Chapter 10: Real-Time Operating Systems (RTOS)

Syllabus 9.6 — Real-Time Aspects: Determinism, Scheduling, Latency & Embedded Systems

1. What is a Real-Time System?

A Real-Time System is a computing system where correctness depends on both the logical result and the time at which the result is produced.

OutcomeResult
Correct Answer + Delivered on Time✅ Success
Correct Answer + Delivered Late❌ Failure

Airbag Example: Airbag must deploy within 20 ms after crash detection.

Deployment TimeOutcome
15 ms✅ Success
18 ms✅ Success
25 ms❌ Failure — too late

An RTOS is an operating system specifically designed to process events and respond within guaranteed timing constraints.

General OS vs RTOS

FeatureGeneral OSRTOS
Primary goalSpeed and throughputPredictability
Performance measureAverage performanceGuaranteed response time
DeadlinesMay be missedMust be met
Kernel sizeFeature-rich, largeSmall, minimal
Use caseGeneral computingMission-critical applications

2. Characteristics of RTOS

CharacteristicDefinitionExample
Determinism Operations complete within a known and predictable time every time Interrupt handling always takes exactly 5 ms — not sometimes 2 ms, sometimes 50 ms
Fast Response Time System responds immediately to events Medical monitor, airbag, industrial robot
Reliability System failures are unacceptable Nuclear plant control, aircraft navigation
High Availability System operates continuously with minimal downtime Power grid, air traffic control
Minimal Latency Delay between event and response must be extremely small Sensor activation to actuator response

📌 Determinism is the heart of RTOS. Memory Trick — DRILL: D → Deterministic   R → Reliable   I → Interrupt responsive   L → Low latency   L → Low jitter


3. Key RTOS Concepts

Deadline

A deadline is the maximum allowable time to complete a task.

ExampleDeadline
Emergency braking system10 ms
Airbag deployment20 ms
Pacemaker pulseSpecific cardiac interval

Latency

Latency is the delay between an event occurring and the system beginning its response.

Latency TypeDefinition
Interrupt LatencyTime from interrupt occurrence to start of Interrupt Service Routine (ISR) execution
Scheduling LatencyTime between a task becoming ready and the scheduler assigning the CPU
Dispatch LatencyTime required to switch the CPU from one process to another (context switch time)

Jitter

Jitter is the variation in response time. RTOS aims to minimize jitter.

Good RTOSPoor RTOS
10 ms, 10 ms, 11 ms, 10 ms — very consistent10 ms, 30 ms, 9 ms, 50 ms — unpredictable
Low jitter ✅High jitter ❌

4. Types of Real-Time Systems

A. Hard Real-Time System

Missing even one deadline is catastrophic and unacceptable.

AspectDetail
Deadline toleranceZero — no missed deadlines
Consequence of missingCatastrophic failure (injury, death, disaster)
DeterminismHighest
ExamplesAircraft flight control, airbag, nuclear reactor, pacemaker

B. Soft Real-Time System

Missing a deadline reduces quality or performance but does not cause system failure.

AspectDetail
Deadline toleranceSome misses acceptable
Consequence of missingReduced quality (e.g., video frames dropped)
ExamplesVideo streaming, online gaming, audio playback, video conferencing

C. Firm Real-Time System

A result produced after its deadline has no value, but occasional missed deadlines are tolerated.

AspectDetail
Deadline toleranceOccasional misses tolerated
Late result valueZero — useless if late
ExamplesStock market data feed, radar tracking, industrial monitoring

Comparison Table

FeatureHard RTFirm RTSoft RT
Missed deadlinesNever allowedOccasional — but result uselessAcceptable with degraded quality
ConsequenceCatastrophic failureReduced usefulnessReduced performance
StrictnessStrictestModerateLeast strict
ExampleAirbag, pacemakerRadar, stock tickerNetflix, online gaming

📌 Memory Trick — HFS (Hardest → Softest): H → Hard  |  F → Firm  |  S → Soft


5. Embedded Systems

RTOS is widely used in embedded systems — computers designed to perform a dedicated function within a larger device.

CategoryExamples
Home AppliancesMicrowave oven, washing machine, printer
WearablesSmartwatch, fitness tracker
AutomotiveCar ECU (Engine Control Unit), ABS braking
MedicalPacemaker, insulin pump
CharacteristicDetail
SizeSmall form factor
PurposeSingle dedicated function
PowerLow power consumption
EfficiencyHighly optimized for its task

6. RTOS Scheduling

RTOS scheduling focuses on meeting deadlines, not just maximizing throughput.

A. Rate Monotonic Scheduling (RMS)

Principle: Tasks with shorter periods receive higher priority. Priority is fixed and never changes.

TaskPeriodPriority
T120 msHighest (shortest period)
T250 msMedium
T3100 msLowest (longest period)
CharacteristicDetail
Priority typeFixed (does not change at runtime)
Suitable forPeriodic tasks
AdvantagesSimple, predictable, widely used

B. Earliest Deadline First (EDF)

Principle: The task with the nearest (earliest) deadline always executes first. Priority is dynamic and changes continuously.

TaskDeadlineExecution Order
A20 ms1st
B40 ms2nd
C80 ms3rd
CharacteristicDetail
Priority typeDynamic (recalculated as deadlines change)
CPU utilizationHigher than RMS
AdvantagesMore flexible, better CPU utilization

RMS vs EDF

FeatureRMSEDF
PriorityFixed (based on period)Dynamic (based on deadline)
BasisTask periodTask deadline
ComplexitySimplerMore complex
CPU utilizationUp to ~69% theoretical maxUp to 100% theoretical max
Best forFixed periodic tasksMixed / dynamic workloads

📌 Memory Trick — RE: R → RMS (fixed, period-based)  |  E → EDF (dynamic, deadline-based)


7. Interrupt Handling in RTOS

Interrupts must be handled as quickly as possible to maintain real-time guarantees.

StepAction
1Interrupt occurs (sensor, timer, device)
2CPU saves current task state
3Interrupt Service Routine (ISR) executes
4Normal execution resumes

Goal: Keep interrupt latency as low and as consistent as possible.

ISR CharacteristicDetail
LengthShort — does minimal work, defers the rest
ExecutionFast — high priority execution
ExamplesKeyboard press, sensor activation, timer expiration

8. Applications of RTOS

DomainExamples
AerospaceAircraft navigation, flight control, satellite systems
AutomotiveABS braking, airbag, cruise control, Engine Control Unit (ECU)
MedicalPacemakers, MRI, ventilators, patient monitoring
Industrial AutomationRobots, CNC machines, factory automation
TelecommunicationsMobile base stations, network switches
DefenseMissile guidance, radar systems

9 & 10. Advantages and Disadvantages

Advantages of RTOSDisadvantages of RTOS
Predictable, deterministic behaviorComplex design and development
High reliability and availabilityHigher development cost
Fast response and low latencyLimited flexibility compared to GPOS
Supports mission-critical applicationsMay require specialized hardware
Minimal jitterSmaller ecosystem of tools and libraries

11. RTOS vs General Purpose Operating System (GPOS)

FeatureRTOSGeneral Purpose OS
Scheduling goalDeterministic — meet deadlinesBest effort — maximize throughput
FocusDeadline-orientedUser-oriented
LatencyVery low, consistentModerate, variable
Use caseMission-critical systemsGeneral computing (office, gaming)
KernelSmall, minimalFeature-rich, large
ExamplesFreeRTOS, VxWorks, QNXWindows, Linux, macOS

RTOSCommon Use
FreeRTOSEmbedded systems, IoT devices
VxWorksAerospace & defense (used in Mars rovers)
QNXAutomotive (used in car infotainment)
RTLinuxIndustrial control
ZephyrIoT devices
RTEMSNASA & space applications

Memory Tricks

MnemonicFull Form
Types of RT Systems — HFS H → Hard (strictest)   F → Firm   S → Soft (least strict)
Scheduling — RE R → RMS (fixed, period)   E → EDF (dynamic, deadline)
RTOS Features — DRILL D → Deterministic
R → Reliable
I → Interrupt responsive
L → Low latency
L → Low jitter

Frequently Asked Exam Questions

QuestionAnswer
What is an RTOS?An OS designed to produce correct results within guaranteed timing constraints
Most important characteristic of RTOS?Determinism — predictable timing behavior
Hard vs Soft Real-Time?Hard: no missed deadlines (catastrophic if missed). Soft: occasional misses reduce quality.
What is latency?Delay between an event and the system's response
What is jitter?Variation in response time
Difference between RMS and EDF?RMS: fixed priority by period. EDF: dynamic priority by nearest deadline.
What is an embedded system?A computer designed to perform a dedicated function within a larger device
Give three RTOS applications.Airbag system, pacemaker, aircraft flight control

Practice MCQs

  • 1. Which characteristic is most important in an RTOS?
    A. High storage capacity   B. Determinism   C. Large GUI   D. High-resolution graphics
    ✅ Answer: B — Determinism
  • 2. Missing a deadline is unacceptable in:
    A. Soft Real-Time System   B. Hard Real-Time System   C. Time-Sharing System   D. Batch System
    ✅ Answer: B — Hard Real-Time System
  • 3. Which scheduling algorithm gives higher priority to tasks with shorter periods?
    A. FCFS   B. EDF   C. RMS   D. Round Robin
    ✅ Answer: C — RMS (Rate Monotonic Scheduling)
  • 4. Which scheduling algorithm always selects the task with the closest deadline?
    A. Priority Scheduling   B. RMS   C. EDF   D. FCFS
    ✅ Answer: C — EDF (Earliest Deadline First)
  • 5. Which of the following is a common application of RTOS?
    A. Word processing   B. Air traffic control   C. Movie editing   D. Spreadsheet software
    ✅ Answer: B — Air traffic control