5.5.12Embedded Systems & Real-Time Software

Real-time constraints — hard and soft deadlines

2,029 words9 min readdifficulty · medium3 backlinks

WHAT is a real-time system?

The key quantity is the deadline: the latest time by which a task's response must be complete, measured from the task's release (arrival) time.


WHY classify deadlines? Hard vs Soft vs Firm

The cost of a missed deadline differs wildly by application. We classify by the utility of a result delivered after its deadline.

Figure — Real-time constraints — hard and soft deadlines

HOW do we guarantee a hard deadline?

You cannot "test until it feels fast." Hard real-time demands a provable bound. The recipe:

  1. Determine WCET CiC_i for every task (static analysis or measured worst case).
  2. Pick a scheduling policy (e.g. fixed-priority Rate-Monotonic, or EDF).
  3. Run a schedulability test: a mathematical proof that all deadlines are met under worst-case load.

Deriving the simplest test: CPU utilisation bound


Soft deadlines: a different goal

For soft real-time you don't prove zero misses — you bound the statistics: e.g. "99.9% of frames render within 16 ms," or minimise average tardiness max(0,RiDi)\max(0, R_i - D_i). The design knob is graceful degradation: drop quality, skip frames, or shed load instead of crashing.


Flashcards

What makes a system "real-time"?
Correctness depends on both the logical result and the time it is produced (timeliness is part of correctness).
Hard deadline — consequence of a miss?
Catastrophic / total system failure; a late result is invalid.
Firm deadline — consequence of a miss?
Late result has zero value and is discarded, but no catastrophe.
Soft deadline — consequence of a miss?
Result still has reduced/degrading value; occasional misses tolerated.
What is WCET and why use it (not average)?
Worst-Case Execution Time; deadlines fail in the worst case, so guarantees must be built on the maximum, not the mean.
Utilisation of one periodic task?
Ui=Ci/TiU_i = C_i/T_i (CPU fraction it demands).
Total utilisation of nn tasks?
U=iCi/TiU=\sum_i C_i/T_i; if U>1U>1 the CPU is over-subscribed and a miss is unavoidable.
Liu–Layland RM schedulability bound?
Un(21/n1)U \le n(2^{1/n}-1); limit ln20.693\to \ln 2 \approx 0.693 as nn\to\infty.
EDF utilisation bound on one CPU?
U1U \le 1 (EDF is optimal for periodic single-processor).
Is the RM utilisation test sufficient or necessary?
Sufficient only — failing it does not prove unschedulability; use exact Response-Time Analysis.
Response-Time Analysis equation?
Ri=Ci+jhp(i)Ri/TjCjR_i = C_i + \sum_{j\in hp(i)} \lceil R_i/T_j\rceil C_j, iterated to convergence; schedulable iff RiDiR_i \le D_i.
Why does Ri/Tj\lceil R_i/T_j\rceil appear?
It counts how many times higher-priority task jj preempts ii during RiR_i.
Hard real-time goal in one word?
Predictability (bounded worst case), not raw speed.
Recall Feynman: explain to a 12-year-old

Imagine catching a school bus. Hard deadline: if you're even one second late the bus leaves and you miss school entirely — disaster. Firm deadline: you can still come, but if you're late your homework "doesn't count" — no points, but nobody's hurt; you just throw it away. Soft deadline: you're allowed to be a little late and still get most of the marks, just fewer the later you are. To promise you'll never miss the hard bus, you don't say "I'll run fast" — you measure the slowest you could ever walk, add up everyone using the one door, and prove you all fit in time. Fast-on-average isn't a promise; a proof using the worst case is.

Connections

Concept Map

correctness needs

central quantity

d_i = r_i + D_i

meets if R_i <= D_i

worst-case bound

classified by lateness cost

classified by lateness cost

classified by lateness cost

miss = catastrophe

late = zero value, discard

late = degrading value

needs

feeds

sum over tasks

Real-time system

Timeliness

Deadline d_i

Release time r_i

Response time R_i

WCET C_i

Hard deadline

Firm deadline

Soft deadline

Provable guarantee

Schedulability test

Utilisation U_i = C_i / T_i

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Real-time system ka matlab sirf "fast" hona nahi hai — iska matlab hai ki answer sahi time pe aana chahiye. Agar answer correct hai par deadline ke baad aaya, to kuch systems mein wo bekaar (ya khatarnak) ho jaata hai. Isliye correctness mein timeliness bhi include hoti hai. Har task ka ek deadline hota hai: release time se kitne time ke andar finish hona chahiye.

Deadlines teen type ki hoti hain. Hard: miss hui to total disaster — jaise airbag ya flight control. Firm: late answer ki value zero, use throw kar do, par koi catastrophe nahi — jaise video ka late frame. Soft: thoda late chal jaata hai, value dheere-dheere kam hoti hai — jaise streaming buffering ya UI smoothness. Yaad rakhne ka tareeka: HARD = Heart-stop, FIRM = Forget-it, SOFT = Slowly-fades.

Hard deadline ko guarantee karne ke liye testing kaafi nahi — proof chahiye. Pehle har task ka WCET (worst-case execution time, CiC_i) nikalo. Phir utilisation U=Ci/TiU = \sum C_i/T_i nikalo — yeh CPU ka kitna hissa maang raha hai wo batata hai. Agar U>1U > 1 to CPU over-subscribed hai, miss pakka. Rate-Monotonic ke liye safe bound hai Un(21/n1)U \le n(2^{1/n}-1) (jo 0.6930.693 tak gir sakta hai), aur EDF ke liye poora U1U \le 1. Bada point: yeh bound sufficient hai, necessary nahi — fail ho jaaye to Response-Time Analysis se exact check karo.

Sabse important galti: log sochte hain hard real-time matlab "bahut tez". Galat! Iska matlab hai predictable — worst case bounded hona chahiye. Ek slow par deterministic MCU, ek fast par kabhi-kabhi atak jaane waale system se behtar hai. Hamesha average nahi, worst-case time use karo.

Go deeper — visual, from zero

Test yourself — Embedded Systems & Real-Time Software

Connections