This was written entirely with AI.

These notes cover Lecture 6a. Lecture 3’s schedulers aim at good average performance. This lecture is about systems where a late answer is a wrong answer: real-time systems. It explains what real-time means, how to describe a real-time process with three numbers, and two schedulers: rate monotonic (RM) and earliest deadline first (EDF). The past papers barely mention this lecture, so the questions below are the lecture’s quiz questions and one past-paper statement. The skill to practise is drawing an RM or an EDF schedule and checking each deadline.

How to use this page. Each section teaches one idea in a few lines, then gives the questions on it. Try each question before you open its answer. The “Exam patterns” table at the end is for the night before.

Quick reference

Fact Value
Real-time Correct = right result and on time (before its deadline). Real-time means predictable in the worst case, not fast.
Desktop OSes Windows and Linux for PCs are time-sharing systems, not real-time
Cyber-physical loop Sense → decide → act, within a reasonable time
One process ⟨R,C,D⟩\langle R, C, D\rangle: release, CPU need, relative deadline. Absolute deadline = R+DR + D.
Periodic process ⟨T,C,D⟩\langle T, C, D\rangle: period, CPU need, relative deadline. Instance kk is released at kTkT and due at kT+DkT + D.
Why FCFS, SJF, RR fail They ignore deadlines
RM Fixed priority. Shorter period = higher priority. Simple, predictable. Can miss deadlines.
EDF Dynamic priority. Earliest absolute deadline first. More powerful, harder to build, unpredictable under overload.

1. What a Real-Time System Is

A cyber-physical system is a physical system that a computer monitors and controls: cars (airbag, parking assist), aircraft, factory robots, pacemakers. They repeat three steps: sense (read the sensors), decide (run a control law), act (command the motors or valves), all within a reasonable time. What is reasonable depends on the job: milliseconds for car collision avoidance, up to a second for a pacemaker.

Real-time does not mean fast. Real-time means predictable, even in the worst case. The lecture’s picture: a man drowned in a river whose average depth was 20 cm. One deep place was enough. In the same way, a real-time system must meet its deadline every time, not on average.

A real-time system is correct only if the logical result is right and the result comes before its deadline. A late answer is a wrong answer. A real-time OS (RTOS), such as FreeRTOS or MicriumOS, is judged by timeliness: how predictably it meets deadlines. The worst case matters more than the average. Windows and Linux on PCs are time-sharing systems that aim for good average performance, so they are not real-time.

In real-time systems, the average response time of user programs should be minimized.

False. Real-time systems require guaranteed satisfaction of deadlines, whatever the average response time.

“Real-time” means “fast”.

False. Real-time means predictable, even in the worst case. A fast system that sometimes misses a deadline is not real-time.

When is the result of a real-time system correct?

When the logical result is right and it comes before its deadline. A late answer is a wrong answer.

Why are Windows and Linux on personal computers not real-time operating systems?

They are time-sharing systems. They aim for good average performance, and they do not guarantee deadlines.

What three steps do cyber-physical systems repeat?

Sense (collect data from sensors), decide (run a control law) and act (send commands to the actuators within a reasonable time).

AY15/16 S2 Q1a(ii): Real-time operating systems usually use preemptive job scheduling.

True. A newly released urgent job must take the CPU at once, or it can miss its deadline. RM and EDF below are both preemptive.


2. Describing a Real-Time Process

One process: ⟨R, C, D⟩. RR is the release time (when it becomes ready). CC is the CPU time it needs. DD is the relative deadline: how long after release it must finish. It needs CC units in the interval [R,R+D)[R, R + D), and its absolute deadline is R+DR + D. Each process here has one CPU burst of length CC.

Three real-time processes on a time line (Lecture 6a, slide 1.9)

Example: P1⟨0, 5, 10⟩ is released at 0, needs 5 units and must finish by 10. P3⟨20, 10, 30⟩ is released at 20 and must finish by 50.

Periodic process: ⟨T, C, D⟩. Real-time work repeats (sense, decide, act). A periodic process releases a new instance every period TT: at 0,T,2T,…0, T, 2T, \ldots. Instance kk is released at kTkT and must finish by kT+DkT + D. Each instance is itself a real-time process ⟨R, C, D⟩. Example: P⟨10, 5, 7⟩ is released at 0, 10, 20, 30, … and each instance is due at 7, 17, 27, 37, …

The periodic process P⟨10, 5, 7⟩ (Lecture 6a, slide 1.11)

Watch the order of the numbers. A single process is ⟨R, C, D⟩. A periodic process is ⟨T, C, D⟩. The first number changes meaning.

What do R, C and D mean in a real-time process ⟨R, C, D⟩, and what is its absolute deadline?

R is the release time (when the process becomes ready). C is the execution requirement (the CPU time needed). D is the relative deadline (the time allowed after the release). The absolute deadline is R + D.

What does ⟨T, C, D⟩ mean for a periodic process? When are its instances released and due?

T is the period, the time between two releases. Instance k is released at kT and must finish by kT + D. Example: P⟨10, 5, 7⟩ is released at 0, 10, 20, … and must finish by 7, 17, 27, ….


3. Why Normal Schedulers Fail

FCFS, SJF and RR do not look at deadlines. Run them on P1⟨0,20,30⟩, P2⟨0,5,10⟩, P3⟨5,10,35⟩, P4⟨20,10,30⟩, P5⟨25,5,10⟩: all three miss some deadline. Under FCFS, P1 (20 units) runs first, so P2 starts at 20 although its deadline is 10. The algorithms give urgent work no priority.

FCFS, SJF and RR miss deadlines (Lecture 6a, slide 1.13)
Why do FCFS, SJF and RR miss deadlines in real-time systems?

They do not look at deadlines, so they do not give priority to urgent work. For example, under FCFS a long process that arrived first can delay a process whose deadline is near.


4. Real-Time Scheduling

The problem. Given periodic real-time processes, find a preemptive scheduler for one CPU that meets every deadline of every instance. Running example: P1⟨10, 6, 10⟩, P2⟨19, 4, 19⟩, P3⟨20, 2, 20⟩.

Rate monotonic (RM) is a fixed-priority scheduler: each process has one priority for all its instances. The shorter the period, the higher the priority (ties arbitrary). Here T1=10<T2=19<T3=20T_1 = 10 < T_2 = 19 < T_3 = 20, so P1 > P2 > P3.

To build an RM schedule: (1) give each process a fixed priority by period; (2) mark the release time and deadline of every instance; (3) at every moment run the released, unfinished instance of the highest-priority process (a higher-priority release preempts); (4) check every deadline.

The RM schedule for the running example (Lecture 6a, slide 1.16)

RM can miss a deadline, because it looks only at periods. Change P3 to ⟨20, 2, 14⟩. P3 still has the lowest priority (its period is still 20), so P1 and P2 run first and P3 cannot finish by 14.

RM misses P3’s deadline at 14 (Lecture 6a, slide 1.17)

Earliest deadline first (EDF) is a dynamic-priority scheduler: the instance with the earliest absolute deadline has the highest priority. The priority belongs to each instance, not to the process. Use the absolute deadline (R + D), not the parameter D. An old instance with a large DD can have an earlier absolute deadline than a new one with a small DD.

To build an EDF schedule: (1) mark the release time and absolute deadline of every instance; (2) at every release and every finish, look at all released, unfinished instances; (3) run the one with the earliest absolute deadline (a new release with an earlier deadline preempts); (4) check every deadline.

EDF meets every deadline (Lecture 6a, slide 1.18)

With P3⟨20, 2, 14⟩ and P2⟨19, 4, 17⟩, EDF meets every deadline. At time 6, P3’s deadline (14) is earlier than P2’s (17), so P3 runs first. If any scheduler can meet all deadlines of a set on one CPU, EDF can.

RM EDF
Priority Fixed: one per process Dynamic: one per instance
Rule Shorter period first Earlier absolute deadline first
Implementation Simpler: a queue for each process Harder: sort by deadline while running
Heavy load Predictable for high-priority processes: they still meet deadlines Unpredictable: any process can miss
Power Can miss deadlines that EDF meets More powerful
What is the rule of rate monotonic (RM) scheduling?

The shorter the period T, the higher the priority. The priority is fixed: all instances of a process have the same priority.

What is the rule of earliest deadline first (EDF) scheduling?

The instance with the earliest absolute deadline (R + D) gets the highest priority. The priority is dynamic: it belongs to each instance, not to the process.

In EDF, do you compare the parameter D of the processes?

No. Compare the absolute deadlines (R + D) of the released, unfinished instances. An old instance with a large D can have an earlier absolute deadline than a new instance with a small D.

RM never misses a deadline that EDF could meet.

False. EDF is more powerful. If any scheduler can meet all the deadlines of a process set on one CPU, EDF can. RM looks only at periods, so it can miss a deadline that EDF meets.

Compare RM and EDF in implementation and in heavy load.

RM is simpler (a separate queue for each process) and predictable under heavy load, because high-priority processes still meet their deadlines. EDF is harder (the OS must sort by deadline while it runs) and can be unpredictable under heavy load, because any process can miss its deadline.

General method: draw an RM or an EDF schedule
  1. List every instance up to the end of the time line: release time kTkT and absolute deadline kT+DkT + D.
  2. RM: rank the processes by period (shortest first). EDF: rank the instances by absolute deadline. Do this again at every release and every finish.
  3. Run the top-ranked released instance. Draw it until the next release or finish. Preempt if a higher-ranked instance is released.
  4. Check each instance: does it finish by its absolute deadline? Write “miss” where it does not.
  5. Compare: if RM misses and EDF meets, say that EDF is more powerful. If an overload makes EDF miss for many processes, say that EDF is unpredictable.

Exam patterns

This lecture has not appeared in the past papers I checked. The quiz questions above are the best guide.

Question type How to attack it Trap
“Real-time means fast” Real-time means predictable and on time Saying it means fast or low average response
⟨R, C, D⟩ and ⟨T, C, D⟩ Absolute deadline = release + D. Instance kk released at kTkT. Mixing the meaning of the first number
Draw RM Priority by period, preempt on a higher-priority release Using deadlines (that is EDF)
Draw EDF Priority by absolute deadline at each event Comparing the parameter D
Compare RM and EDF Fixed vs dynamic, simple vs sorted, predictable vs unpredictable under load Saying RM never misses

Common Traps