No version for distro humble. Known supported distros are highlighted in the buttons above.
No version for distro jazzy. Known supported distros are highlighted in the buttons above.
No version for distro rolling. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 0.0.1
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description Minimal ROS 2 real-time cookbook recipes
Checkout URI https://github.com/ros-realtime/ros2-realtime-examples.git
VCS Type git
VCS Version rolling
Last Updated 2023-06-05
Dev Status UNKNOWN
CI status No Continuous Integration
Released UNRELEASED
Tags real-time cpp realtime ros ros2 rclcpp
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples of minimal CPU affinity configuration

Additional Links

No additional links.

Maintainers

  • Carlos San Vicente

Authors

  • Carlos San Vicente

minimal_cpu_affinity

These examples show how to pin the process or some threads to one or multiple CPUS.

Note: The code shown in the examples is not necessarily real-time safe. The aim of these examples is to show a minimal usage example for a particular concept.

How to run

minimal_cpu_affinity_main_thread

For this example, we will be configuring the main thread CPU affinity. In this case, the thread middleware threads will not inherit these settings because they are created after the affinity configuration.

$ ros2 run minimal_cpu_affinity minimal_cpu_affinity_main_thread

Use htop or ps to observe which CPU is being used by each thread

$ ps -C minimal_cpu_aff -L -o tid,comm,rtprio,cls,psr
    TID COMMAND         RTPRIO CLS PSR
   6614 minimal_cpu_aff      -  TS   1
   6615 minimal_cpu_aff      -  TS   4
   6616 gc                   -  TS   2
   6617 dq.builtins          -  TS   7
   6618 dq.user              -  TS   6
   6619 tev                  -  TS   4
   6620 recv                 -  TS   5
   6621 recvMC               -  TS   3
   6622 recvUC               -  TS   0
   6623 minimal_cpu_aff      -  TS   1

You can enable the processor column in htop. Note by default htop starts the CPU processor counting at 1 instead of 0 as ps does.

minimal_cpu_affinity_middleware_threads

For this example, we will be configuring the main thread CPU affinity. In this case, the thread middleware threads will inherit these settings because they are created after the affinity configuration.

$ ros2 run minimal_cpu_affinity minimal_cpu_affinity_middleware_threads

Use htop or ps to observe which CPU is being used by each thread

$ ps -C minimal_cpu_aff -L -o tid,comm,rtprio,cls,psr
    TID COMMAND         RTPRIO CLS PSR
   6686 minimal_cpu_aff      -  TS   1
   6687 minimal_cpu_aff      -  TS   1
   6688 gc                   -  TS   1
   6689 dq.builtins          -  TS   1
   6690 dq.user              -  TS   1
   6691 tev                  -  TS   1
   6692 recv                 -  TS   1
   6693 recvMC               -  TS   1
   6694 recvUC               -  TS   1
   6695 minimal_cpu_aff      -  TS   1

minimal_cpu_affinity_mask

In this case, we pin all the thread to CPUs 2 and 3 using a CPU affinity mask.

$ ros2 run minimal_cpu_affinity minimal_cpu_affinity_mask

Use htop or ps to observe which CPU is being used by each thread

$ ps -C minimal_cpu_aff -L -o tid,comm,rtprio,cls,psr
    TID COMMAND         RTPRIO CLS PSR
    TID COMMAND         RTPRIO CLS PSR
   6941 minimal_cpu_aff      -  TS   2
   6942 minimal_cpu_aff      -  TS   3
   6943 gc                   -  TS   3
   6944 dq.builtins          -  TS   3
   6945 dq.user              -  TS   3
   6946 tev                  -  TS   3
   6947 recv                 -  TS   2
   6948 recvMC               -  TS   3
   6949 recvUC               -  TS   3
   6950 minimal_cpu_aff      -  TS   3

Resources

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

System Dependencies

No direct system dependencies.

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged minimal_cpu_affinity at Robotics Stack Exchange

No version for distro noetic. Known supported distros are highlighted in the buttons above.
No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro eloquent. Known supported distros are highlighted in the buttons above.
No version for distro dashing. Known supported distros are highlighted in the buttons above.
No version for distro galactic. Known supported distros are highlighted in the buttons above.
No version for distro foxy. Known supported distros are highlighted in the buttons above.
No version for distro iron. Known supported distros are highlighted in the buttons above.
No version for distro lunar. Known supported distros are highlighted in the buttons above.
No version for distro jade. Known supported distros are highlighted in the buttons above.
No version for distro indigo. Known supported distros are highlighted in the buttons above.
No version for distro hydro. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.