Rate-monotonic Scheduling
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, rate-monotonic scheduling (RMS) is a priority assignment algorithm used in
real-time operating system A real-time operating system (RTOS) is an operating system (OS) for real-time applications that processes data and events that have critically defined time constraints. An RTOS is distinct from a time-sharing operating system, such as Unix, which m ...
s (RTOS) with a static-priority scheduling class. The static priorities are assigned according to the cycle duration of the job, so a shorter cycle duration results in a higher job priority. These operating systems are generally preemptive and have deterministic guarantees with regard to response times. Rate monotonic analysis is used in conjunction with those systems to provide scheduling guarantees for a particular application.


Introduction

A simple version of rate-monotonic analysis assumes that threads have the following properties: *No resource sharing (processes do not share resources, ''e.g.'' a hardware resource, a queue, or any kind of
semaphore Semaphore (; ) is the use of an apparatus to create a visual signal transmitted over distance. A semaphore can be performed with devices including: fire, lights, flags, sunlight, and moving arms. Semaphores can be used for telegraphy when arra ...
blocking or non-blocking ( busy-waits)) *Deterministic deadlines are exactly equal to periods *Static priorities (the task with the highest static priority that is runnable immediately preempts all other tasks) *Static priorities assigned according to the ''rate monotonic'' conventions (tasks with shorter periods/deadlines are given higher priorities) *Context switch times and other thread operations are free and have no impact on the model It is a mathematical model that contains a calculated simulation of periods in a closed system, where round-robin and
time-sharing In computing, time-sharing is the sharing of a computing resource among many users at the same time by means of multiprogramming and multi-tasking.DEC Timesharing (1965), by Peter Clark, The DEC Professional, Volume 1, Number 1 Its emergence a ...
schedulers fail to meet the scheduling needs otherwise. Rate monotonic scheduling looks at a run modeling of all threads in the system and determines how much time is needed to meet the guarantees for the set of threads in question.


Optimality

The rate-monotonic priority assignment is ''optimal'' under the given assumptions, meaning that if any static-priority scheduling algorithm can meet all the deadlines, then the rate-monotonic algorithm can too. The deadline-monotonic scheduling algorithm is also optimal with equal periods and deadlines, in fact in this case the algorithms are identical; in addition, deadline monotonic scheduling is optimal when deadlines are less than periods. For the task model in which deadlines can be greater than periods, Audsley's algorithm endowed with an exact schedulability test for this model finds an optimal priority assignment.


Upper bounds on utilization


Least upper bound

proved that for a set of periodic tasks with unique periods, a feasible schedule that will always meet deadlines exists if the CPU utilization is below a specific bound (depending on the number of tasks). The schedulability test for RMS is: :U = \sum_^ = \sum_^ \frac \leq n(^ - 1) where is the utilization factor, is the computation time for process , is the release period (with deadline one period later) for process , and is the number of processes to be scheduled. For example, for two processes. When the number of processes tends towards
infinity Infinity is that which is boundless, endless, or larger than any natural number. It is often denoted by the infinity symbol . Since the time of the ancient Greeks, the philosophical nature of infinity was the subject of many discussions amo ...
, this expression will tend towards: :\lim_ n(\sqrt - 1) = \ln 2 \approx 0.693147\ldots Therefore, a rough estimate when \geq is that RMS can meet all of the deadlines if total CPU utilization, , is less than 70%. The other 30% of the CPU can be dedicated to lower-priority, non-real-time tasks. For smaller values of or in cases where is close to this estimate, the calculated utilization bound should be used. In practice, for the process, should represent the worst-case (i.e. longest) computation time and should represent the worst-case deadline (i.e. shortest period) in which all processing must occur.


Upper bound for harmonic task sets

Liu and Layland noted that this bound may be relaxed to the maximum possible value of 1.0, if for tasks , where and i = 1...m-1, is an integer multiple of , which is to say that all tasks have a period that is not just a multiple of the shortest period, , but instead that any task's period is a multiple of all shorter periods. This is known as an harmonic task set. An example of this would be: ,,= , 3, 6, 12/math>. It is acknowledged by Liu and Layland that it is not always feasible to have a harmonic task set and that in practice other mitigation measures, such as buffering for tasks with soft-time deadlines or using a dynamic priority assignment approach may be used instead to allow for a higher bound.


Generalization to harmonic chains

Kuo and Mok showed that for a task set made up of harmonic task subsets (known as ''harmonic chains''), the least upper bound test becomes: :U = \sum_^ \frac \leq K(^ - 1) In the instance where no task period is an integer multiple of another, the task set can be thought of as being composed of harmonic task subsets of size 1 and therefore , which makes this generalization equivalent to Liu and Layland's least upper bound. When , the upper bound becomes 1.0, representing full utilization.


Stochastic bounds

It has been shown that a randomly generated periodic task system will usually meet all deadlines when the utilization is 88% or less, however this fact depends on knowing the exact task statistics (periods, deadlines) which cannot be guaranteed for all task sets, and in some cases the authors found that the utilization reached the least upper bound presented by Liu and Layland.


Hyperbolic bound

The hyperbolic bound is a tighter sufficient condition for schedulability than the one presented by Liu and Layland: :\prod_^n (U_i +1) \leq 2, where is the CPU utilization for each task. It is the tightest upper bound that can be found using only the individual task utilization factors.


Resource sharing

In many practical applications, resources are shared and the unmodified RMS will be subject to
priority inversion In computer science, priority inversion is a scenario in scheduling in which a high priority task is indirectly superseded by a lower priority task effectively inverting the assigned priorities of the tasks. This violates the priority model that h ...
and
deadlock In concurrent computing, deadlock is any situation in which no member of some group of entities can proceed because each waits for another member, including itself, to take action, such as sending a message or, more commonly, releasing a lo ...
hazards. In practice, this is solved by disabling preemption or by
priority inheritance In real-time computing, priority inheritance is a method for eliminating unbounded priority inversion. Using this programming method, a process scheduling algorithm increases the priority of a process (A) to the maximum priority of any other proce ...
. Alternative methods are to use lock-free algorithms or avoid the sharing of a mutex/semaphore across threads with different priorities. This is so that resource conflicts cannot result in the first place.


Disabling of preemption

*The OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() primitives that lock CPU interrupts in a real-time kernel, e.g.
MicroC/OS-II Micro-Controller Operating Systems (MicroC/OS, stylized as μC/OS) is a real-time operating system (RTOS) designed by Jean J. Labrosse in 1991. It is a priority-based preemptive real-time kernel for microprocessors, written mostly in the programm ...
*The splx() family of primitives which nest the locking of device interrupts (FreeBSD 5.x/6.x),


Priority inheritance

*The ''basic priority inheritance protocol'' promotes the priority of the task that holds the resource to the priority of the task that requests that resource at the time the request is made. Upon release of the resource, the original priority level before the promotion is restored. This method does not prevent deadlocks and suffers from ''chained blocking''. That is, if a high priority task accesses multiple shared resources in sequence, it may have to wait (block) on a lower priority task for each of the resources. Th
real-time patch
to the
Linux kernel The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ope ...
includes an implementation of this formula. *The
priority ceiling protocol In real-time computing, the priority ceiling protocol is a synchronization protocol for shared resources to avoid unbounded priority inversion and mutual deadlock due to wrong nesting of critical sections. In this protocol each resource is assign ...
enhances the basic priority inheritance protocol by assigning a ''ceiling priority'' to each semaphore, which is the priority of the highest job that will ever access that semaphore. A job cannot preempt a lower priority critical section if its priority is lower than the ceiling priority for that section. This method prevents deadlocks and bounds the blocking time to at most the length of one lower priority critical section. This method can be suboptimal, in that it can cause unnecessary blocking. The priority ceiling protocol is available in the
VxWorks VxWorks is a real-time operating system (or RTOS) developed as proprietary software by Wind River Systems, a wholly-owned subsidiary of Aptiv. First released in 1987, VxWorks is designed for use in embedded systems requiring real-time, determin ...
real-time kernel. It is also known as ''Highest Locker's Priority Protocol'' (HLP). Priority inheritance algorithms can be characterized by two parameters. First, is the inheritance lazy (only when essential) or immediate (boost priority before there is a conflict). Second is the inheritance optimistic (boost a minimum amount) or pessimistic (boost by more than the minimum amount): In practice there is no mathematical difference (in terms of the Liu-Layland system utilization bound) between the lazy and immediate algorithms, and the immediate algorithms are more efficient to implement, and so they are the ones used by most practical systems. An example of usage of basic priority inheritance is related to the "
Mars Pathfinder ''Mars Pathfinder'' (''MESUR Pathfinder'') is an American robotic spacecraft that landed a base station with a roving probe on Mars in 1997. It consisted of a lander, renamed the Carl Sagan Memorial Station, and a lightweight, wheeled robot ...
reset bug" which was fixed on Mars by changing the creation flags for the semaphore so as to enable the priority inheritance.


Interrupt Service Routines

All interrupt service routines (ISRs), whether they have a hard real-time deadline or not should be included in RMS analysis to determine schedulability in cases where ISRs have priorities above all scheduler-controlled tasks. An ISR may already be appropriately prioritized under RMS rules if its processing period is shorter than that of the shortest, non-ISR process. However, an ISR with a period/deadline longer than any non-ISR process period with a critical deadline results in a violation of RMS and prevents the use of the calculated bounds for determining schedulability of a task set.


Mitigating mis-prioritized ISRs

One method for mitigating a mis-prioritized ISR is to adjust the analysis by reducing the ISR's period to be equal to that of the shortest period, if possible. Imposing this shorter period results in prioritization that conforms to RMS, but also results in a higher utilization factor for the ISR and therefore for the total utilization factor, which may still be below the allowable bound and therefore schedulability can be proven. As an example, consider a hardware ISR that has a computation time, of 500 microseconds and a period, , of 4 milliseconds. If the shortest scheduler-controlled task has a period, of 1 millisecond, then the ISR would have a higher priority, but a lower rate, which violates RMS. For the purposes of proving schedulability, set = and recalculate the utilization factor for the ISR (which also raises the total utilization factor). In this case, / will change from /0.125 to /0.5. This utilization factor would be used when adding up the total utilization factor for the task set and comparing to the upper bound to prove schedulability. It should be emphasized that adjusting the period of the ISR is for analysis only and that the true period of the ISR remains unchanged. Another method for mitigating a mis-prioritized ISR is to use the ISR to only set a new semaphore/mutex while moving the time-intensive processing to a new process that has been appropriately prioritized using RMS and will block on the new semaphore/mutex. When determining schedulability, a margin of CPU utilization due to ISR activity should be subtracted from the least upper bound. ISRs with negligible utilization may be ignored.


Examples


Example 1

Under RMS, P2 has the highest rate (i.e. the shortest period) and so would have the highest priority, followed by P1 and finally P3.


Least Upper Bound

The utilization will be: \frac + \frac + \frac = 0.725. The sufficient condition for 3\, processes, under which we can conclude that the system is schedulable is: : = 3(2^\frac - 1) = 0.77976 > 0.693\ldots (0.693 \text n=\infty \ldots ) Because 0.77976 \geq 0.725, and because being below the Least Upper Bound is a sufficient condition, the system is guaranteed to be schedulable.


Example 2

Under RMS, P2 has the highest rate (i.e. the shortest period) and so would have the highest priority, followed by P3 and finally P1.


Least Upper Bound

Using the Liu and Layland bound, as in Example 1, the sufficient condition for 3\, processes, under which we can conclude that the task set is schedulable, remains: : = 3(2^\frac - 1) = 0.77976 The total utilization will be: \frac + \frac + \frac = 0.7875. Since 0.77976 0.7875 the system is determined to ''not'' be guaranteed to be schedulable by the Liu and Layland bound.


Hyperbolic Bound

Using the tighter Hyperbolic bound as follows: :\prod_^n (U_i +1) = (\frac+1) * (\frac+1) * (\frac+1) = 1.995 \leq 2 it is found that the task set ''is'' schedulable.


Example 3

Under RMS, P2 has the highest rate (i.e. the shortest period) and so would have the highest priority, followed by P3 and finally P1.


Least Upper Bound

Using the Liu and Layland bound, as in Example 1, the sufficient condition for 3\, processes, under which we can conclude that the task set is schedulable, remains: : = 3(2^\frac - 1) = 0.77976 The total utilization will be: \frac + \frac + \frac = 0.81875. Since 0.77976 0.81875 the system is determined to ''not'' be guaranteed to be schedulable by the Liu and Layland bound.


Hyperbolic Bound

Using the tighter Hyperbolic bound as follows: :\prod_^n (U_i +1) = (\frac+1) * (\frac+1) * (\frac+1) = 2.0475 Since 2.0 2.0475 the system is determined to ''not'' be guaranteed to be schedulable by the Hyperbolic bound.


Harmonic Task Set Analysis

Because =, tasks 2 and 3 can be considered a harmonic task subset. Task 1 forms its own harmonic task subset. Therefore, the number of harmonic task subsets, , is . : = K(2^\frac - 1) = 2(2^\frac - 1) = 0.828 Using the total utilization factor calculated above (0.81875), since 0.81875 < 0.828 the system is determined to be schedulable.


See also

* Deadline-monotonic scheduling *
Deos DDC-I, Inc. is a privately held company providing software development of real-time operating systems, software development tools, and software services for safety-critical embedded applications, headquartered in Phoenix, Arizona. It was first cr ...
, a time and space partitioned real-time operating system containing a working Rate Monotonic Scheduler. *
Dynamic priority scheduling Dynamic priority scheduling is a type of scheduling algorithm in which the priorities are calculated during the execution of the system. The goal of dynamic priority scheduling is to adapt to dynamically changing progress and to form an optimal con ...
*
Earliest deadline first scheduling Earliest deadline first (EDF) or least time to go is a dynamic priority scheduling algorithm used in real-time operating systems to place processes in a priority queue. Whenever a scheduling event occurs (task finishes, new task released, etc.) ...
*
RTEMS Real-Time Executive for Multiprocessor Systems (RTEMS), formerly Real-Time Executive for Missile Systems, and then Real-Time Executive for Military Systems, is a real-time operating system (RTOS) designed for embedded systems. It is free and open ...
, an open source real-time operating system containing a working Rate Monotonic Scheduler. *
Scheduling (computing) In computing, scheduling is the action of assigning ''resources'' to perform ''tasks''. The ''resources'' may be processors, network links or expansion cards. The ''tasks'' may be threads, processes or data flows. The scheduling activity is c ...


References


Further reading

*. * *, Chapter 6. *. *


External links


Mars Pathfinder Bug
from Research @ Microsoft

from The Risks Digest, Vol. 19, Issue 49

The actual reason for the Mars Pathfinder Bug, by those who actually dealt with it, rather than someone whose company and therefore stock value depended upon the description of the problem, or someone who heard someone talking about the problem. {{Processor scheduling Processor scheduling algorithms Real-time computing