Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons



Similar documents
Aperiodic Task Scheduling

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

3. Scheduling issues. Common approaches /1. Common approaches /2. Common approaches / /13 UniPD / T. Vardanega 23/01/2013. Real-Time Systems 1

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

REAL TIME OPERATING SYSTEMS. Lesson-18:

Lecture 3 Theoretical Foundations of RTOS

Real Time Scheduling Basic Concepts. Radek Pelánek

Common Approaches to Real-Time Scheduling

Multi-core real-time scheduling

Real-time Scheduling of Periodic Tasks (1) Advanced Operating Systems Lecture 2

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Real-time scheduling algorithms, task visualization

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

ICS Principles of Operating Systems

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Dispatching Domains for Multiprocessor Platforms and their Representation in Ada

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Methods and Tools For Embedded Distributed System Scheduling and Schedulability Analysis

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Effective Scheduling Algorithm and Scheduler Implementation for use with Time-Triggered Co-operative Architecture

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Real-Time Scheduling 1 / 39

Operating System Aspects. Real-Time Systems. Resource Management Tasks

Periodic Task Scheduling

OPERATING SYSTEMS SCHEDULING

Classification - Examples

Tasks Schedule Analysis in RTAI/Linux-GPL

Real- Time Scheduling

CPU Scheduling. CPU Scheduling

CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.

BASIC CONCEPTS OF REAL TIME OPERATING SYSTEMS

Scheduling Real-time Tasks: Algorithms and Complexity

Commonly Used Approaches to Real-Time Scheduling

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

The simple case: Cyclic execution

Operating Systems, 6 th ed. Test Bank Chapter 7

OS OBJECTIVE QUESTIONS

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

Improved Handling of Soft Aperiodic Tasks in Offline Scheduled Real-Time Systems using Total Bandwidth Server

4. Fixed-Priority Scheduling

Processor Scheduling. Queues Recall OS maintains various queues

CPU Scheduling Outline

Operating Systems. III. Scheduling.

The Design and Implementation of Real-Time Schedulers in RED-Linux

Operating Systems Concepts: Chapter 7: Scheduling Strategies

174: Scheduling Systems. Emil Michta University of Zielona Gora, Zielona Gora, Poland 1 TIMING ANALYSIS IN NETWORKED MEASUREMENT CONTROL SYSTEMS

REAL TIME OPERATING SYSTEMS. Lesson-10:

SOFTWARE VERIFICATION RESEARCH CENTRE THE UNIVERSITY OF QUEENSLAND. Queensland 4072 Australia TECHNICAL REPORT. No Real-Time Scheduling Theory

Comparison between scheduling algorithms in RTLinux and VxWorks

How To Compare Real Time Scheduling To A Scheduled Scheduler On Linux On A Computer System With A Visualization System

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

Real-Time Task Scheduling for Energy-Aware Embedded Systems 1

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

W4118 Operating Systems. Instructor: Junfeng Yang

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Exercises : Real-time Scheduling analysis

Performance Comparison of RTOS

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

HARD REAL-TIME SCHEDULING: THE DEADLINE-MONOTONIC APPROACH 1. Department of Computer Science, University of York, York, YO1 5DD, England.

System Software and TinyAUTOSAR

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

Earliest Due Date (EDD) [Ferrari] Delay EDD. Jitter EDD

Chapter 5 Process Scheduling

Job Scheduling Model

Enhancing the Monitoring of Real-Time Performance in Linux

MultiPARTES. Virtualization on Heterogeneous Multicore Platforms. 2012/7/18 Slides by TU Wien, UPV, fentiss, UPM

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Off-line Optimal Multiprocessor Scheduling of Dependent Periodic Tasks

W4118 Operating Systems. Instructor: Junfeng Yang

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

CHAPTER 4: SOFTWARE PART OF RTOS, THE SCHEDULER

Applied Algorithm Design Lecture 5

Scheduling Single Machine Scheduling. Tim Nieberg

Parameters for Efficient Software Certification

Aperiodic Task Scheduling

Priority-Driven Scheduling

How to Perform Real-Time Processing on the Raspberry Pi. Steven Doran SCALE 13X

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

Transcription:

Today Intro to real-time scheduling Cyclic executives Scheduling tables Frames Frame size constraints Generating schedules Non-independent tasks Pros and cons

Real-Time Systems The correctness of a real-time system depends not just on the validity of results but on the times at which results are computed Computations have deadlines Usually, but not always, ok to finish computation early Hard real-time system: missed deadlines may be catastrophic Soft real-time system: missed deadlines reduce the value of the system Real-time deadlines are usually in the range of microseconds through seconds

Real-Time System Examples Hard real-time Most feedback control systems E.g. engine control, avionics, Missing deadlines affects stability of control Air traffic control Missing deadlines affects ability of airplanes to fly Soft real-time Windows Media Player Software DVD player Network router Games Web server Missing deadlines reduces quality of user experience

Real-Time Abstractions System contains n periodic tasks T 1,, T n T i is specified by (P i, C i, D i ) P is period C is worst-case execution cost D is relative deadline Task T i is released at start of period, executes for C i time units, must finish before D i time units have passed Often P i ==D i, and in this case we omit D i Intuition behind this model: Real-time systems perform repeated computations that have characteristic rates and response-time requirements What about non-periodic tasks?

Real Time Scheduling Given a collection of runnable tasks, the scheduler decides which to run If the scheduler picks the wrong task, deadlines may be missed Interesting schedulers: Fixed priorities Round robin Earliest deadline first (EDF) Many, many more exist A scheduler is optimal when, for a class of real-time systems, it can schedule any task set that can be scheduled by any algorithm

Real-Time Analysis Given: A set of real-time tasks A scheduling algorithm Is the task set schedulable? Yes all deadlines met, always No at some point a deadline might be missed No at some point a deadline might be missed Important: Answer this question at design time Other questions to ask: Where does worst-case execution cost come from? How close to schedulable is a non-schedulable task set? How close to non-schedulable is a schedulable task set? What happens if we change scheduling algorithms? What happens if we change some task s period or execution cost?

Cyclic Schedule This is an important way to sequence tasks in a realtime system We ll look at other ways later Cyclic scheduling is static computed offline and stored in a table For now we assume table is given Later look at constructing scheduling tables Task scheduling is non-preemptive No RTOS is required Non-periodic work can be run during time slots not used by periodic tasks Implicit low priority for non-periodic work Usually non-periodic work must be scheduled preemptively

Cyclic Schedule Table T(t k ) = T I i if if T i is to be scheduled at time t no periodic task is scheduled at time t k k Table executes completely in one hyperperiod H Then repeats H is least common multiple of all task periods N quanta per hyperperiod Multiple tables can support multiple system modes E.g., an aircraft might support takeoff, cruising, landing, and taxiing modes Mode switches permitted only at hyperperiod boundaries Otherwise, hard to meet deadlines

Example Consider a system with four tasks T 1 = (4,1) T 2 = (5, 1.8) T 3 = (20, 1) T 4 = (20, 2) Possible schedule: T 1 T 3 T 2 T 1 T 4 T 2 T 1 T 2 T 1 T 1 T 2 0 4 8 12 16 20 Table starts out with: (0, T 1 ), (1, T 3 ), (2, T 2 ), (3.8, I), (4, T 1 ),

Refinement: Frames We divide hyperperiods into frames Timing is enforced only at frame boundaries Each task is executed as a function call and must fit within a single frame Multiple tasks may be executed in a frame Frame size is f Number of frames per hyperperiod is F = H/f

Frame Size Constraints 1. Tasks must fit into frames So, f C i for all tasks Justification: Non-preemptive tasks should finish executing within a single frame 2. f must evenly divide H Equivalently, f must evenly divide P i for some task i Justification: Keep table size small

More Frame Size Constraints 3. There should be a complete frame between the release and deadline of every task Justification: Want to detect missed deadlines by the time the deadline arrives frame k frame k+1 frame k+2 t t t+f t+2f t +D i t+3f t +P i T i released Therefore: 2f gcd (P i, f) D i for each task i

Example Revisited Consider a system with four tasks T 1 = (4,1), T 2 = (5, 1.8), T 3 = (20, 1), T 4 = (20, 2) H = lcm (4,5,20) = 20 By Constraint 1: f 2 By Constraint 2: f might be 1, 2, 4, 5, 10, or 20 By Constraint 3: only 2 works T 1 T 3 T 2 T 1 T 4 T 2 T 1 T 2 T 1 T 1 T 2 0 4 8 12 16 20

Task Slices What if frame size constraints cannot be met? Example: T = { (4, 1), (5, 2, 7), (20, 5) } By Constraint 1: f 5 By Constraint 3: f 4 Solution: slice a task into smaller sub-tasks So (20, 5) becomes (20, 1), (20, 3), and (20, 1) Now f = 4 works What is involved in slicing?

Design Decision Summary Three decisions: Choose frame size Partition tasks into slices Place slices into frames In general these decisions are not independent

Cyclic Executive Pseudocode // L is the stored schedule current time t = 0; current frame k = 0; do forever accept clock interrupt; currentblock = L(k); t++; k = t mod F; if last task not completed, take appropriate action; execute slices in currentblock; sleep until next clock interrupt;

Practical Considerations Handling frame overrun Main issue: Should offending task be completed or aborted? How can we eliminate the possibility of overrun? Mode changes At hyperperiod boundaries How to schedule the code that figures out when it s time to change modes? Multiprocessor systems Similar to uniprocessor but table construction is more difficult Splitting tasks Painful and error prone

Computing a Static Schedule Problem: Derive a frame size and schedule meeting all constraints Solution: Reduce to a network flow problem Use constraints to compute all possible frame sizes For each possible size, try to find a schedule using network flow algorithm If flow has a certain value: A schedule is found and we re done Otherwise: Schedule is not found, look at the next frame size If no frame size works, system is not schedulable using cyclic executive

Network Flow Problem Given a graph of links, each with a fixed capacity, determine the maximum flow through the network Efficient algorithms exist

Flow Graph Definitions Denote all jobs in hyperperiod of F frames as J 1 J n Vertices: N job vertices J 1, J 2,, J N F frame vertices 1, 2,, F Edges: (source, J i ) with capacity C i Encodes jobs compute requirements (J i, x) with capacity f iff J i can be scheduled in frame x Encodes periods and deadlines (f, sink) with capacity f Encodes limited computational capacity in each frame

Flow Graph Illustration Jobs J i f Frames x Source C i f f y f f Sink C k f J k f z

Finding a Schedule Maximum attainable flow is Σ i=1..n C i Total amount of computation in the hyperperiod If a max flow is found with this amount then we have a schedule If a task is scheduled across multiple frames, we must slice it into subtasks Potentially difficult However, if we don t allow the algorithm to split tasks, the problem becomes NP-complete Common pattern in this sort of problem E.g. optimal bin packing becomes easy if we can split objects

Flow Graph Example Jobs J i h / f Frames x C i / C i (C i -h) / f h / f Source C k / C k J k C k / f 0 / f y z (C k +C i -h) / f 0 / f Sink This flow is telling us to split J i into two jobs, one in x and one in y, while J k executes entirely in y

Non-Independent Tasks Precedence constraints: T i must execute before T j Enforce these by adjusting tasks release times and deadlines Critical sections: T i must not be sliced in such a way that T j runs in the middle These make the problem of finding a schedule NP-hard

CE Advantages Main advantage: Cyclic executives are very simple you just need a table Table makes the system very predictable Can validate and test with very high confidence No race conditions, no deadlock No processes, no threads, no locks, Task dispatch is very efficient: just a function call Lack of scheduling anomalies

CE Disadvantages Cyclic executives are brittle any change requires a new table to be computed Release times of tasks must be fixed F could be huge Implies mode changes may have long latency All combinations of tasks that could execute together must be analyzed Slicing tasks into smaller units is difficult and errorprone

Summary Cyclic executive is one of the major software architectures for embedded systems Historically, cyclic executives dominate safety-critical systems Simplicity and predictability win However, there are significant drawbacks Finding a schedule might require significant offline computation