140 likes | 287 Views
Real Time Operating Systems Lecture 10. David Andrews dandrews@eecs.ukans.edu. What We Will Cover Today. Operating Systems Services Base Components Real Time Considerations Task Management Time Triggered Event Triggered Interprocess Communications Blocking Non-Blocking Time Management
E N D
Real Time Operating SystemsLecture 10 David Andrews dandrews@eecs.ukans.edu
What We Will Cover Today • Operating Systems Services • Base Components • Real Time Considerations • Task Management • Time Triggered • Event Triggered • Interprocess Communications • Blocking • Non-Blocking • Time Management • Services • Maintenance
Task Manager Timer Services IPC File Mgt Scheduling Semaphores Watchdog Countdown System Time Synch Asynch Virtual Mem Cache Operating Systems Functionality • Considerations • Footprint An Issue • Small Numbers of Programs • Virtual Memory Will Not be Required For Our Study
Task Taxonomy • Simple Task (S-task) • No synchronization within task • Executes from beginning to end, subject only to pre-emption by interrupts – Might be triggered by some other task initially – Might communicate results to some other task – But, no internal synchronization with other tasks • Complex Task (C-task) • Has some synchronization with other tasks – May have to wait for another task to process a request – May have to wait for I/O to complete – May have to wait for resource to become available (memory, network) • Timing depends on the rest of the system – So, C-tasks are “bad” because they increase complexity – And, C-tasks make it more difficult to analyze system timing properties
C-Task Execution time • S-Task execution time plus: • Waiting for other processes… • Not so bad if other tasks are S-Tasks and it is just a remote procedure call • General case can be impractical to handle • General solution: • Break C-tasks into S-tasks separated by interactions • Then, make sure that S-tasks are scheduled far enough apart for interaction to complete • Great when it works...
Task Management • Key component is scheduler: • Static: Schedule Built up Prior To Running • Scheduler Develops Time Triggered Schedule • Periodic/Predictable • Dynamic: Schedule Built During Run Time • Can Be Based on Worst Case Execution Time (WCET) • Scheduler Invoked by events • Timer, Interrupts, suspend, resume, etc.
Worst Case Execution Time (simple version)... • Assume a simple task (S-task) that just executes its own code without coordinating with other threads or I/O How hard could it be to determine timing? • Timing is once through the code + jitter due to: • Non-fixed loop iteration count • Non-fixed number of recursive calls • Garbage collection • Conditional statement execution asymmetry (if/else path timings) • Effects of hardware non-determinism – Cache – Data-dependent instruction execution time – …
Task B Task A Restore context Save context OS OS Restore context Save Context Task B WACO WACO … Plus S-Task Context Swapping • Overhead from task switching: OS + Hardware • … multiply by number of pre-emptions • Gives WCAO (Worst-Case Administrative Overhead) due to pre-emptions
… Plus Effects From Nested Interrupts • What if you have multiple prioritized interrupts • Worst case execution time for interrupt at Priority X is = Execution time for interrupt at Priority 1 (perhaps multiple times) + Execution time for interrupt at Priority 2 (perhaps multiple times) + Execution time for interrupt at Priority 3 (perhaps multiple times) … + Execution time for interrupt at Priority X (perhaps multiple times) • You can bound this as long as the period of each interrupt is bounded • Same algorithm as for computing worst case CAN message latency(!) • Scheduling on a CPU is a dual problem to scheduling on a network
Time Action WCET 10 17 22 38 47 Start T1 Send M5 Stop T1 Start T3 Send M3 12 20 Dispatcher Task Management • Time Triggered • A priori build Task-Descriptor Table (TADL)
Interprocess Communications • IPC can support Messages, or Common Data Regions… • Messages • We have already discussed synch/asynch • Asynchronous can be implemented in S-Tasks • Synchronous (suspend) can be implemented in C-Tasks • Common Data Regions • Implemented via shared memory • Introduces critical regions • Semaphore Operations needed • Test and Set
Time Management • Time Management provides: • Clock synchronization • Time stamping • Watchdog Timers • User Accessible • Operating System
Real Time Operating Systems • Unix “feel” • QNX • LinxOS • “Smaller” RTOSs • OS9, Microware • VxWorks (be sure to get the memory protection extension) • pSOS • RTX, VenturCom • A few research/freeware RTOS systems: • KURT (KU real Time) • RT-Mach, CMU • …others • Windows: WinCE; embedded NT, Windows + RT add-on products
Questions To Ask Your RTOS Vendor • Real Time Operating System • Purports to ensure timeliness of task execution • Uses task priorities and a scheduling algorithm • Hard questions: • What is the tasking model (preemptive or non-preemptive)? Scheduler? • What is the longest task switch latency? – Function of interrupt masking time • How big is the footprint for a real system? (Not a stripped-down toy system) • Does it have inter-task memory protection? • How much of POSIX does it really support? • How long does the system take to reboot? • What is the runtime license fee? • How robust is it (and what is the exception handling model?)