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 practical disciplines (includin ...
, 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 ...
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 ar ...
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 ...
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
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, an ...
utilization is below a specific bound (depending on the number of tasks). The schedulability test for RMS is:
:
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 am ...
, this expression will tend towards:
:
Therefore, a rough estimate when
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
,
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: