Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 3.43 KB

File metadata and controls

73 lines (50 loc) · 3.43 KB

minimal_scheduling

These examples show how to configure the thread scheduling policy and priority using pthread APIs.

Requirements

Adjust permissions for the scheduler, see (https://docs.ros.org/en/foxy/Tutorials/Real-Time-Programming.html#setting-permissions-for-the-scheduler) or run as root.

How to run

minimal_sched_fifo_main_thread

For this example, we will be configuring the main thread scheduling policy with a SCHED_FIFO real-time scheduling and with real-time priority. In this case, the thread middleware threads will not inherit these settings because they are created after the scheduling configuration.

$ ros2 run minimal_scheduling minimal_sched_fifo_main_thread

Use htop or ps to observe the priorities of the threads.

minimal_sched_fifo_middleware_threads

For this example, we will be configuring the main thread scheduling policy before the node creation. The thread middleware threads will inherit these settings because they are created after the scheduling configuration.

This could be interesting when middleware communications shall not participate in the real-time execution. Also, this could be useful with some DDS implementations which allow to configure each thread scheduling individually, allowing to set a priority different to the main thread.

$ ros2 run minimal_scheduling minimal_sched_fifo_middleware_threads

Use htop or ps to observe the priorities of the threads.

minimal_sched_fifo_spin_thread

For this example, we will be configuring the scheduling policy of a thread used to spin the executor. In this case, the thread middleware threads will not inherit these settings because the settings apply only to the spinner thread.

$ ros2 run minimal_scheduling minimal_sched_fifo_spin_thread

Use htop or ps to observe the priorities of the threads.

minimal_sched_fifo_callback_group

For this example, we will be using multiple callback groups to separate callbacks, so it is possible to spin them in threads with different scheduling priorities.

$ ros2 run minimal_scheduling minimal_sched_fifo_callback_group

Use htop or ps to observe the priorities of the threads.

Resources