Scheduling Algorithms in RTOS


  Based on scheduling algorithms, scheduler decides the task execution. 
There are two types

·         Preemptive priority based scheduling:
o   Most real time kernels use this scheduling by default.
o   Real-time kernels generally support 256 priority levels, in which 0 is the highest and 255 thelowest. Some kernels appoint the priorities in reverse order,
o   Tasks are assigned Priority levels when they are created, task priority can be changed dynamically using kernel provided calls.
o     With a preemptive priority-based scheduler, each task has a priority, and the highest-priority task runs first.
o   Task 1 ispreempted by higher-priority task 2, which is then preempted by task 3. When task 3 completes,task 2 resumes; likewise, when task 2 completes, task 1 resumes.
·         Round Robin scheduling:
o   Round-robin scheduling provides each task an equal share of the CPU execution time.
o   Which uses time slicing toachieve equal allocation of the CPU for tasks of the same priority.
o     A run-time counter tracks the time slice for each task, incrementing onevery clock tick. When one task’s time slice completes, the counter is cleared, and the task isplaced at the end of the cycle.

If a task in a round-robin cycle is preempted by a higher-priority task, its run-time count is savedand then restored when the interrupted task is again eligible for execution. This idea is illustratedin Figure, in which task 1 is preempted by a higher-priority task 4 but resumes where it left offwhen task 4 completes.

No comments:

Post a Comment