http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O
RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences CS134 Real-Time Operating Systems (RTOS) Real-time scheduling Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Real-time operating systems (RTOS) Any system that must react in bounded time to events in the real world Cruise control Autopilot Robot Thermostat Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences An example real-time system Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Real-time requirements Soft real-time Best-effort attempt Schedule real-time tasks at high priority Some scheduling misses are allowed Tasks have deadlines, but no analysis of compute time Linux, Win32, Mac OS X all support soft real-time Hard real-time Tasks specify a hard deadline that must be met Response time must be predictable No cache No secondary storage (disk) Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Model-predictive control (MPC) P l a n
1 Destination P l a n
2
Actual trajectory P la n 3
Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Definitions A task set may have Fixed-priority processes Dynamic-priority processes Scheduling may be performed Statically offline Dynamically online Scheduling may be preemptive or non-preemptive A task set is feasible if there exists a schedule A scheduler is optimal if it can schedule any feasible task set Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Periodic real-time processes Assumptions Processes wake up at periodic intervals Relative deadline is bounded by the period No non-preemptable resources for now Rate-monotonic scheduling Fixed priority processes Process priority: 1/period Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Rate-monotonic scheduling Process 1 Period: 2 Duration: 1 Process 2 Period: 7 Duration: 2 0 1 2 3 4 5 6 7 Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Scheduling metrics Some metrics Schedulability Jitter Behavior under overload RM is optimal Used in Space Station Freedom FAA advanced automation system Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Dynamic priority processes Assumptions Periodic processes The deadline of a process is bounded by its period Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Earliest deadline first The priority of a process is its absolute deadline Arrival time + relative deadline (period) No non-preemptable resources Preemptive scheduling Process 1 Period: 2 Duration: 1 Process 2 Period: 7 Duration: 2 0 1 2 3 4 5 6 7 Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Earliest deadline first Optimal Difficult to implement in many systems Poor behavior for (transiently) overloaded systems Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Priority inversion Two processes share a common resource Priority inversion occurs when a high-priority process is blocked by a low-priority process A low-priority producer may block a high-priority consumer even if the buffer is not empty Actuator Producer Consumer Buffer Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Unbounded wait Priority Code Task A H ...P(S)...V(S)... Task B M .... Task C L ...P(S)...V(S)... P(S) V(S) P(S) V(S) A B C Blocked Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Priority inheritance protocol Assumptions Resources are non-preemptable Guarded by binary semaphores When a high-priority process P H blocks on a semaphore help by low-priority process P L P L inherits the priority of P H When P L release the semaphore, it resumes with its original priority Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Priority Inheritance protocol blocked Priority Code Task A H ...P(S1)...P(S2)...V(S2)...V(S1)... Task B M ...P(S1)...V(S1)... Task C L ...P(S2)...V(S2)... P(S2) V(S2) P(S1) V(S1) P(S1) P(S2) V(S1,S2) A B C Running with priority H Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Deadlock Priority Code Task A H ...P(S1)...P(S2)... Task B L ...P(S2)...P(S1)... P(S2) P(S1) P(S1) P(S2) A B deadlock blocked Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Priority Ceiling Protocol Assumptions Periodic fixed-priority processes Non-preemptable resources guarded by semaphores Intuition Block processes early to avoid priority inversion Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Priority Ceiling Protocol Define a priority ceiling for binary semaphores The priority of the highest priority process that can execute a lock operation on the semaphore Lock is granted only if the locking processes priority is greater than the ceiling of all other locked semaphores If a lock operation blocks, the process holding the semaphore inherits the priority of the blocked process for the duration Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences PCP Example Task A H ...P(S1)...V(S1)... Task B M ...P(S2)...P(S3)...V(S3)...V(S2)... Task C L ...P(S3)...P(S2)...V(S2)...V(S3)... Run with B's priority Blocked on S3 P(S2) Get S2 P(S3) V(S3) Run with original priority P(S3) P(S2) V(S2) V(S3) P(S1) V(S1) Ceil(S1) = H Ceil(S2) = Ceil(S3) = M A B C Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences Example Mars Pathfinder mission (July 4, 1997) VxWorks (real-time OS), preemptive priority scheduling of threads (e.g., RMS) Priority inversion involving three threads: Information bus task (T1), meteorological data gathering task (T3), communication task (T2). Priority order: T1>T2>T3 Shared resource: information bus (used mutex) Findings: Priority ceiling protocol was found to be disabled initially, then it was enabled online and the problem was corrected Computing Systems http://mojave.caltech.edu/cs134/a/ October 19, 2006 C A L I F O RNIA INSTITUTE OF TECHN O I L O G Y If this page displays slowly, try turning off the smooth line art option in Acrobat, under Edit->Preferences PCP properties PCP is deadlock free But delay bound is hard to compute