Chapter 9: Real-Time Operating System (RTOS)

What is a Real-Time Operating System (RTOS)?

Definition

  • A Real-Time Operating System (RTOS) (meaning: an operating system that guarantees to process events or data within a specific, short time limit) schedules tasks, manages resources, and provides a consistent platform for real-time applications.

Causes

  • Needed when systems must respond to inputs immediately
  • Required for embedded systems with moderate-to-large software that need predictable scheduling

Goals / Objectives

  • To schedule execution in a timely manner
  • To manage system resources (memory, CPU)
  • To guarantee response within strict time limits

Importance

  • Essential for safety-critical and time-sensitive systems (e.g., aircraft, traffic lights, nuclear reactors)
  • Provides a reliable foundation for building embedded applications

Procedures

  • Not specified in notes

Advantages & Disadvantages

  • Advantages:

    • Enables timely, predictable responses
    • Supports complex embedded applications
  • Disadvantages:

    • Not needed for very simple systems (e.g., basic calculators)
    • Adds complexity and resource overhead

Impact / Effect

  • Makes real-time systems reliable and responsive
  • Without an RTOS, time-critical tasks may miss deadlines, causing system failure

Examples

  • Traffic light control system
  • Aircraft flight control
  • Nuclear reactor monitoring

Key Takeaways

  • RTOS = operating system with strict time guarantees
  • Used when missing a deadline is unacceptable or costly
  • Not all embedded systems need one—only those with real-time requirements

Key Characteristics of an RTOS

Definition

  • The key characteristics of an RTOS are the core qualities that make it suitable for time-critical applications.

Causes

  • Driven by the demands of real-world embedded and control systems

Goals / Objectives

  • To ensure the RTOS can meet application-specific timing and reliability needs

Importance

  • These traits determine whether an RTOS is fit for purpose in a given system

Procedures

  • Evaluate an RTOS based on these five attributes:
    • Reliability
    • Predictability
    • Performance
    • Compactness
    • Scalability

Advantages & Disadvantages

  • Advantages:

    • Together, these traits enable robust, efficient real-time systems
  • Disadvantages:

    • Not specified in notes

Impact / Effect

  • Poor reliability or unpredictability can lead to catastrophic system failures
  • Compactness and scalability affect cost and flexibility

Examples

  • Digital solar-powered calculator: May reset if light is low—but still acceptable (lower reliability needed)
  • Cell phone: Must be small, portable, and low-cost → requires compactness

Key Takeaways

  • RTOS must be reliable, predictable, fast, small, and scalable
  • The right mix depends on the specific application
  • Predictability (determinism) is often more important than raw speed

Reliability

Definition

  • Reliability means the RTOS can operate correctly for long periods without failure or human intervention.

Causes

  • Needed for systems that can’t be easily monitored or restarted

Goals / Objectives

  • To ensure continuous, correct operation under expected conditions

Importance

  • Critical for safety-critical or remote systems (e.g., space probes, medical devices)

Procedures

  • Design for fault tolerance and long uptime
  • Acceptable reliability level depends on application context

Advantages & Disadvantages

  • Advantages:

    • Reduces risk of system downtime or failure
  • Disadvantages:

    • Higher reliability may increase cost or complexity

Impact / Effect

  • Unreliable RTOS → system crashes or unsafe behavior

Examples

  • Solar-powered calculator: Can reset if light is low and still be useful
  • Industrial control system: Must run 24/7 without failure

Key Takeaways

  • Reliability = “keeps working, even when no one is watching”
  • Required level varies by application—not all systems need 100% uptime

Predictability (Determinism)

Definition

  • Predictability (also called determinism) means the RTOS completes operations within known, consistent time frames.

Causes

  • Real-time systems must meet strict deadlines—unpredictable delays cause errors

Goals / Objectives

  • To ensure timing behavior is consistent and measurable

Importance

  • The defining feature of real-time systems—correctness depends on when results are produced, not just what is produced

Procedures

  • Use benchmark programs to measure response time variance
  • Ensure system calls have low, consistent execution times

“Deterministic describes Real-Time Operating Systems (RTOSs) with predictable behavior, in which the completion of operating system calls occurs within known timeframes.”

Advantages & Disadvantages

  • Advantages:

    • Enables accurate timing analysis and scheduling
  • Disadvantages:

    • May limit use of complex or variable-time features

Impact / Effect

  • High predictability → system always meets deadlines
  • Low predictability → missed deadlines = system failure

Examples

  • Measuring response time variance for each RTOS system call
  • A good RTOS shows very small variation in timing

Key Takeaways

  • Predictability ≠ speed—it’s about consistency
  • Determinism is key: you must know exactly how long things take
  • Test with real timing measurements, not just theory

Performance

Definition

  • Performance refers to how fast the RTOS and system can process inputs and produce outputs.

Causes

  • Systems must be fast enough to meet timing requirements

Goals / Objectives

  • To fulfill all real-time deadlines through sufficient speed

Importance

  • Even a predictable system fails if it’s too slow

Procedures

  • Measure using:
    • MIPS (Million Instructions Per Second)
    • Call-by-call timing: timestamp system call start and end
    • Input-to-output rate

Advantages & Disadvantages

  • Advantages:

    • Higher performance allows more complex tasks in same time window
  • Disadvantages:

    • Raw speed without predictability is not enough for real-time

Impact / Effect

  • Poor performance → missed deadlines, even with good scheduling

Examples

  • Using timestamps to measure how long a system call takes
  • Checking if system can generate output fast enough for incoming sensor data

Key Takeaways

  • Performance must be measured in context of deadlines
  • Use real timing tests, not just processor specs
  • MIPS alone doesn’t guarantee real-time capability

Compactness

Definition

  • Compactness means the RTOS uses minimal memory and code size.

Causes

  • Embedded systems often have tight hardware constraints (cost, power, size)

Goals / Objectives

  • To minimize static and dynamic memory usage
  • To fit within limited hardware resources

Importance

  • Enables use in small, low-cost devices like phones or sensors

Procedures

  • Analyze:
    • Static memory: allocated at compile-time
    • Dynamic memory: allocated at run-time
  • Limit OS and application size to meet design and cost constraints

Advantages & Disadvantages

  • Advantages:

    • Reduces hardware cost and power use
  • Disadvantages:

    • May limit features or flexibility

Impact / Effect

  • Non-compact RTOS → too big for target hardware
  • Forces use of more expensive components

Examples

  • Cell phone: must be small, portable, and low-cost → needs compact OS
  • Designers must understand total memory footprint of RTOS + app

Key Takeaways

  • Compact = small memory and code size
  • Critical for cost-sensitive or battery-powered devices
  • Check both static and dynamic memory usage

Scalability

Definition

  • Scalability means the RTOS can grow or shrink by adding or removing features to match application needs.

Causes

  • RTOSs are used in many different types of systems, from tiny sensors to complex controllers

Goals / Objectives

  • To support modular configuration (e.g., add file system, remove networking)

Importance

  • Avoids over-engineering small systems or under-powering large ones

Procedures

  • Design RTOS with modular components (e.g., protocol stacks, file systems) that can be included or excluded

Advantages & Disadvantages

  • Advantages:

    • One RTOS can serve many product lines
    • Keeps small systems lean and efficient
  • Disadvantages:

    • Modular design adds development complexity

Impact / Effect

  • Scalable RTOS → flexible, reusable across projects
  • Non-scalable → need different OS for every product

Examples

  • Adding a file system for a data-logging device
  • Removing network stack for a simple motor controller

Key Takeaways

  • Scalability = “use only what you need”
  • Lets you customize the OS for each project
  • Saves memory, cost, and power

Categories of RTOS: Hard vs. Soft Real-Time

Definition

  • RTOSs are divided into hard real-time and soft real-time based on how strictly they must meet deadlines.

Causes

  • Different applications have different consequences for missing deadlines

Goals / Objectives

  • To match system design to timing-criticality of the task

Importance

  • Determines how the system is built, tested, and validated

Procedures

  • Classify tasks based on what happens if deadline is missed:
    • Hard real-time: result is wrong or useless if late
    • Soft real-time: result is less valuable if late, but still usable

Advantages & Disadvantages

  • Advantages:

    • Clear classification helps choose the right design approach
  • Disadvantages:

    • Some systems have mixed hard and soft tasks, complicating design

Impact / Effect

  • Hard real-time systems require more rigorous design and testing
  • Soft real-time allows more flexibility and lower cost

Examples

  • Hard: Aircraft control—missed deadline = crash
  • Soft: Video streaming—missed frame = glitch, not failure

Key Takeaways

  • Hard real-time: Deadline = law—missing it breaks the system
  • Soft real-time: Deadline = goal—missing it reduces quality
  • Always ask: “What happens if this is late?”

Hard Real-Time Systems

Definition

  • A hard real-time system is one where results are incorrect if not delivered by the deadline—the value of a late result is zero.

Causes

  • Used in safety-critical or control systems where timing is part of correctness

Goals / Objectives

  • To guarantee all deadlines are met, 100% of the time

Importance

  • Failure can lead to injury, death, or major financial loss

Procedures

  • Design with worst-case timing analysis
  • Use deterministic scheduling and no unpredictable delays

Advantages & Disadvantages

  • Advantages:

    • Maximum safety and reliability
  • Disadvantages:

    • Higher cost, complexity, and testing burden

Impact / Effect

  • Enables use in mission-critical applications
  • Requires certification and rigorous validation

Examples

  • Nuclear reactor shutdown system
  • Anti-lock braking system (ABS) in cars

Key Takeaways

  • Late = wrong—no exceptions
  • Used where human safety or major assets are at risk
  • Must be proven to always meet deadlines

Soft Real-Time Systems

Definition

  • A soft real-time system is one where performance degrades if deadlines are missed, but the system still functions.

Causes

  • Used in user-facing or quality-sensitive applications where occasional delays are tolerable

Goals / Objectives

  • To minimize missed deadlines and reduce penalty when they occur

Importance

  • Balances user experience and cost
  • Most common type in consumer electronics

Procedures

  • Track tardiness (how late a task is)
  • Apply penalties that increase with delay (e.g., lower video quality)

Advantages & Disadvantages

  • Advantages:

    • More flexible and cost-effective than hard real-time
  • Disadvantages:

    • Unpredictable user experience if overloaded

Impact / Effect

  • Missed deadlines cause reduced quality, not failure
  • Allows use of cheaper hardware

Examples

  • Online video call: late frames cause lag or blur, but call continues
  • Music streaming: occasional skip, but song keeps playing

Key Takeaways

  • Late = worse, but not broken
  • Penalty increases the later you are
  • Good for media, games, and non-critical apps

RTOS Components

Definition

  • RTOS components are the core modules that make up a real-time operating system.

Causes

  • Needed to manage tasks, time, and resources in a time-critical environment

Goals / Objectives

  • To provide minimal, efficient services for real-time task execution

Importance

  • These components enable predictable, concurrent operation

Procedures

  • Five key components:
    • Real-time clock: provides timing for scheduling
    • Interrupt handler: manages aperiodic (unexpected) events
    • Scheduler: chooses next process to run
    • Resource manager: allocates memory and CPU
    • Dispatcher: starts process execution

Advantages & Disadvantages

  • Advantages:

    • Modular design supports efficiency and determinism
  • Disadvantages:

    • Not specified in notes

Impact / Effect

  • Well-designed components → low overhead, high predictability
  • Poor design → unpredictable delays and missed deadlines

Examples

  • Interrupt handler responding to a sensor trigger
  • Scheduler deciding which alarm process runs next in a burglar system

Key Takeaways

  • RTOS has 5 core parts: clock, interrupt handler, scheduler, resource manager, dispatcher
  • Each must be fast and predictable
  • Together, they coordinate real-time tasks

Timing Analysis in Real-Time Systems

Definition

  • Timing analysis is the process of calculating execution times, frequencies, and deadlines to ensure all tasks meet their timing requirements.

Causes

  • Real-time correctness depends on both logical result and delivery time

Goals / Objectives

  • To determine how often each process must run
  • To ensure all stimuli are processed on time

Importance

  • Foundation for correct RTOS scheduling
  • Prevents overload and missed deadlines

Procedures

  • Analyze three key factors:

    • Deadlines: latest time a response must be produced
    • Frequency: how often a process must execute per second
    • Execution time: time needed to process one stimulus
  • Use results to design the scheduling system

Advantages & Disadvantages

  • Advantages:

    • Enables provable correctness of real-time behavior
  • Disadvantages:

    • Requires detailed knowledge of task timing

Impact / Effect

  • Accurate analysis → system always meets deadlines
  • Inaccurate analysis → occasional or frequent failures

Examples

  • Burglar alarm system:
    • Poll door sensor every 0.5 sec
    • Poll motion sensor every 1 sec
  • Scheduling table ensures no task is delayed

Key Takeaways

  • Timing analysis = “Will everything finish on time?”
  • Must know deadline, frequency, and execution time for each task
  • Drives the entire scheduling design

Real-Time System Design Process

Definition

  • The real-time system design process is a step-by-step method to build a system that reliably responds to external events within time limits.

Causes

  • Real-time systems must handle multiple concurrent stimuli with strict timing

Goals / Objectives

  • To transform requirements into a working, schedulable system

Importance

  • Ensures the final system is correct, predictable, and efficient

Procedures

  • Six key stages:
    1. Identify stimuli and responses (e.g., sensor trigger → alarm)
    2. Define timing constraints for each stimulus-response pair
    3. Group into concurrent processes (e.g., Door Sensor Process, Motion Sensor Process)
    4. Design algorithms for each response
    5. Design scheduling system to meet all deadlines
    6. Integrate under RTOS for resource and process management

Advantages & Disadvantages

  • Advantages:

    • Structured approach reduces design errors
    • Ensures timing requirements are built in from the start
  • Disadvantages:

    • Requires upfront analysis and planning

Impact / Effect

  • Leads to robust, maintainable real-time systems
  • Prevents last-minute timing crises

Examples

  • Intruder alarm system:
    • Stimulus: “Two sensors positive”
    • Response: “Initiate alarm, turn on lights, call police with location”
  • Power failure → “Switch to backup power”

Key Takeaways

  • Design in 6 clear steps, from stimuli to RTOS integration
  • Always start with what the system must react to
  • Group related tasks into concurrent processes
  • Scheduling is designed last—but based on all prior steps

Stimuli in Real-Time Systems

Definition

  • Stimuli (meaning: external events or inputs that trigger system responses) are the starting point for real-time system behavior.

Causes

  • Real-time systems exist to react to the outside world

Goals / Objectives

  • To detect and respond to all relevant environmental changes

Importance

  • Without stimuli, there’s no reason for a real-time system to exist

Procedures

  • Classify stimuli into two types:

    • Periodic: occur at regular intervals (e.g., sensor polling every 0.5 sec)
    • Aperiodic: occur unpredictably (e.g., button press, power failure)
  • For each stimulus, define response and deadline

Advantages & Disadvantages

  • Advantages:

    • Clear stimulus list ensures nothing is missed
  • Disadvantages:

    • Aperiodic stimuli are harder to schedule (require interrupts)

Impact / Effect

  • Determines system architecture and scheduling strategy
  • Affects hardware choices (e.g., interrupt lines)

Examples

  • Burglar alarm system stimuli:
    • Periodic: sensor polling
    • Aperiodic: panic button, power failure, sensor trigger
  • Carpark system (quiz example):
    • Stimulus: car at entrance
    • Response: issue ticket, raise barrier

Key Takeaways

  • All real-time systems start with “What do I react to?”
  • Periodic = regular; Aperiodic = random
  • Each stimulus must have a defined response and deadline