Understanding Scheduling Strategies in RTOS Applications

Follow+Star Public Account, don’t miss out on exciting content
Understanding Scheduling Strategies in RTOS Applications
Source | Microtech Technology

Transitioning from software development with a front-back architecture to using Real-Time Operating Systems (RTOS) can be a challenging task. However, there are many advantages to using RTOS, such as simplifying application integration and supporting task preemption scheduling. It becomes meaningful to use RTOS when developers work with complex 32-bit microcontrollers and have sufficient Flash and RAM space. Many 32-bit applications require the use of USB, TCP/IP, and file systems, which are very difficult to develop for bare-metal applications, and most third-party middleware is designed to integrate seamlessly with RTOS.

Before using RTOS, users may need to delve deep into the details of RTOS. Let’s take a look at commonly used scheduling techniques in RTOS.

1

Time-Slice Round-Robin Scheduling

Front-back system implementations are typically based on polling scheduling techniques, which is a natural way to write software; simply adding new code to the super loop is equivalent to adding a new task. The round-robin scheduling strategy in RTOS allows multiple tasks to be assigned the same priority level. The scheduler monitors task time based on the clock; tasks at the relevant priority level execute their allocated time slices in a first-come, first-served manner. When the time is up, even if the current task has not been completed, the task will pass the CPU time to the next task. In the next allocated time period, that task will continue executing from where it stopped.
Commonly used RTOS, such as μC/OS-III (Cs/OS3) and FreeRTOS, support the time-slice round-robin algorithm. In FreeRTOS, the time slice length for each task is fixed, set to one time tick; while in μC/OS-III, the time slice length for each task can be variable and specified at task creation.
Understanding Scheduling Strategies in RTOS Applications

2

Priority-Based Cooperative Scheduling

In RTOS, cooperative scheduling is a priority-based non-preemptive scheduling method. Tasks are sorted by priority and are event-driven; once a running task completes or voluntarily yields the CPU by calling OS services, only the highest-priority ready task can gain CPU usage.
Understanding Scheduling Strategies in RTOS Applications

3

Preemptive Scheduling

RTOS ensures real-time performance through preemptive scheduling. To guarantee task responsiveness, in a preemptive scheduling strategy, whenever a higher-priority task becomes ready, the currently running lower-priority task will be switched out. Through preemption, the currently running task is forced to relinquish the processor, even if the task has not completed its work.
Understanding Scheduling Strategies in RTOS Applications
RTOS can typically be configured to use many deterministic scheduling algorithms to ensure task deadlines are met. For example, FreeRTOS and μC/OS-III support both preemptive and time-slice round-robin scheduling methods.

4

Conclusion

RTOS is a powerful tool for embedded software developers. In RTOS applications, each task has a separate task control block, which contains parameters such as stack, priority, and ID. Each task can be viewed as a separate application. RTOS also provides a variety of synchronization and communication tools, such as semaphores, mutexes, and message queues, simplifying application development.
However, task switching consumes CPU time; even on 32-bit processors, RTOS can incur time overhead. Task switching takes more time than interrupts. If it is a very small application but needs to fully utilize processor resources, in such cases, careful consideration of the feasibility of RTOS is required.
Each scheduling algorithm has its pros and cons. Understanding commonly used scheduling algorithms in RTOS can help us make appropriate choices.

———— END ————

Understanding Scheduling Strategies in RTOS Applications

● Column “Embedded Tools”

● Column “Embedded Development”

● Column “Keil Tutorials”

● Selected Tutorials from Embedded Column

Follow the public account reply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.

Understanding Scheduling Strategies in RTOS Applications

Understanding Scheduling Strategies in RTOS Applications

Click “Read Original” to see more shares.

Leave a Comment

Your email address will not be published. Required fields are marked *