Search topics and sections

Real-time computing is the part of computer science that studies systems that must respond within strict time limits. In such a system, a result is correct only if it is logically right and also produced on time [1]. A vehicle's automatic brake controller, for example, must detect an obstacle and apply the brakes before the vehicle reaches it [2].

Each time limit is called a deadline. Missing a hard deadline can cause very serious harm, while missing a soft deadline only makes performance worse [2].

Engineers use scheduling rules and mathematical tests to show, before a system runs, that its deadlines will be met.

Correct and on time

Time is part of correctness

Real-time computing adds time to the meaning of a correct answer. Stankovic defined real-time systems as those whose correctness depends on both the logical result of a computation and the time at which the result is produced [1]. A correct value that arrives too late can still be a failure.

Not the same as fast

One misconception Stankovic addressed is that real-time computing is the same as fast computing [1]. Fast computing tries to reduce the average response time of a set of tasks, while real-time computing tries to meet the timing requirement of each individual task [2]. However short the average is, it does not guarantee that every task meets its requirement in every situation [2].

Predictability

Real-time design therefore stresses predictability, which means knowing in advance that every critical timing requirement will be met [2]. Most methods on this page exist to make timing predictable and to check it.

Where deadlines come from

Deadlines need not be stated by the user. They can be derived from the needs of the physical system being controlled [2]. Buttazzo shows this with an automatic braking system for a vehicle, such as a train, that moves along a straight line [2].

A brake control unit runs a periodic task, one that runs again at regular intervals, with period TT. Each run reads range sensors, computes the distance to any obstacle, and decides whether to make an emergency stop [2]. In the worst case, three delays add up before the vehicle stops [^2]:

  1. The detection delay runs from the moment an obstacle appears to the moment the control unit detects it. It is at most one period TT.
  2. The transmission delay Δt\Delta t runs from the moment the control unit issues the stop command to the moment the brakes start to act.
  3. The braking duration is the time the vehicle needs to come to a complete stop.
Speed against time during an emergency stopDetection delayup to TTransmissiondelay ΔtBraking timeΔb = v / (μf g)SpeedvTimeObstacle appears (t₀)Vehicle stopsStopping distance
During an emergency stop the speed stays at vv through the detection delay (up to TT) and the transmission delay Δt\Delta t. It then falls in a straight line to zero over the braking time Δb=v/(μfg)\Delta b = v/(\mu_f g), and the stopping distance is the shaded area under the curve.

During the first two delays the vehicle keeps moving at full speed and covers v(T+Δt)v(T + \Delta t). Braking then covers v2/(2μfg)v^2/(2\mu_f g). To guarantee that no collision occurs, the obstacle's distance DD must exceed the total [^2]:

D>v22μfg+v (T+Δt)D > \frac{v^2}{2\mu_f g} + v\,(T + \Delta t)

Here vv is the vehicle's speed, μf\mu_f is the wheel-road friction coefficient, gg is the acceleration due to gravity, TT is the sensor task's period, and Δt\Delta t is the transmission delay. Solving for TT gives the longest safe period [^2]:

T<Dv−v2μfg−ΔtT < \frac{D}{v} - \frac{v}{2\mu_f g} - \Delta t

A timing requirement on the software thus follows from speed, friction, and sensor range.

Hard, firm, and soft deadlines

Deadlines are classed by what happens when one is missed [2].

Type Effect of a missed deadline Example
Hard May cause catastrophic consequences for the system under control Emergency braking [2]
Firm Causes no damage, but the late result is useless Skipping a late video frame [3]
Soft The late result is still useful, but performance degrades Handling keyboard input or updating a display [2]

A value function shows the same idea as a graph. It gives the value that a result has for the system as a function of the time the task finishes [2]. The value after the deadline differs by task type [^2]:

Task type Value after the deadline
Non-real-time Stays the same; there is no deadline
Soft Falls gradually
Firm Drops to zero
Hard Can be treated as minus infinity
Value functions for hard, firm, and soft deadlinesHardFirmSoftdddfinishing time ffinishing time ffinishing time fvalue v(f)value v(f)value v(f)−∞
Value v(f)v(f) of a task as a function of its finishing time ff for hard, firm, and soft deadlines dd. The value before the deadline is the same in all three cases. After it, the value falls to −∞-\infty, falls to zero, or declines gradually.

A system that mixes these classes must guarantee that every hard task meets its deadline [2]. Soft tasks get best-effort service, in which the system tries to keep their average response time short [2].

Tasks, jobs, and timing parameters

Real-time theory describes a system's work as a set of tasks. A task is code that runs again and again, and each run is called a job or instance [2]. Tasks are grouped by how their jobs arrive [^2]:

  • Periodic tasks release a job at regular intervals, called the period TiT_i.
  • Aperiodic tasks release jobs at irregular times.
  • Sporadic tasks are aperiodic tasks with a known minimum time between arrivals, which makes it possible to give them guarantees.

Each job is described by a few times [^2]:

  • The arrival time aia_i (also called the release time rir_i) is when the job becomes ready to run.
  • The computation time CiC_i is the processor time it needs without interruption.
  • The start time sis_i and finishing time fif_i are when it first runs and when it completes.
  • The absolute deadline did_i is the time by which it must finish.
Timing parameters of a real-time jobPreemptedDᵢ (relative deadline)Rᵢ (response time)Time to sparerᵢsᵢfᵢdᵢCᵢ (computation time)TimeReleaseStartFinishDeadline
Timing parameters of a single real-time job JiJ_i: release time rir_i, start time sis_i, finish time fif_i and absolute deadline did_i. The computation time CiC_i is the total length of the shaded execution intervals, the response time is Ri=fi−riR_i = f_i - r_i, and the relative deadline is Di=di−riD_i = d_i - r_i.

Other quantities follow from these [^2]:

  • The relative deadline Di=di−aiD_i = d_i - a_i is the time allowed after arrival.
  • The response time Ri=fi−aiR_i = f_i - a_i is the time the job actually takes.
  • The lateness Li=fi−diL_i = f_i - d_i is a job's finishing time minus its deadline, so it is negative when the job finishes early.

The slack, or laxity, Xi=di−ai−CiX_i = d_i - a_i - C_i is the longest a job can wait after arrival and still finish on time if it then runs without interruption [2].

Jitter is the variation in timing between jobs of the same periodic task, such as changes in their start or finishing times [2].

For periodic tasks that all start at time 0, the schedule repeats after the hyperperiod H=lcm⁡(T1,…,Tn)H = \operatorname{lcm}(T_1, \dots, T_n), the least common multiple of the periods [2]. Checking one hyperperiod therefore shows the whole schedule.

Scheduling real-time tasks

A scheduler decides which ready job runs at each moment. Most real-time schedulers use preemption, which means they can suspend a running job to run a more urgent one and resume it later [2].

Cyclic executive

The simplest method fixes the whole schedule in advance. A cyclic executive, also called timeline scheduling, divides time into equal slots called minor cycles. A timer starts each slot, and a fixed table says which tasks run in it and repeats every major cycle [2].

Buttazzo's example uses three tasks, A, B, and C, that must run at 40, 20, and 10 Hz, so their periods are 25, 50, and 100 ms [2]. The minor cycle is the greatest common divisor of the periods (the largest number that divides them all evenly, here 25 ms). The major cycle is their least common multiple (the smallest number that is a whole multiple of every period, here 100 ms).

A runs in every slot, B in every second slot, and C in every fourth slot. This works only if CA+CB≤25C_A + C_B \le 25 ms and CA+CC≤25C_A + C_C \le 25 ms [2].

Cyclic executive schedule over one major cycleABACABA0255075100Time (ms)major cycle = 100 msminor cycle = 25 msidleA, 40 HzB, 20 HzC, 10 Hz
A cyclic executive repeats a fixed table over a 100 ms major cycle made of four 25 ms minor cycles. Task A runs in every minor cycle (40 Hz), B runs in every second one (20 Hz), and C runs once per major cycle (10 Hz).

The method has clear trade-offs [^2]:

  • It is simple and has very low overhead (extra processing time spent on managing tasks), because a main program calls the tasks in order and no scheduler switches between them.
  • Task start times barely vary, so jitter is low.
  • It is fragile under overload. A task that overruns its slot can break the rest of the schedule.
  • It is hard to change. A longer computation time or a new frequency may force the whole table to be rebuilt.
  • It handles aperiodic work poorly.

Fixed priorities

A priority-driven scheduler always runs the ready job with the highest priority. In fixed-priority scheduling, each task has one priority that all its jobs share [2]. Two rules are standard:

Rule Higher priority goes to Result
Rate-monotonic (RM) Shorter periods Optimal among fixed-priority methods when deadlines equal periods (Liu and Layland, 1973) [4]
Deadline-monotonic Shorter relative deadlines Optimal among fixed-priority methods when deadlines may be shorter than periods (Leung and Whitehead, 1982) [2]

Optimal here means that if any fixed priority assignment can schedule a set of periodic tasks, the rule can as well [4]. Liu and Layland's proof assumes independent periodic tasks with deadlines equal to periods and constant computation times, running with preemption on one processor [4].

Dynamic priorities

With dynamic priorities, a task's priority can change from one job to the next. Earliest deadline first (EDF) scheduling always runs the ready job whose absolute deadline is nearest [2].

EDF has strong optimality results on one processor with preemption. In 1974 Horn showed that it minimizes the maximum lateness of independent jobs with arbitrary arrival times, and Dertouzos showed that if any algorithm can meet all deadlines, EDF can as well [2].

These results need preemption. When preemption is not allowed, EDF is no longer optimal [2].

Comparing RM and EDF

Consider τ1\tau_1 with C1=2C_1 = 2 and T1=5T_1 = 5, and τ2\tau_2 with C2=4C_2 = 4 and T2=7T_2 = 7, which together use 2/5+4/7≈0.972/5 + 4/7 \approx 0.97 of the processor [2]. Under RM, τ1\tau_1 preempts τ2\tau_2 at t=5t = 5, so τ2\tau_2 has done only 3 of its 4 units when its deadline passes at t=7t = 7. Under EDF, τ2\tau_2 keeps running at t=5t = 5 because its deadline (7) is earlier than that of τ1\tau_1's new job (10), and every deadline is met [2].

Rate monotonic versus EDF schedulesDeadline missRate monotonicEDFτ1τ2τ1τ202468101214Time
Rate monotonic and EDF schedules for τ1\tau_1 (C=2C=2, T=5T=5) and τ2\tau_2 (C=4C=4, T=7T=7), with deadlines equal to the next release. Under rate monotonic, τ2\tau_2 misses its deadline at t=7t=7 with one unit of work left. EDF meets every deadline.

Buttazzo compared the two methods in detail [5] [^2]:

Property RM EDF
Priorities Fixed per task, by period Dynamic per job, by absolute deadline
Guaranteed utilization (Di=TiD_i = T_i) n(21/n−1)n(2^{1/n} - 1), about 0.69 for large nn 1
Exact test (Di=TiD_i = T_i) Pseudo-polynomial (response time analysis) O(n)O(n): check U≤1U \le 1
Ready-queue insertion O(1)O(1) with one queue per priority level, if levels are few O(log⁡n)O(\log n) with a heap (a tree-shaped queue)
Preemptions More Fewer
Permanent overload Lower-priority tasks may never run All tasks run at a lower rate

The table uses these terms:

  • nn is the number of tasks.
  • O(1)O(1) means the work is fixed no matter how many tasks there are.
  • O(log⁡n)O(\log n) means the work grows very slowly as tasks are added.
  • O(n)O(n) means the work grows in proportion to nn.
  • Pseudo-polynomial means the work also grows with the size of the task periods, not only with their number.

EDF must compute a new absolute deadline for each job, but it causes fewer preemptions. So its total operating system overhead is lower than under RM when context switches (the work of saving one task's state and loading another's) are counted [5].

Under permanent overload, Cervin and colleagues proved that with EDF each task settles to an average period of TiUT_i U, as if every period were stretched by the same factor [5].

Schedulability analysis

Schedulability analysis checks, before a system runs, whether a set of tasks will always meet its deadlines under a given scheduler. A task set that passes is called schedulable.

Processor utilization

The processor utilization UU is the fraction of processor time that a set of nn periodic tasks needs [^3]:

U=∑i=1nCiTiU = \sum_{i=1}^{n} \frac{C_i}{T_i}

Here CiC_i is the computation time of task ii and TiT_i its period. If U>1U > 1, the tasks need more time than exists, and no algorithm can schedule them [2].

Utilization bounds

Liu and Layland proved that RM meets all deadlines if [4]

U≤n(21/n−1)U \le n\left(2^{1/n} - 1\right)

This Liu and Layland bound holds under the assumptions listed for RM above. It falls as nn grows: 1.000 for one task, 0.828 for two, 0.780 for three, and 0.718 for ten [2]. Its limit for large nn is ln⁡2≈0.69\ln 2 \approx 0.69, which is why Liu and Layland wrote that this bound may be as low as 70 percent for large task sets [4].

Liu and Layland utilization bound for rate-monotonic schedulingn(21/n − 1)ln 2 ≈ 0.69 (limit as n grows)0.60.70.80.91.012345678910Number of tasks nUtilization boundschedulable by RM (sufficient test)
The Liu and Layland bound U≤n(21/n−1)U \le n(2^{1/n} - 1) for rate-monotonic scheduling drops from 1 for one task to about 0.718 for ten tasks. As nn grows it approaches ln⁡2≈0.693\ln 2 \approx 0.693.

The bound is a sufficient test: passing it proves the set is schedulable, but failing it does not prove the opposite [2]. Many task sets above the bound still meet all deadlines.

Lehoczky, Sha, and Ding found that RM could schedule random task sets up to an average load of about 88% [2].

EDF has an exact test. Under the same assumptions, Liu and Layland proved that EDF meets all deadlines if and only if U≤1U \le 1 [4].

Response time analysis

Response time analysis is an exact test for fixed priorities when deadlines do not exceed periods [2]. It computes each task's worst-case response time RiR_i and checks that Ri≤DiR_i \le D_i. With tasks numbered by priority, task 1 being the highest, RiR_i is the smallest solution of

Ri=Ci+∑j<i⌈RiTj⌉CjR_i = C_i + \sum_{j<i} \left\lceil \frac{R_i}{T_j} \right\rceil C_j

The sum is the interference from higher-priority tasks. In a window of length RiR_i, task jj releases at most ⌈Ri/Tj⌉\lceil R_i/T_j \rceil jobs, each needing CjC_j. The equation is solved by repeating

Ri(k+1)=Ci+∑j<i⌈Ri(k)Tj⌉CjR_i^{(k+1)} = C_i + \sum_{j<i} \left\lceil \frac{R_i^{(k)}}{T_j} \right\rceil C_j

starting from Ri(0)=∑j≤iCjR_i^{(0)} = \sum_{j \le i} C_j, the computation times of task ii and all higher-priority tasks. The iteration stops when the value stops changing or exceeds DiD_i [2].

Take three tasks with (Ci,Ti)(C_i, T_i) equal to (1, 4), (2, 6), and (3, 10), deadlines equal to periods, under RM. Their utilization is about 0.88, above the three-task bound of 0.780, so the utilization test cannot decide. For τ3\tau_3 the iteration runs as follows:

  1. R3(0)=1+2+3=6R_3^{(0)} = 1 + 2 + 3 = 6
  2. R3(1)=3+⌈6/4⌉⋅1+⌈6/6⌉⋅2=7R_3^{(1)} = 3 + \lceil 6/4 \rceil \cdot 1 + \lceil 6/6 \rceil \cdot 2 = 7
  3. R3(2)=3+⌈7/4⌉⋅1+⌈7/6⌉⋅2=9R_3^{(2)} = 3 + \lceil 7/4 \rceil \cdot 1 + \lceil 7/6 \rceil \cdot 2 = 9
  4. R3(3)=3+⌈9/4⌉⋅1+⌈9/6⌉⋅2=10R_3^{(3)} = 3 + \lceil 9/4 \rceil \cdot 1 + \lceil 9/6 \rceil \cdot 2 = 10
  5. R3(4)=3+⌈10/4⌉⋅1+⌈10/6⌉⋅2=10R_3^{(4)} = 3 + \lceil 10/4 \rceil \cdot 1 + \lceil 10/6 \rceil \cdot 2 = 10, unchanged

So R3=10≤D3=10R_3 = 10 \le D_3 = 10. The same method gives R1=1R_1 = 1 and R2=3R_2 = 3, so the set is schedulable.

Rate-monotonic schedule of three periodic tasks 0123456789101112 Time τ₁ τ₂ τ₃ R₃ = 10 = D₃
Rate-monotonic schedule of three periodic tasks: τ1\tau_1 (C=1C=1, T=4T=4, highest priority), τ2\tau_2 (C=2C=2, T=6T=6) and τ3\tau_3 (C=3C=3, T=10T=10, lowest priority). The first job of τ3\tau_3 finishes exactly at its deadline, so R3=10=D3R_3 = 10 = D_3, and the processor is never idle from 0 to 12.

For EDF with deadlines shorter than periods, the processor demand criterion plays the same role. For periodic tasks that all start at time 0 with Di≤TiD_i \le T_i, EDF meets all deadlines if and only if, for every L>0L > 0 [5],

g(0,L)=∑i=1n⌊L+Ti−DiTi⌋Ci≤Lg(0, L) = \sum_{i=1}^{n} \left\lfloor \frac{L + T_i - D_i}{T_i} \right\rfloor C_i \le L

Here g(0,L)g(0, L) is the processor demand, the total computation of the jobs that arrive and must finish within [0,L][0, L]. The check is needed only at absolute deadlines below a computable limit, and like response time analysis it takes pseudo-polynomial time [5].

Sharing resources and priority inversion

Tasks often share data or devices. To keep shared data consistent, they use mutual exclusion: only one task at a time may run a critical section, the code that uses the resource [2]. A semaphore or a mutex (a lock that only one task can hold at a time) enforces this.

A task waiting for a lock held by a lower-priority task is blocked [2]. Some blocking cannot be avoided, but real-time analysis needs it to be bounded.

How priority inversion happens

Priority inversion is a high-priority task being blocked by a lower-priority task for an unbounded time [6]. Buttazzo's example uses tasks τ1\tau_1 (high priority, H in the figure), τ2\tau_2 (medium, M), and τ3\tau_3 (low, L), where τ1\tau_1 and τ3\tau_3 share data protected by a semaphore [^10]:

  1. τ3\tau_3 locks the semaphore and enters its critical section.
  2. τ1\tau_1 arrives, preempts τ3\tau_3, tries to lock the semaphore, and blocks.
  3. τ2\tau_2, which does not use the data, arrives and preempts τ3\tau_3.
  4. τ1\tau_1 must now wait for all of τ2\tau_2 as well as the rest of τ3\tau_3's critical section.
Priority inversion with and without priority inheritance No protocol H (high) M (medium) L (low) H (high) M (medium) L (low) blocked priority inversion (unbounded) critical section Priority inheritance blocked bounded blocking M waits L inherits H's priority t0 t1 t2 t3 t4 t5 t6
In the top timeline, the medium-priority task MM (τ2\tau_2) preempts the low-priority task LL (τ3\tau_3) while LL holds a lock that the high-priority task HH (τ1\tau_1) needs, so HH's wait has no fixed limit. With priority inheritance (bottom), LL runs its critical section at HH's priority, so MM cannot preempt it and HH waits only until LL releases the lock.

Disabling preemption inside critical sections solves the problem, but it only suits very short critical sections [6]. Otherwise it delays high-priority tasks that share nothing.

The Mars Pathfinder resets

Mars Pathfinder landed on 4 July 1997. A few days later, after it began gathering weather data, the spacecraft started suffering total system resets, each losing data [7]. It ran the VxWorks real-time operating system, which schedules tasks by priority with preemption [7].

The cause was priority inversion. A high-priority bus management task and a low-priority weather data task shared an "information bus" guarded by a mutex, and on rare occasions a long-running medium-priority communications task preempted the weather task while it held the mutex and the bus task waited [7]. A watchdog timer then noticed that the bus task had not run for some time and reset the whole system [7].

The fix was a single setting. A VxWorks mutex takes a parameter at creation that turns priority inheritance (explained below) on or off, and this mutex had been created with it off [7]. JPL engineers uploaded a short C program that turned it on, and the resets stopped [7].

Resource access protocols

Sha, Rajkumar, and Lehoczky published the priority inheritance protocol (PIP) in 1990 [7]. Under PIP, when a task blocks on a resource, the task holding it inherits the blocked task's priority until it releases the resource [6]. Medium-priority tasks can then no longer preempt the holder.

Under PIP, a task τi\tau_i can be blocked for at most the duration of min⁡(li,si)\min(l_i, s_i) critical sections, where lil_i is the number of lower-priority tasks that can block it and sis_i the number of distinct semaphores that can block it [2].

PIP has two weaknesses. It does not prevent deadlock, and a task can be blocked several times in a chain [2].

The priority ceiling protocol (PCP), by the same authors, fixes both. It gives each semaphore a ceiling equal to the highest priority of any task that may lock it. A task may enter a critical section only if its priority is higher than the ceilings of all semaphores locked by other tasks, which prevents deadlock and limits blocking to one critical section [2].

Baker's stack resource policy (SRP), from 1991, extends the ceiling idea to dynamic priorities such as EDF [2]. Like PCP, it allows at most one blocking and prevents deadlock.

Two simpler protocols are also used [^2]:

  • The non-preemptive protocol (NPP) disables preemption inside critical sections.
  • The highest locker priority protocol (HLP) raises a task to the semaphore's ceiling as soon as it locks it.
Protocol Priorities Blocked at most Prevents deadlock
NPP Any 1 critical section Yes
HLP Fixed 1 critical section Yes
PIP Fixed min⁡(li,si)\min(l_i, s_i) critical sections No
PCP Fixed 1 critical section Yes
SRP Any 1 critical section Yes

With a protocol in place, each task has a maximum blocking time BiB_i, which is added to the response time equation [^2]:

Ri=Ci+Bi+∑j<i⌈RiTj⌉CjR_i = C_i + B_i + \sum_{j<i} \left\lceil \frac{R_i}{T_j} \right\rceil C_j

According to Buttazzo, tests that are necessary and sufficient without blocking become only sufficient once blocking factors are included [2].

Worst-case execution time

Every test above needs each task's worst-case execution time (WCET), the longest time its code can take on the target hardware [8]. The tests are only as safe as these numbers.

Why it is hard

  • In general, no method can bound the execution time of every program, since that would solve the halting problem. Real-time code avoids this by banning or bounding recursion and bounding loop counts [8].
  • The input that causes the worst case is usually unknown and hard to find [8].
  • Caches and pipelines make an instruction's time depend on what ran before, and that time can vary by several orders of magnitude [8].
  • Many powerful processors have timing anomalies, where a local worst case such as a cache miss can lead to a shorter total time. Analysis therefore cannot just take the worst case at each step [8].
Execution time distribution and WCET boundsBCETMin observedMax observedWCET (exact)WCET upper bound(static analysis)Measurementcan miss thisOverestimationExecution timeNumber of runsAll possible execution timesMeasured execution times
Measured run times show only part of a task's range of execution times. The longest observed run can fall short of the exact worst-case execution time (WCET), while a static-analysis upper bound lies above the exact WCET.

Two families of methods

Measurement-based Static
How it works Runs the task on the hardware with test inputs and records the times Analyzes the code and a model of the hardware without running the task
Result Longest observed time Upper bound on all execution times
Main limit Generally underestimates the WCET, so not safe for hard real-time systems Only as accurate as the hardware model

Newer measurement-based methods measure parts of the task and combine the results, but they still rarely guarantee a bound [8]. The longest observed time on its own is not safe for hard real-time systems [8].

Static methods use abstract interpretation to predict cache and pipeline behavior [8]. Integer linear programming then finds the largest total execution time that the program's control flow allows, which gives an upper bound [8]. Integer linear programming is an optimization method that chooses whole-number values to make a quantity as large or small as possible under a set of linear equations and inequalities.

Static bounds usually overestimate the exact WCET, because the analysis loses some information [8].

The overestimation can be small. In the ARTIST2 WCET Tool Challenge, reported by Tan in 2007, one static tool overestimated by only 7 to 8% on average [8].

Preemption adds a cost that a WCET measured alone misses. A preempting task can push another task's data out of the cache, and the preempted task must reload it when it resumes [9]. A study by Bui and colleagues found that on a PowerPC MPC7410 processor, this cache interference raised a task's WCET by as much as 33% [9].

Operating system support

A real-time operating system (RTOS) must support timing guarantees. For example, it should activate periodic tasks automatically at the start of each period and detect jobs that overrun their computation time or miss their deadlines [6]. Its own interrupt and timer handling also add delays that the analysis must include.

Interrupts

In most operating systems, an interrupt from a device runs its interrupt handler at once, preempting any application task [6]. In a control system this can be wrong, because a control task may be more urgent than the device. The number of interrupts a task may suffer is hard to bound in advance, so the delay they add is unpredictable [6].

Buttazzo describes two approaches [^2]:

  1. Treat the interrupt's work as a sporadic task, scheduled like the others, so its cost is included in the schedulability guarantee.
  2. Run the handler at once at the highest priority. This minimizes interrupt latency, the delay before the interrupt is served, but its cost must be added to the analysis of every task.

Timer overhead

Most RTOSs keep time with a periodic timer interrupt, called a tick, with period QQ. If handling each tick takes time σ\sigma, the timer uses a fraction σ/Q\sigma/Q of the processor, and the utilization left for tasks is [^2]:

Unet=Ulub−σQU_{\text{net}} = U_{\text{lub}} - \frac{\sigma}{Q}

Here UlubU_{\text{lub}} is the scheduler's utilization bound, such as 1 for EDF. With σ=100\sigma = 100 µs and Ulub=1U_{\text{lub}} = 1, a 10 ms tick leaves 0.99, a 1 ms tick leaves 0.9, and a 200 µs tick leaves only 0.5. Finer timing resolution therefore costs processor capacity.

Handling overload

A system is overloaded when, under worst-case assumptions, no schedule can meet all deadlines, so some task will miss one [2].

Theoretical limits

Locke showed that EDF performs poorly in overload [2]. A single new job can make the jobs already in the system miss their deadlines one after another, a cascade called the domino effect [2].

There is also a limit on what any online scheduler, which decides without knowing future arrivals, can achieve. Baruah and colleagues showed that when the load can exceed 2 and each job's value is proportional to its computation time, no online scheduler can guarantee more than one quarter of the value that a scheduler knowing the future would get [2]. This is a theoretical, worst-case bound.

Practical strategies

Practical systems use several strategies [^2]:

  • Admission control accepts a new task only if a test shows that all deadlines will still be met.
  • Resource reservation gives each task a fixed share of the processor and stops it from using more, so an overrun only affects that task. Under EDF, the constant bandwidth server by Abeni and Buttazzo does this.
  • Job skipping drops some jobs of tasks that can tolerate it, which frees time for others.
  • Period adaptation lowers the load by lengthening task periods. In elastic scheduling, task periods stretch like springs within allowed ranges.

History

Real-time computing began with computers that controlled processes as they happened. MIT's Whirlwind project began in 1944 as an Office of Naval Research effort to build a universal flight trainer, and its focus later changed to building a high-speed digital computer [10]. Whirlwind was among the first machines to use fast calculation for real-time problems such as aircraft simulation and air traffic control [11].

Whirlwind pioneered computers in real-time control, in contrast to the business and scientific machines of the time, which ran batches of punched-card jobs [11]. It served as the prototype for the US Air Force's Semi-Automatic Ground Environment (SAGE) air defense system [11].

Year Event
1949 Whirlwind is first brought online at MIT [11]
1973 Liu and Layland publish utilization bounds for RM and EDF [4]
1974 Horn and Dertouzos publish optimality results for EDF [2]
1982 Leung and Whitehead show that deadline-monotonic priorities are optimal when deadlines may be shorter than periods [2]
1988 Stankovic publishes his paper on misconceptions about real-time computing [1]
1990 Sha, Rajkumar, and Lehoczky publish the priority inheritance protocols [7]
1991 Baker publishes the stack resource policy [2]
1997 Priority inversion causes resets on Mars Pathfinder, fixed by turning on priority inheritance [7]

Open problems

Several problems remain open:

  • Trusting hardware models. Static WCET tools rely on models of the processor, but vendors generally do not disclose enough detail to check them, and testing can find model errors but not prove their absence [8].
  • Loop bounds and indirect calls. Automatic analyses of these do not work in all cases, so users must sometimes supply annotations, notes that give the analysis extra information about the code [8].
  • Preemption costs. A task's WCET depends on how often it is preempted, and the number of preemptions depends on the WCETs, a circular dependency that is hard to solve [9].
  • Preemptive versus non-preemptive scheduling. Which is better has been debated for a long time, and under fixed priorities neither dominates when both predictability and efficiency count. Limited-preemption models have been proposed as a middle path [9].

References

  1. Misconceptions about real-time computing: a serious problem for next-generation systems, J. A. Stankovic, IEEE Computer, 1988.
  2. Hard Real-Time Computing Systems: Predictable Scheduling Algorithms and Applications, 4th ed., G. Buttazzo, Springer, 2024.
  3. Firm Real-Time Processing in an Integrated Real-Time System, T. Kaldewey, C. Lin, and S. Brandt, RTAS Work-in-Progress, 2006.
  4. Scheduling Algorithms for Multiprogramming in a Hard-Real-Time Environment, C. L. Liu and J. W. Layland, Journal of the ACM, 1973.
  5. Rate Monotonic vs. EDF: Judgment Day, G. C. Buttazzo, Real-Time Systems, 2005.
  6. Why Real-Time Computing?, G. Buttazzo, ANIPLA, 2006.
  7. What really happened on Mars?, M. Jones (reporting a keynote by D. Wilner of Wind River Systems), 1997.
  8. The Worst-Case Execution-Time Problem: Overview of Methods and Survey of Tools, R. Wilhelm et al., ACM Transactions on Embedded Computing Systems, 2008.
  9. Limited Preemptive Scheduling for Real-Time Systems. A Survey, G. C. Buttazzo, M. Bertogna, and G. Yao, IEEE Transactions on Industrial Informatics, 2013.
  10. Milestones: Whirlwind Computer, 1944-59, IEEE / Engineering and Technology History Wiki.
  11. The Whirlwind Computer at CHM, G. Fedorkow, Computer History Museum, 2018.

Figure