Real Time Operating Systems
Real Time Operating Systems
EE 128
Lecture 17
Outline Embedded Systems Are Often Time-Critical
Electrical and Computer Engineering
Sensing and Actuation for Embedded Systems • Real-Time Systems Concepts • Real-Time: timing correctness is part of the system correctness
• Preemptive vs. non-preemptive – Both logical & temporal correctness of output should be guaranteed
• OS and Task Management • Hard real-time systems
– Deadlines must be met
– If any hard deadline is ever missed, then the system is incorrect
Real-Time Operating Systems – E.g., Automotive safety features, nuclear power plant
2 3
Example Real-Time Applications Real-Time Does Not Mean “Fast” Common Misconceptions About Real-Time
• Process Control (Chemical Plants)
• Factories (Automotive Assembly Plants)
• Supervisory Control and Data Acquisition (Utilities)
• Real-time? Real Fast? • Real-time computing is equivalent to fast computing
• Medical Devices and Healthcare (Medical Robots and Equipment) – Fast = doing something quickly
• Computer Peripherals (Laser printers) – Real-time = meeting timing constraints (deadlines) • Advances in supercomputing hardware will take care of real-time
• Automotive (Engine controls) • Real-time system can be slow requirements
• Telecommunications (Cellphone Infrastructure) • Fast system can be non-real-time
• Aerospace (avionics) • Real-time programming = assembly or low-level language
• Of course, most real-time systems are designed to be fast and to programming
• Internet and Multimedia (Videoconferencing, IPTV, Skype)
• Consumer Electronics (Mobile phones, TVs, set=top boxes)
operate at high speeds
• Military systems (missile guidance systems, radar systems) • “Real time” is performance tweaking
• Space systems (planetary rovers, rockets, satellites) Real-time != Real Fast
Predictability & Analyzability
4 5 6
05-Dec-22
Physical
environment
7 8 9
10 11 12
05-Dec-22
Task release
13 14 15
• Non-preemptive scheduling • The software layer that lies between a computer user and the • Hardware
– Task runs to completion, even if other tasks want service computer hardware – Provides basic computing resources: CPU, memory, I/O (disk, mouse,
• e.g., put everything in a while loop in background/foreground systems – Hides details of programming low-level devices keyboard, display), network interfaces
– What happens if one task takes very long time to complete? • Provides resource abstraction • Operating System
– Manages system resource sharing – Controls and coordinates the use of the hardware among various
• Preemptive scheduling application programs for different users
– Separates users and processes from one another
– Task is suspended immediately when some other task wants service, then
restarted at a later time • Application Programs
– Better to provide shorter latency – Define the ways in which the system resources are used to solve the
computing problems of users
– e.g., task scheduling in most operating systems
• e.g. database systems, 3D games, business applications
– Needs support from operating systems
• Task management: task state, scheduler, context switching • Users
– People, machines, and other computers
16 17 18
05-Dec-22
• Task Management • Task is a program in execution within its own address space
• Memory Management – Also called process or thread
– A task includes the current activity of the program
• File Management
• PC, Stack pointer, values in register set
• I/O Management – Each task has its own text, data, heap and stack section
• Networking – Tasks need certain resources, including CPU time, memory, files, and I/O
• User Security devices
19 20 21
22 23 24
05-Dec-22
25 26 27
28 29 30
05-Dec-22
• Metrics for real-time systems differ from that for general- • Scheduler: resource allocator that affects the timing of tasks • Fixed-priority based
purpose systems – Some tasks have more importance (higher priority) than others
All scheduling algorithms – Once a task’s priority is assigned, it cannot change during run-time
General-purpose systems Real-time systems
Capacity High throughput Schedulability • Rate Monotonic (RM)
Responsiveness Fast average response Ensured worst-case response – Shorter the period, the higher the priority of the task
Overload Fairness Stability Static scheduling Dynamic scheduling – Assigns fixed priorities in reverse order of period length
(or offline, or clock-driven) (or online, or priority-driven) – Tasks requiring frequent attention have higher priority and get scheduled
– Schedulability is the ability to meet task deadlines earlier
– Worse-case latency is the maximum response time to events in the worst-
case scenario • Deadline Monotonic (DM)
Fixed-priority Dynamic-priority – Similar to RM (if period = deadline, RM = DM)
– Stability in overload means the system meets critical deadlines when not
scheduling scheduling – Shorter the deadline, the higher the priority of the task
all deadlines can be met
31 32 33
34 35