Aperiodic Task Scheduling

Similar documents
Real Time Scheduling Basic Concepts. Radek Pelánek

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

Priority-Driven Scheduling

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

Embedded System Design: Embedded Systems Foundations of Cyber-Physical Systems

Commonly Used Approaches to Real-Time Scheduling

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

Periodic Task Scheduling

Scheduling Real-time Tasks: Algorithms and Complexity

Common Approaches to Real-Time Scheduling

Lecture 3 Theoretical Foundations of RTOS

4. Fixed-Priority Scheduling

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

Scheduling Aperiodic and Sporadic Jobs in Priority- Driven Systems

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

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

Real- Time Scheduling

Multi-core real-time scheduling

Classification - Examples

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

Aperiodic Task Scheduling

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

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

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

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

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

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

Predictable response times in event-driven real-time systems

Scheduling Single Machine Scheduling. Tim Nieberg

Real-time scheduling algorithms, task visualization

REAL TIME OPERATING SYSTEMS. Lesson-10:

Real-Time Scheduling 1 / 39

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

Middleware. Peter Marwedel TU Dortmund, Informatik 12 Germany. technische universität dortmund. fakultät für informatik informatik 12

REAL TIME OPERATING SYSTEMS. Lesson-18:

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

The simple case: Cyclic execution

ICS Principles of Operating Systems

CPU Scheduling. CPU Scheduling

Operating Systems. III. Scheduling.

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

BASIC CONCEPTS OF REAL TIME OPERATING SYSTEMS

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

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

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

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

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

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

Embedded & Real-time Operating Systems Communication Libraries

Global Multiprocessor Real-Time Scheduling as a Constraint Satisfaction Problem

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

Processor Scheduling. Queues Recall OS maintains various queues

Scheduling Shop Scheduling. Tim Nieberg

Embedded Systems. 6. Real-Time Operating Systems

CHAPTER 4: SOFTWARE PART OF RTOS, THE SCHEDULER

W4118 Operating Systems. Instructor: Junfeng Yang

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

Job Scheduling Model

Efficient Scheduling of Sporadic, Aperiodic, and Periodic Tasks with Complex Constraints

Off-line Optimal Multiprocessor Scheduling of Dependent Periodic Tasks

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

CPU Scheduling Outline

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

Exercises : Real-time Scheduling analysis

AN APPROPRIATE ENGINEERING APPROACH

Methods and Tools For Embedded Distributed System Scheduling and Schedulability Analysis

Embedded & Real-time Operating Systems

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

Quality of Service su Linux: Passato Presente e Futuro

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

OPERATING SYSTEMS SCHEDULING

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

Chapter 5 Process Scheduling

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

Scheduling Algorithms for Real-Time Systems

Attaining EDF Task Scheduling with O(1) Time Complexity

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Dispatching Domains for Multiprocessor Platforms and their Representation in Ada

Embedded System Design: Embedded Systems Foundations of Cyber-Physical Systems

Embedded System Design (Embedded Systems Foundations of Cyber-Physical Systems)

Hard Real-Time Reconfiguration Port Scheduling

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

Online Scheduling for Cloud Computing and Different Service Levels

A Comparative Study of Scheduling Algorithms for Real Time Task

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

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

Transcription:

Aperiodic Task Scheduling Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund, Informatik 12 Germany Springer, 2010 2014 年 11 月 19 日 These slides use Microsoft clip arts. Microsoft copyright restrictions apply.

Structure of this course Application Knowledge 2: Specification 3: ES-hardware 4: system software (RTOS, middleware, ) Design repository 6: Application mapping 7: Optimization 5: Evaluation & validation & (energy, cost, performance, ) Design 8: Test Numbers denote sequence of chapters - 2 -

Real-time scheduling Assume that we are given a task graph G=(V,E). Def.: A schedule S of G is a mapping V D t of a set of tasks V to start times from domain D t. G=(V,E) V1 V2 V3 V4 S D t t Typically, schedules have to respect a number of constraints, incl. resource constraints, dependency constraints, deadlines. Scheduling = finding such a mapping. - 3 -

Hard and soft deadlines Def.: A time-constraint (deadline) is called hard if not meeting that constraint could result in a catastrophe [Kopetz, 1997]. All other time constraints are called soft. We will focus on hard deadlines. - 4 -

Periodic and aperiodic tasks Def.: Tasks which must be executed once every T units of time are called periodic tasks. T is called their period. Each execution of a periodic task is called a job. Def.: Tasks requesting the processor at unpredictable times are called sporadic, if there is a minimum separation between the times at which they request the processor. All other tasks are called aperiodic. - 5 -

Preemptive and non-preemptive scheduling Non-preemptive schedulers: Jobs are executed until they are done. Response time for external events may be quite long. Preemptive schedulers: To be used if - some tasks have long execution times or - if the response time for external events to be short. - 6 -

Dynamic/online scheduling Dynamic/online scheduling: Processor allocation decisions (scheduling) at run-time; based on the information about the tasks arrived so far. - 7 -

Static/offline scheduling Static/offline scheduling: Scheduling taking a priori knowledge about arrival times, execution times, and deadlines into account. Dispatcher allocates processor when interrupted by timer. Timer controlled by a table generated at design time. Start Task 1 Start Task 3 Start Task 2-8 -

Time-triggered systems (1) In an entirely time-triggered system, the temporal control structure of all tasks is established a priori by off-line support-tools. This temporal control structure is encoded in a Task-Descriptor List (TDL) that contains the cyclic schedule for all activities of the node. This schedule considers the required precedence and mutual exclusion relationships among the tasks such that an explicit coordination of the tasks by the operating system at run time is not necessary... The dispatcher is activated by the synchronized clock tick. It looks at the TDL, and then performs the action that has been planned for this instant [Kopetz]. Start Task 1 Start Task 3 Start Task 2-9 -

Time-triggered systems (2) pre-run-time scheduling is often the only practical means of providing predictability in a complex system. [Xu, Parnas]. It can be easily checked if timing constraints are met. The disadvantage is that the response to sporadic events may be poor. - 10 -

Centralized and distributed scheduling Mono- and multi-processor scheduling: - Simple scheduling algorithms handle single processors, - more complex algorithms handle multiple processors. algorithms for homogeneous multi-processor systems algorithms for heterogeneous multi-processor systems (includes HW accelerators as special case). Centralized and distributed scheduling: Multiprocessor scheduling either locally on 1 or on several processors. - 11 -

Schedulability Set of tasks is schedulable under a set of constraints, if a schedule exists for that set of tasks & constraints. Exact tests are NP-hard in many situations. Sufficient tests: sufficient conditions for schedule checked. Necessary tests: checking necessary conditions. Used to show no schedule exists. There may be cases in which no schedule exists & we cannot prove it. sufficient schedulable necessary - 12 -

Classical scheduling algorithms for aperiodic systems Graphics: Alexandra Nolte, Gesine Marwedel, 2003 These slides use Microsoft clip arts. Microsoft copyright restrictions apply.

Aperiodic scheduling: - Scheduling with no precedence constraints - Let {τ i } be a set of tasks. Let: c i be the execution time of τ i, d i be the absolute deadline I will use deadline in this case when we have only aperiodic tasks r i be the arrival time or release time l i be the laxity or slack initially defined as l i = d i - c i - r i for a time t [r i ; d i ] the current laxity is defined as l i t = d i t c i t where c i (t) is the remaining execution time of task τ i at time t f i be the finishing time. - 14 -

Cost functions Cost function: Different algorithms aim at minimizing different functions. Def.: Maximum lateness = max all tasks (completion time deadline) Is <0 if all tasks complete before deadline. Task 1 Task 2 t - 15 -

Uniprocessor with equal arrival times Preemption is useless. Earliest Due Date (EDD): Execute task with earliest due date (deadline) first. f i f i f i EDD requires all tasks to be sorted by their (absolute) deadlines. Hence, its complexity is O(n log(n)). - 16 -

Optimality of EDD EDD is optimal for minimizing the maximum lateness: Given a set of n independent tasks, any algorithm that executes the tasks in order of non-decreasing (absolute) deadlines is optimal with respect to minimizing the maximum lateness. Proof (See Buttazzo, 2002): Let S be a schedule produced by any algorithm A If S the schedule of EDD τ a, τ b, d a d b, τ b immediately precedes τ a in S. Let S' be the schedule obtained by exchanging τ a and τ b. - 17 -

Exchanging τ a and τ b cannot increase lateness Max. lateness for τ a and τ b in S is L max (a,b)=f a -d a Max. lateness for τ a and τ b in S' is L' max (a,b)=max(l' a, L' b ) Two possible cases 1. L' a L' b : L' max (a,b) = f' a d a < f a d a = L max (a,b) since T a starts earlier in schedule S'. 2. L' a < L' b : L' max (a,b) = f' b d b = f a d b f a d a = L max (a,b) since f a =f' b and d a d b L' max (a,b) L max (a,b) S S' τ b τ a τ a τ b f a =f' b - 18 -

EDD is optimal Any schedule S with lateness L can be transformed into an EDD schedule S n with lateness L n L, which is the minimum lateness. EDD is optimal for minimizing the maximum lateness (q.e.d.) EDD is optimal for meeting the deadlines Note that EDD is not always optimal for other cost functions - 19 -

Sufficient and Necessary Schedulability Tests for EDD A set of aperiodic tasks arriving at the same time (says, 0) is schedulable (by EDD) if and only if o Proof for if: this simply comes from the evaluation of EDD o Proof for only if: this simply comes from the fact that the demand must be no more than the available time - 20 -

Earliest Deadline First (EDF): - Horn s Theorem - Different arrival times: Preemption potentially reduces lateness. Theorem [Horn74]: Given a set of n independent tasks with arbitrary arrival times, any algorithm that at any instant executes the task with the earliest absolute deadline among all the ready tasks is optimal with respect to minimizing the maximum lateness. - 21 -

Earliest Deadline First (EDF): - Algorithm - Earliest deadline first (EDF) algorithm: Each time a new ready task arrives: It is inserted into a queue of ready tasks, sorted by their absolute deadlines. Task at head of queue is executed. If a newly arrived task is inserted at the head of the queue, the currently executing task is preempted. Straightforward approach with sorted lists (full comparison with existing tasks for each arriving task) requires run-time O(n 2 ); (less with binary search or bucket arrays). Sorted queue Executing task - 22 -

Earliest Deadline First (EDF): Example - τ 1 τ 2 τ 3 τ 1 τ 2 τ 3 Earlier deadline preemption Later deadline no preemption - 23 -

Optimality of EDF To be shown: EDF minimizes maximum lateness. Proof (Buttazzo, 2002): Let S be a schedule produced by generic schedule A Let S EDF : schedule produced by EDF Preemption allowed: tasks executed in disjoint time intervals S divided into time slices of 1 time unit each Time slices denoted by [t, t+1) Let S(t): task executing in [t, t+1) Let E(t): the unfinished task which, at time t, has the earliest absolute deadline Let t E (t): time ( t) at which the next slice of task E(t) begins its execution in schedule S - 24 -

Optimality of EDF (2) If S S EDF, then there exists time t: S(t) E(t) Idea: swapping S(t) and E(t) cannot increase max. lateness. τ 1 τ 2 τ 3 τ 1 τ 2 τ 3 [Buttazzo, - 2002] 25 -

Optimality of EDF (3) Algorithm interchange: { for (t=0 to D-1) { if (S(t) E(t)) { S(t E (t)) = S(t); S(t) = E(t); }}} Using the same argument as in the proof of EDD, it is easy to show that swapping cannot increase maximum lateness; hence EDF is optimal for minimizing the maximum lateness. Does interchange preserve schedulability? Yes, the argument is the same as the case with EDD. q.e.d. [Buttazzo, 2002] - 26 -

Sufficient and Necessary Schedulability Tests for EDF A set of aperiodic tasks is schedulable (by EDF) if and only if o Proof for only if (necessary test): this simply comes from the fact that the demand must be no more than the available time o Proof for if (sufficient test) - 27 -

Proof: Sufficient Schedulability Test for EDF Proof by contrapositive: Suppose that EDF schedule does not meet the deadline Let task τ k be the first task which misses its absolute deadline d k Let t 0 be the last instant before d k, at which either the processor is idle or the processor executes a task with absolute deadline larger than d k By EDF, t 0 must be an arrival time of a job, called τ i Therefore, t 0 is equal to r i Due to the deadline miss of τ k, the processor must be busy between r i and d k The processor executes only the jobs arriving no earlier than r i and with absolute deadline less than or equal to d k Therefore, we conclude the proof by showing that - 28 -

Least laxity (LL), Least Slack Time First (LST) Priorities = decreasing function of the laxity (lower laxity higher priority); changing priority; preemptive. τ 1 τ 2 τ 3 l 1 15 =33-15-6=12 l 3 15 =29-15-2=12 τ 1 τ 2 τ 3 τ l 1 4 =33-4-6=23 1 l 2 4 =29-4-3=21 l 1 5 =33-5-6=22 l 2 5 =28-5-3=21 l 3 5 =29-5-10=14 l 1 13 =33-13-6=14 l 2 13 =28-13-2=13 l 3 13 =29-13-2=14 l 1 16 =33-16-6=11 l 3 16 =29-16-1=12-29 -

Properties Not sufficient to call scheduler & re-compute laxity just at task arrival times. Overhead for calls of the scheduler. Many context switches. Detects missed deadlines early. LL is also an optimal scheduling for mono-processor systems to meet the deadlines. Dynamic priorities cannot be used with a fixed prio OS. LL scheduling requires the knowledge of the execution time. - 30 -

Scheduling without preemption (1) Lemma: If preemption is not allowed, optimal schedules may have to leave the processor idle at certain times. Proof: Suppose: optimal schedulers never leave processor idle. - 31 -

Scheduling without preemption (2) τ 1 : periodic, available at times 4*n, c 1 = 2, T 1 = 4, D 1 = 4 τ 2 : periodic, available at times 4*n+1, c 2 = 1, T 1 = 4, D 2 = 1 τ 1 has to start at t =0 deadline missed, but schedule is possible (start τ 2 first) scheduler is not optimal contradiction! q.e.d. τ 1 τ 2-32 -

Scheduling without preemption Preemption not allowed: optimal schedules may leave processor idle to finish tasks with early deadlines arriving late. Knowledge about the future is needed for optimal scheduling algorithms No online algorithm can decide whether or not to keep idle. EDF is optimal among all scheduling algorithms not keeping the processor idle at certain times. If arrival times are known a priori, the scheduling problem becomes NP-hard in general. B&B typically used. - 33 -

Summary Hard vs. soft deadlines Static vs. dynamic TT-OS Schedulability Classical scheduling Aperiodic tasks No precedences - Simultaneous ( EDD) & Asynchronous Arrival Times ( EDF, LL) - No preemption (brief) - 34 -