The way a real-time operating system (RTOS) schedules tasks guarantees that high-priority tasks execute within precise time constraints. Understanding how scheduling works in an RTOS can help you set the right priorities for deterministic tasks in your application.
The following list contains some key concepts that underlie the RTOS scheduling process:
At any given time, every thread in a real-time system is either running or blocked.
When a thread becomes unblocked, it enters the run queue in order of priority.
The RTOS scheduler handles new Timed Loop threads that enter the run queue in different ways depending on their priorities.
Use the following table to decide how to set relative priorities for Timed Loops in a real-time application so that the application meets timing requirements.
|Priority of new Timed Loop thread||RTOS scheduler behavior|
|Higher priority than running thread||The scheduler preempts the running thread so that the new thread can execute immediately. The preempted thread then moves behind the new thread in the run queue.|
|Equal priority as running thread||The scheduler places the new thread behind all other threads of the same priority in the run queue. Threads of equal priority are scheduled according to a first-in, first-out policy.|
|Lower priority than running thread||The scheduler allows the new thread to run only after all higher-priority threads are blocked.|