BCS401 Operating System Semester IV · AY 2025-26 onward
Unit 1 · Introduction & OS Structure

Lecture 5: Real‑time systems: hard vs soft

Learning outcomes

  • Explain the difference between hard and soft real‑time systems and give examples.

Prerequisites

-- Basics from Lectures 1–4: OS types (batch / interactive / time-sharing) and the concept of a process/task -- Basic understanding of deadlines (time limits for completing a task) -- Basic understanding of preemption (a higher-priority task can interrupt a currently running task)

Lecture Notes

Main content

Unit 1 — Introduction & OS Structure

Lecture 5: Real-Time Systems — Hard vs Soft

Learning Outcome

Explain what a real-time system is and clearly distinguish between hard real-time and soft real-time systems.


1) What is a Real-Time System?

A real-time system is one in which correctness depends on both: (1) producing the correct result, and (2) producing that result within a specified time limit. The central requirement is predictability (deterministic timing), not merely speed.

Misconception Alert:

"Real-time" does not mean "the fastest possible system." It means the system behaves deterministically—its response time can be predicted.


2) Hard Real-Time vs Soft Real-Time (Core Difference)

Aspect Hard Real-Time Soft Real-Time
Deadline rule Service must be completed by the deadline; missing it is treated as failure. No absolute guarantee of exact completion time; critical tasks are given priority.
Deadline miss Not acceptable (may cause failure or unsafe behavior). Acceptable occasionally (performance/quality degrades, but the system continues).
Typical examples Airbag control, pacemaker, flight/missile control, industrial safety shutdown. Video streaming, online gaming, VoIP, multimedia playback.
Exam line:

Hard real-time: "deadline miss = failure." Soft real-time: "deadline miss = reduced quality."


3) Key Characteristics of Real-Time Systems

3.1 Determinism (Predictability)

The ability to predict when a task will execute and how long it will take.

3.2 Responsiveness (Low Latency)

Real-time performance depends strongly on how quickly the OS responds to events.

  • Interrupt latency: time from interrupt arrival to the start of interrupt service (ISR starts).
  • Dispatch latency: time required to switch the CPU to the higher-priority real-time task.

3.3 Preemption

A higher-priority real-time task should be able to preempt a lower-priority task with minimal delay.


4) Latency Diagram (What You Should Visualize)

Latency in real-time response (conceptual) t0 Interrupt arrives t1 ISR starts t2 RT task runs Interrupt latency Dispatch latency (switch to RT task) Hard real-time systems require tightly bounded latencies; soft real-time systems aim to keep them low.
Fig 5.1: Two important latencies affecting real-time responsiveness.

5) Design Expectations (Hard vs Soft)

Hard Real-Time

  • Deadlines for critical tasks must always be met.
  • Timing must be predictable; worst-case timing is crucial.
  • Interrupt and dispatch latencies must be very low and bounded.

Soft Real-Time

  • Critical tasks are prioritized over noncritical tasks.
  • Occasional deadline misses may occur; output quality may degrade.
  • The aim is good responsiveness, though strict guarantees may not exist.

6) Quick Self-Check Questions

  1. Define hard real-time and soft real-time in one line each.
  2. Why does "real-time" refer to determinism rather than just speed?
  3. What is the consequence of missing a deadline in a hard real-time system?
  4. Differentiate interrupt latency and dispatch latency.
  5. Give two examples each of hard and soft real-time systems.

Worked Example

Worked Example: Airbag Controller vs Video Streaming

A) Hard Real-Time: Airbag Deployment

  • Event: collision detected by sensors
  • Deadline: airbag must deploy within a strict time bound
  • If late: considered a failure (unsafe outcome)

Conclusion: This is a hard real-time requirement.

B) Soft Real-Time: Video Streaming

  • Event: next video frame/audio chunk is needed
  • Deadline: should arrive on time for smooth playback
  • If late: lag/buffering occurs (quality drops), but the system continues

Conclusion: This is a soft real-time requirement.

One-Page Summary

One-Page Summary — Real-Time Systems (Hard vs Soft)

  • Real-time concept: correctness depends on producing the correct result within a required time bound (predictability is essential).
  • Soft real-time: exact scheduling time is not guaranteed; critical tasks are prioritized over noncritical tasks.
  • Hard real-time: a task must be serviced by its deadline; service after the deadline is effectively failure.
  • Determinism: the ability to predict when tasks run and how long they take.
  • Responsiveness: mainly affected by interrupt latency and dispatch latency.
  • Examples:
    • Hard: airbags, pacemakers, safety control systems
    • Soft: video streaming, VoIP, online gaming