Real-time Software

Real-time Tux

Tyler Veness

Definitions of Real-time

  • Hard
    • Can't miss deadlines
    • Aircraft control, pacemaker
  • Firm
    • Can miss deadlines, but late results are useless
    • Heads-up display, video stream
  • Soft
    • Usefulness of result degrades after deadline
    • Desktop application scheduling


  • Predictability
  • Determinism
    • malloc(), printf(), locks

Scheduling and Priority

  • Kernel can be preemptible
  • Real-time scheduling
    • SCHED_FIFO (queues) ∈ SCHED_RR
    • SCHED_DEADLINE (earliest first)
  • Non-RT
    • SCHED_OTHER, SCHED_BATCH and niceness ([-20..19])

Priority Inversion

  • Low priority task preempts high priority task for shared resource
  • High priority task waits on shared resource
  • Solutions
    • Disable interrupts
    • Priority inheritance
    • Lock-free and atomics

Disable Interrupts

  • Allow process with shared resource to complete
  • Doesn't scale well

Priority Inheritance

  • Elevate priority to that of highest priority waiting task

Lock-free and Atomics

  • No locks! (ideally)
  • Lock-free vs wait-free
  • Lock-free data structures

Lock-free Example

Floating Point Unit (FPU)


Robot Code Example