Ready for a change?
Your ad here. Buy Media Now
Introduction to Rate Monotonic Scheduling
By Michael Barr
Embedded Systems Design
(02/28/02, 09:38:34 AM EST)
If you've got a lot of tasks to do, and tight dead-lines to
meet, what's the best way to prioritize them?
The scheduling algorithm you choose depends on your goals. Different algorithms yield
different results. Let's suppose you're given ten jobs and each will take a day to finish.
In ten days, you will have all of them done. But what if one or more has a deadline? If
the ninth task given to you has a deadline in three days, then doing the tasks in the
order you receive them will cause you to miss that deadline.
The purpose of a real-time scheduling algorithm is to ensure that critical timing
constraints, such as deadlines and response time, are met. When necessary, decisions
are made that favor the most critical timing constraints, even at the cost of violating
others. Real-time scheduling is also used to allocate processor time between tasks in
soft real-time embedded systems.
Many real-time systems use preemptive multitasking, especially those with an
underlying real-time operating system (RTOS). Priorities are assigned to tasks, and the
RTOS always executes the ready task with highest priority.
In this case, the scheduling algorithm is the method in which priorities are assigned.
Most algorithms are classified as fixed priority, dynamic priority, or mixed priority. A
fixed-priority algorithm assigns all priorities at design time, and those priorities remain
constant for the lifetime of the task. A dynamic-priority algorithm assigns priorities at
runtime, based on execution parameters of tasks, such as upcoming deadlines. A
mixed-priority algorithm has both static and dynamic components. Needless to say,
fixed-priority algorithms tend to be simpler than algorithms that must compute
priorities on the fly.
To demonstrate the importance of a scheduling algorithm, consider a system with only
two tasks, which we'll call t
. Assume these are both periodic tasks with periods
, and each has a deadline that is the beginning of its next cycle. Task t
= 50ms, and a worst-case execution time of C1 = 25ms. Task t
= 40ms. Note that the utilization, U
, of task ti is C
. Thus U
= 50% and U
40%. This means total requested utilization U = U
= 90%. It seems logical that
if utilization is less than 100%, there should be enough available CPU time to execute
Let's consider a static priority scheduling algorithm. With two tasks, there are only two
Case 1: Priority(t
) > Priority(t
Case 2: Priority(t
) < Priority(t
The two cases are shown in Figure1. In Case 1, both tasks meet their respective
deadlines. In Case 2, however, t
misses a deadline, despite 10% idle time. This
illustrates the importance of priority assignment.