Computer Software and Operating Systems (9hrs) · Computer Fundamentals & Emerging Technologies

Real-time

1. Definition

A real-time operating system (RTOS) is one in which the correctness of a result depends not only on the computed value but also on the time at which it is produced. Every task must complete within its deadline; a late answer is a wrong answer. The OS must therefore be deterministic and predictable — not merely fast, but reliably bounded in the worst case.

Example: an airbag controller has roughly 20-30 ms to sense a crash and fire the bag. A response of 50 ms is technically "faster than a human notices" but completely wrong for the passenger.

2. Types of Real-Time Systems

Type Deadline miss means Examples
Hard real-time Catastrophic failure — loss of life, mission or money Airbag, ABS brakes, pacemaker, flight control, nuclear reactor control, missile guidance
Firm real-time Result has no value after the deadline, but no disaster Robotics picking arm, automated trading quotes, industrial batching
Soft real-time Quality degrades gracefully; occasional miss is tolerable Video/audio streaming, VoIP, online gaming, virtual meetings

3. Requirements and Characteristics of an RTOS

  • Deterministic scheduling — the worst-case response time of every task is known and provable in advance.
  • Priority-based pre-emptive scheduling — a high-priority task pre-empts a lower one immediately.
  • Bounded interrupt latency and dispatch latency — small, predictable worst-case delays.
  • Small, efficient kernel — a footprint of kilobytes and fast context switches.
  • Priority inheritance / ceiling protocols — prevent priority inversion (a low-priority task holding a lock needed by a high-priority task).
  • No or controlled virtual memory — page faults are unpredictable, so pages are locked in RAM or paging is disabled altogether.
  • Predictable device handling — interrupt-driven I/O with bounded service times, often direct control of hardware.
  • Reliability and graceful degradation — watchdog timers, fail-safe states, redundancy, built-in self-tests.
  • Task synchronisation primitives — semaphores, mutexes, message queues, event flags, all with bounded latencies.
  • Compact, ROM-able code — runs on microcontrollers with limited RAM/flash.

4. Scheduling in Real-Time Systems

Algorithm Policy Property
Rate Monotonic (RM) Fixed priority; shorter period gets higher priority Optimal among fixed-priority algorithms; schedulable if U≤n×(21/n−1)U ≤ n × (2^{1/n} - 1) (≈ 0.693 for large n)
Earliest Deadline First (EDF) Dynamic priority; task with nearest deadline runs first Optimal for uniprocessor pre-emptive systems; schedulable if U≤1U ≤ 1
Least Laxity First Run the task with least slack (deadline − remaining work) Good but heavy overhead

Utilisation of a task set: U=Σ(executiontime/period)U = Σ (execution time / period).

Worked example: three periodic tasks — T1 (C = 1 ms, P = 4 ms), T2 (C = 2 ms, P = 6 ms), T3 (C = 2 ms, P = 12 ms).

U=1/4+2/6+2/12=0.25+0.333+0.167=0.75U = 1/4 + 2/6 + 2/12 = 0.25 + 0.333 + 0.167 = 0.75

EDF can schedule it (U≤1U ≤ 1). For RM the bound for n = 3 is 3×(21/3−1)≈0.783 × (2^{1/3} - 1) ≈ 0.78, so 0.75 also fits RM — but note that RM is conservative: values above the bound may still be schedulable.

5. RTOS vs General-Purpose OS

Basis RTOS General-purpose OS (Windows/Linux desktop)
Primary goal Meet deadlines, predictability Throughput, fairness, convenience
Scheduling Priority-based, deterministic, often RM/EDF Time-sliced round robin / fair-share (CFS)
Worst-case latency Bounded and documented Not guaranteed — can be tens of ms
Kernel size Tiny (KB) Large (MB), hundreds of drivers
Memory No paging for time-critical code; static allocation Virtual memory with demand paging
Priority inversion Handled by protocol (inheritance/ceiling) Usually ignored
User interface Minimal or none Rich GUI, multitasking for humans
Examples VxWorks, QNX Neutrino, FreeRTOS, RTEMS, µC/OS-II, PREEMPT-RT Linux Windows 11, Ubuntu desktop, macOS

6. Applications

Automotive (engine control, ABS, airbag, ADAS), medical devices (pacemakers, ventilators, insulin pumps), aerospace and defence (flight control, UAVs, missile systems), industrial automation (PLCs, SCADA, CNC, robotic arms), telecommunications (base stations, switches, routers), consumer electronics (set-top boxes, cameras, printers), railways and traffic signalling — plus soft real-time uses such as streaming media and online gaming.

7. Exam Points

  • Define a real-time operating system and differentiate hard, firm and soft real-time with examples — 5 marks, almost certain.
  • List the characteristics/requirements of an RTOS — 5 marks, frequent.
  • Explain Rate Monotonic and EDF scheduling with the utilisation conditions — 5-7 marks.
  • Numerical: compute utilisation of a periodic task set and test RM/EDF schedulability — 5 marks.
  • Differentiate an RTOS from a general-purpose OS — 5 marks.
  • What is priority inversion and how is it solved? — 3 marks.
  • Why is paging avoided in hard real-time systems? — 3 marks.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Computer Fundamentals & Emerging Technologies modules