Course Outline: Embedded Real-Time Software
Part 1: Real-Time Operating Systems (RTOS)
1. Introduction to Real-Time Embedded Systems
-
Embedded Systems Overview: Definition and characteristics of embedded systems. * Real-Time Concepts:
-
Definition of Real-Time Systems (correctness depends on time).
-
Hard vs. Soft Real-Time: Distinction based on the consequences of missed deadlines.
-
Constraints: Processor speed, memory, energy, and concurrency.
-
-
RTOS Fundamentals:
-
Comparison between General Purpose OS (GPOS) and RTOS.
-
Key Characteristics: Reliability, Predictability, Performance, Compactness, Scalability.
-
Task Model:
-
Task types: Periodic (time-driven), Aperiodic (event-driven, one-shot), and Sporadic (event-driven with minimum inter-arrival time).
-
Task States: Running, Ready, Blocked, Suspended.
-
Task Control Block (TCB): Data structure for managing task context.
-
-
2. Scheduling
-
Task Specification:
-
Temporal parameters: Release time, Execution time (), Deadline (), Period ().
-
Functional parameters: Criticality and Preemptivity.
-
-
Scheduling Algorithms:
-
Clock-Driven Scheduling: Static schedules, cyclic executives, frame-based scheduling.
-
Priority-Based Scheduling:
-
Fixed Priority: Rate Monotonic (RM) scheduling (shorter period = higher priority).
-
Dynamic Priority: Earliest Deadline First (EDF) scheduling (earlier deadline = higher priority).
-
-
-
Schedulability Analysis:
-
CPU Utilization ().
-
Necessary and sufficient conditions for schedulability under RM and EDF.
-
Worst-Case Execution Time (WCET) estimation.
-
3. Concurrency and Synchronization
-
Resource Sharing:
-
Shared data structures, memory, and I/O.
-
Race Conditions: Issues arising from interleaved execution.
-
Critical Sections: Code segments accessing shared resources requiring mutual exclusion.
-
-
Priority Inversion:
-
Problem: High-priority task blocked by low-priority task holding a resource.
-
Unbounded Priority Inversion: Infinite blocking due to medium-priority tasks.
-
Protocols:
-
Priority Inheritance Protocol (PIP): Boosting priority of the blocking task.
-
Priority Ceiling Protocol (PCP): Preventing deadlocks and bounding blocking time using resource ceilings.
-
-
-
Synchronization Primitives:
-
Semaphores: Binary and Counting semaphores for signaling and resource counting. * Mutex: Mutual exclusion objects with ownership and priority inheritance capabilities.
-
Condition Variables: Signaling state changes between threads.
-
Atomic Variables: Uninterruptible operations for lock-free synchronization.
-
-
Inter-Task Communication:
-
Message Queues: Asynchronous data transfer (FIFO).
-
Pipes: Byte-stream data transfer.
-
4. Debugging Real-Time Systems
-
Fault Analysis:
-
Types of bugs: Permanent, Aging-related (memory leaks), and Heisenbugs (disappear when probed).
-
Cost of fixing bugs at different development stages.
-
-
Debugging Tools & Techniques:
-
GPIO Debugging: Using physical pins to measure timing/state without halting.
-
Logging/Printf: Non-intrusive tracing (limitations in timing).
-
JTAG/SWD Debuggers: Breakpoints, stepping, and memory inspection.
-
Tracing: Recording execution history (system events, ISRs) for performance analysis (e.g., Segger SystemView).
-
-
Testing:
-
Unit Testing in Zephyr (Ztest framework).
-
Code Coverage: Statement, Decision, and MC/DC coverage.
-