Real-Time and Embedded Operating Systems What Is Real Time?
Total Page:16
File Type:pdf, Size:1020Kb
Real-Time and Embedded Operating Systems What is Real Time? Real-time: Systems where the correctness of computation depends on the timing of the results Embedded: Systems that tightly interact with the physical world 1 Embedded and Real-Time Computing Classical Applications Advanced Embedded Systems The Next Frontier Trend: • Invisible (embedded) computing, implicit interfaces (users need only 1 mobile device – rest should be non-intrusive) • Context-aware computing (new sensors, new effectors) • Ubiquitous – instrument what we use most (attire, personal effects, …) Processors Embedded Everywhere - Transparent - Context-aware - Mobile - Miniature - Ubiquitous (Smart attire, smart spaces, …) Today 2 Embedded Networked Systems RFID Embedded Networks Device Applications Industrial Networks Networks Remote Sensing Networks Medical Networks Smart Space Networks Embedded Computing Computing occurs in physical context. It must be aware of physical real-world properties: Time Energy Physical space and context 3 So What Does “Real-Time” Mean Again? Why Predictability? Example: Going to the Airport Which route would you choose? •Route 1: 15 min ($1 Toll) •Route 2: 5 min - 45 min, with 15 min average (Free) You pay for predictability 4 The Task Model Typically, periodic tasks Each task invocation must complete before the next one starts (deadlines = periods) How to Ensure Predictability? Real-time operating systems are distinguished by mechanisms they use to ensure predictable task execution 5 Predictability: Mechanism #1: Scheduling Real-time operating systems feature predictable scheduling policies Utilization Bounds Intuitively, for a given scheduling policy: The lower the processor utilization, U, the easier it is to meet deadlines. The higher the processor utilization, U, the more difficult it is to meet deadlines. Question: is there a threshold Ubound such that When U < Ubound deadlines are met 6 Main Results Periodic Task Scheduling Rate Monotonic EDF Bound Optimality Bound Optimality 69% 100% Mixed Periodic and Aperiodic Task Systems Idea: aperiodic tasks can be served by periodically invoked servers The server can be accounted for in periodic task schedulability analysis The server has a period Ps and a budget Bs Server can serve aperiodic tasks until budget expires Servers have different flavors depending on the details of when they are invoked, what priority they have, and how budgets are replenished Server Aperiodic Tasks 7 Example: Polling Server Runs as a periodic task (priority set according to RM) Aperiodic arrivals are queued until the server task is invoked When the server is invoked it serves the queue until it is empty or until the budget expires then suspends itself If the queue is empty when the server is invoked it suspends itself immediately. Server is treated as a regular periodic task Other Real-time Servers Deferrable server Sporadic server Priority exchange server Slack stealing server Constant bandwidth server etc... 8 Predictability Mechanism #2: Synchronization Real-time operating systems feature predictable locking mechanisms (that guarantee bounded blocking time) Mutual Exclusion Constraints Tasks that lock/unlock the same semaphore are said to have a mutual exclusion constraint Lock S Unlock S Task 1 Critical sections (Mutually exclusive) Task 2 Lock S Unlock S 9 Remember Unbounded Priority Inversion? Consider the case below: a series of intermediate priority tasks is delaying a higher- priority one Attempt to lock S High-priority task results in blocking Preempt. Unbounded Priority Inversion Intermediate-priority tasks … Lock S Preempt. Low-priority task Unbounded Priority Inversion How to prevent unbounded priority inversion? Attempt to lock S High-priority task results in blocking Preempt. Unbounded Priority Inversion Intermediate-priority tasks … Lock S Preempt. Low-priority task 10 Example from Earlier: Priority Inheritance Protocol Let a task inherit the priority of any higher- priority task it is blocking Attempt to lock S High-priority task results in blocking Preempt. Unlock S Lock S Intermediate-priority tasks … Lock S Unlock S Low-priority task Example from Earlier: Priority Ceiling Protocol Definition: The priority ceiling of a semaphore is the highest priority of any task that can lock it A task that requests a lock Rk is denied if its priority is not higher than the highest priority ceiling of all currently locked semaphores (say it belongs to semaphore Rh) The task is said to be blocked by the task holding lock Rh A task inherits the priority of the top higher-priority task it is blocking 11 Multicore: Contention over Memory Execution on different processors may not be entirely independent because of contention over main memory bandwidth Multicore: Contention over Cache Execution on different processors may not be entirely independent because of contention over cache (one task might cause content belonging to another to be kicked out of the cache) Solutions: Allow tasks to have dedicated portions of cache Allow cache lines to be locked 12 Predictability Mechanism #3: Communication Communication must offer a bounded latency as well. This design decisions favors communication protocols that offer dedicated resources to communicating nodes (e.g., their own time slots) over those that offer a shared contention- based medium access. Predictability Mechanism #4: Real-time Virtual Machines Consider the problem of garbage collection in Java The garbage collector can run at arbitrary times and consume an arbitrary amount of resources Solution: Bound the latency of any activities that interrupt the current task (such as the garbage collector) 13 Other Considerations General resource efficiency Energy efficiency Code minimality Configurability Security Verifiability 14.