Lecture 13. Real-Time Scheduling. Daniel Kästner AbsInt GmbH 2013

Similar documents
Embedded Systems Development

Networked Embedded Systems WS 2016/17

Real-Time Systems. Event-Driven Scheduling

Task Models and Scheduling

Embedded Systems 15. REVIEW: Aperiodic scheduling. C i J i 0 a i s i f i d i

Non-Preemptive and Limited Preemptive Scheduling. LS 12, TU Dortmund

Real-Time Systems. Event-Driven Scheduling

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

Real-Time Scheduling. Real Time Operating Systems and Middleware. Luca Abeni

CIS 4930/6930: Principles of Cyber-Physical Systems

Real-Time and Embedded Systems (M) Lecture 5

Aperiodic Task Scheduling

Clock-driven scheduling

3. Scheduling issues. Common approaches 3. Common approaches 1. Preemption vs. non preemption. Common approaches 2. Further definitions

Scheduling Periodic Real-Time Tasks on Uniprocessor Systems. LS 12, TU Dortmund

Andrew Morton University of Waterloo Canada

Lecture 6. Real-Time Systems. Dynamic Priority Scheduling

Real-Time Scheduling and Resource Management

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

Scheduling Algorithms for Multiprogramming in a Hard Realtime Environment

Real-Time Scheduling

There are three priority driven approaches that we will look at

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

Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

RUN-TIME EFFICIENT FEASIBILITY ANALYSIS OF UNI-PROCESSOR SYSTEMS WITH STATIC PRIORITIES

Bounding the End-to-End Response Times of Tasks in a Distributed. Real-Time System Using the Direct Synchronization Protocol.

Embedded Systems 14. Overview of embedded systems design

Real-Time Systems. Lecture #14. Risat Pathan. Department of Computer Science and Engineering Chalmers University of Technology

Scheduling. Uwe R. Zimmer & Alistair Rendell The Australian National University

EDF Feasibility and Hardware Accelerators

Real-Time Systems. LS 12, TU Dortmund

CEC 450 Real-Time Systems

Design of Real-Time Software

Schedulability of Periodic and Sporadic Task Sets on Uniprocessor Systems

Priority-driven Scheduling of Periodic Tasks (1) Advanced Operating Systems (M) Lecture 4

Non-preemptive Fixed Priority Scheduling of Hard Real-Time Periodic Tasks

CPU SCHEDULING RONG ZHENG

Paper Presentation. Amo Guangmo Tong. University of Taxes at Dallas January 24, 2014

Schedulability analysis of global Deadline-Monotonic scheduling

Static priority scheduling

Real-time Systems: Scheduling Periodic Tasks

Scheduling Slack Time in Fixed Priority Pre-emptive Systems

System Model. Real-Time systems. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

Schedulability Analysis for the Abort-and-Restart Model

Schedulability and Optimization Analysis for Non-Preemptive Static Priority Scheduling Based on Task Utilization and Blocking Factors

IN4343 Real Time Systems April 9th 2014, from 9:00 to 12:00

Multiprocessor Scheduling of Age Constraint Processes

Lec. 7: Real-Time Scheduling

Optimal Utilization Bounds for the Fixed-priority Scheduling of Periodic Task Systems on Identical Multiprocessors. Sanjoy K.

EDF Scheduling. Giuseppe Lipari May 11, Scuola Superiore Sant Anna Pisa

A Theory of Rate-Based Execution. A Theory of Rate-Based Execution

Online Energy-Aware I/O Device Scheduling for Hard Real-Time Systems with Shared Resources

Deadline-driven scheduling

CSE 380 Computer Operating Systems

Probabilistic Preemption Control using Frequency Scaling for Sporadic Real-time Tasks

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

Real Time Operating Systems

Real Time Operating Systems

EDF Scheduling. Giuseppe Lipari CRIStAL - Université de Lille 1. October 4, 2015

Improved Priority Assignment for the Abort-and-Restart (AR) Model

Rate Monotonic Analysis (RMA)

A Note on Modeling Self-Suspending Time as Blocking Time in Real-Time Systems

Real-Time Systems. Lecture 4. Scheduling basics. Task scheduling - basic taxonomy Basic scheduling techniques Static cyclic scheduling

Non-Work-Conserving Non-Preemptive Scheduling: Motivations, Challenges, and Potential Solutions

On-line scheduling of periodic tasks in RT OS

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CEC 450 Real-Time Systems

Lecture 4. Finite Automata and Safe State Machines (SSM) Daniel Kästner AbsInt GmbH 2012

Tardiness Bounds under Global EDF Scheduling on a Multiprocessor

Scheduling Lecture 1: Scheduling on One Machine

AS computer hardware technology advances, both

Multiprocessor Scheduling I: Partitioned Scheduling. LS 12, TU Dortmund

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

Bounding the Maximum Length of Non-Preemptive Regions Under Fixed Priority Scheduling

Multiprocessor Scheduling II: Global Scheduling. LS 12, TU Dortmund

Scheduling Lecture 1: Scheduling on One Machine

Static-Priority Scheduling. CSCE 990: Real-Time Systems. Steve Goddard. Static-priority Scheduling

Lecture: Workload Models (Advanced Topic)

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

A 2-Approximation Algorithm for Scheduling Parallel and Time-Sensitive Applications to Maximize Total Accrued Utility Value

The Concurrent Consideration of Uncertainty in WCETs and Processor Speeds in Mixed Criticality Systems

Periodic scheduling 05/06/

On the Soft Real-Time Optimality of Global EDF on Multiprocessors: From Identical to Uniform Heterogeneous

Exam Spring Embedded Systems. Prof. L. Thiele

Real-Time Workload Models with Efficient Analysis

Segment-Fixed Priority Scheduling for Self-Suspending Real-Time Tasks

Module 5: CPU Scheduling

Approximation Algorithms for scheduling

Chapter 6: CPU Scheduling

Cyclic Schedules: General Structure. Frame Size Constraints

Lecture Note #6: More on Task Scheduling EECS 571 Principles of Real-Time Embedded Systems Kang G. Shin EECS Department University of Michigan

A Dynamic Real-time Scheduling Algorithm for Reduced Energy Consumption

Bursty-Interference Analysis Techniques for. Analyzing Complex Real-Time Task Models

Selected solutions for. TDDD07 Real-time Systems

Scheduling I. Today Introduction to scheduling Classical algorithms. Next Time Advanced topics on scheduling

Schedulability Analysis for the Abort-and-Restart (AR) Model

Resource-locking durations in EDF-scheduled systems

Simulation of Process Scheduling Algorithms

Fixed Priority Scheduling

Resource Sharing Protocols for Real-Time Task Graph Systems

Transcription:

Lecture 3 Real-Time Scheduling Daniel Kästner AbsInt GmbH 203

Model-based Software Development 2 SCADE Suite Application Model in SCADE (data flow + SSM) System Model (tasks, interrupts, buses, ) SymTA/S Generator System-level Schedulability Analysis Astrée ait StackAnalyzer void Task (void) { variable++; function(); next++: if (next) do this; terminate() } Compiler Runtime Error Analysis C-Code Binary Code Worst-Case Execution Time Analysis Stack Usage Analysis

3 Setting the scene Hard real-time systems can be designed as a set of cooperating sequential processes (tasks). Questions: In which order to execute tasks? How to deal with shared resources? How to guarantee timely execution?

The Endless Loop 4 Do forever request input device; fetch input value; do computation; request output device; write output; End

The Basic Cyclic Executive 5 Let three procedures A, B, and C be given. Do forever call A; call B; call C; End

The Time-Driven Cyclic Executive 6 Let three procedures A, B, and C be given. Do forever wait for timer interrupt; call A; call B; call C; End The rate of hardware timer interrupts is the rate at which the procedures (tasks) must execute.

Multi-Rate Cyclic Executive Let the following task system be given: Task Period WCET A 5 5 B 5 4 C 30 3 D 30 2 Do forever // The major cycle wait for timer interrupt; //st minor cycle A; B; C; wait for timer interrupt; //2nd minor cycle A; B; D; E; wait for timer interrupt; //3rd minor cycle A; B; C; wait for timer interrupt; //4th minor cycle A; B; D; End E 60 7 Procedures are mapped onto a set of minor cycles that together constitute the complete schedule (or major cycle).

8 The Cyclic Executive Naive, but common way to implement concurrent hard real-time systems. No actual processes exist at run-time; each minor cycle is just a sequence of procedure calls Procedures share a common address space and can thus pass data between themselves. Concurrent access is not possible, thus no protection (e.g. semaphores) required. All process periods must be a multiple of the minor cycle time.

9 The Cyclic Executive Simple process modell: Application consists of fixed set of processes All processes are periodic All processes are independent from each other Context-switching times and other overhead is ignored All processes have a deadline equal to their period All processes have known worst-case execution time

0 The Cyclic Executive - Problems System is deterministic, but only fully so for the first task (at begin of major/minor cycle). All later tasks start to run whenever the preceding ones have ended. Hardware devices are polled. If they are not polled frequently enough, important events might be missed. If they are polled too frequently, processing power is wasted. Difficult to incorporate processes with long periods. If procedures are split up to form tasks with lower execution times, finding the right granularity of processes is difficult. Code for logically independent tasks is interleaved. Sporadic activities cannot be incorporated. Difficult to construct (NP complete) and difficult to maintain.

The Scheduling Problem: Classification Scheduling problems usually are classified according to a set of criteria: the cost function hard deadlines vs. soft deadlines periodic vs. aperiodic vs. sporadic events preemptive vs. non-preemptive static vs. dynamic online vs. offline

2 The Scheduling Problem: Classification Tasks which must be executed once every p units of time are called periodic, and p is called their period. Each execution of a periodic task is called a job. Tasks which are not periodic are called aperiodic. Aperiodic 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. A preemptive scheduler can arbitrarily suspend a process s execution and restart it later without affecting the functional behavior of the process. Preemption typically occurs when a higher priority process becomes runnable. Non-preemptive schedulers do not suspend processes in this way.

3 The Scheduling Problem: Classification An offline scheduling algorithm makes all scheduling decisions prior to the running of the system. Online scheduling algorithms schedule tasks at run-time; they can be either static or dynamic. In a static scheduling algorithm calculating the schedules is based on a process s characteristics available before the system is run. It requires little runtime overhead. A dynamic method schedules at run-time, taking into account both process characteristics and the current state of the system. It has higher run-time cost but can deal with non-predicted events and can give greater processor utilization.

The Task Model 4 Let = { T i } be a set of tasks. Then let r i be the release time (or arrival time) which is the time at which T i is ready for processing c i be the worst-case execution time of T i d i be the deadline interval, ie the time between T i becoming available and the time until which T i has to finish execution l i = d i -c i be the laxity or slack of T i. In { T i } precedence constraints among tasks may be defined. T i T j means that the processing of T i must be completed before T j can be started. Release of task T i d i c i l i t

Task Model 5 The following parameters can be calculated from a given schedule: Completion Time C i Response Time R i =C i r i Lateness L i =C i d i Tardiness D i =max { C i d i, 0 } Some performance measures / goal functions: Schedule Length (makespan) C max =max{ C i } Maximum Lateness L max = max{ L i } Critical instant: That time at which the release of a task will produce the largest response time. Scheduling to minimize the makespan with release times and deadlines is NP hard.

Overview 6 Static-Priority Scheduling (Fixed-priority Scheduling) Dynamic-Priority Scheduling Schedulability and Response Time Analysis Further reading: Giorgio Buttazzo. Hard Real-Time Computing Systems. Predictable Scheduling Algorithms and Applications. 2nd Edition. Springer, 2005. Jane Liu. Real-Time Systems. Prentice Hall, 2000.

Fixed-Priority Scheduling 7 Under fixed-priority scheduling, different jobs of a task are assigned the same priority. A fixed-priority scheduling scheme S is optimal if the following criterion is satisfied: If any process can be scheduled with some fixed-priority assignment scheme, then the given process can also be scheduled with scheme S.

Rate Monotonic Scheduling 8 Let each process have a unique priority P i based on its period i. We assume that the shorter the period, the higher the priority, ie i < j P i > P j. Further assume d i = i for all tasks T i. Example schedule: T with =3 and c =0.5, T 2 with 2 =4 and c 2 = and T 3 with 3 =6 and c 3 =2. T T 2 T 3

9 Rate Monotonic Scheduling The priority of a process is derived from its temporal requirements, not its importance to the system, nor its integrity. Note: priority is lowest (least) priority. Task Period Priority P A 5 5 B 30 4 C 00 D 45 2 E 35 3 The schedulability depends on the period and the maximal computational requirements of each process.

Processor Utilization 20 Let = {T i } be a set of tasks. The utilization U of a task set is defined as N c i i i Corollary: If the utilization factor of a task set = { T i } i=..n is greater than one, the task set cannot be scheduled by any algorithm. PROOF: Let = 2... N be the product of all periods. If U>, then also U >, which can be written as: N c i i i / i is the number of times task T i is executed in the interval. (/ i )c i is the total computation time requested by T i in the interval. Thus: if the total demand in computation time is higher than the available processor time, there can be no feasible schedule for the task set. U

Processor Utilization 2 There exists a maximum value of U below which is schedulable and above which is not schedulable. This limit depends on the task set, ie. the relations among task s periods and on the algorithm used to schedule the tasks. Let U ub (,A) be this upper bound of the processor utilization factor for a task set under an algorithm A. When U=U ub (,A), fully utilizes the processor. Then is schedulable but an increase in computation time in any of the tasks will make the set infeasible. For a given algorithm A, the least upper bound U lub (A) is the minimum of the utilization factors over all task sets that fully utilize the processor: U ( A) min U (, A) lub ub Any task set whose processor utilization factor is below U lub (A) is schedulable by A With U lub schedulability can be easily verified!

Rate Monotonic Scheduling 22 Theorem [Liu and Layland]: A system of N independent, preemptable periodic tasks T i with d i = i can be feasibly scheduled on a processor according to the rate monotonic algorithm if its total utilization U is at most N U RM N(2 ) Note: U RM asymtotically approaches ln2 (69.3%). N U RM (N) 2 0.828 3 0.779 4 0.756 5 0.743 6 0.734

23 Example: Process Set A Process Period WCET c Priority P Utilization U T 50 2 0.240 T2 40 0 2 0.250 T3 30 0 3 0.333 The combined utilization is U=2/50+0/40+0/30=0.823. Since this is above the threshold for three processes (U RM (3)=0.78), this process set fails the utilization test. T T 2 T 3 0 0 20 30 40 50 60 Preempted Executing Deadline met Deadline missed

24 Example: Process Set B Process Period WCET c Priority P Utilization U T 80 32 0.400 T2 40 5 2 0.25 T3 20 5 3 0.250 The combined utilization is U=32/80+5/40+5/20=0.775. Since this is below the threshold for three processes (U RM (3)=0.78), this process set will meet all its deadlines. T T 2 T 3 0 0 20 30 40 50 60 Preempted Executing Deadline met Deadline missed 70 80

25 Example: Process Set C Process Period WCET c Priority P Utilization U A 80 40 0.500 B 40 0 2 0.250 C 20 5 3 0.250 The combined utilization is.0. Since this is above the threshold for three processes (U RM (3)=0.78), this process set fails the utilization test. Nevertheless the process set will meet all its deadlines. T T 2 T 3 0 0 20 30 40 50 60 Preempted Executing Deadline met Deadline missed 70 80

Critical Instants 26 Corollary: A critical instant for a task occurs whenever the task is released simultaneously with all higher-priority tasks. Let = { T i } i=..n be a set of periodic tasks, ordered by increasing periods, ie < 2 <... < n and, thus P >P 2 >...>P N and let n>i. T n T i R n =c n +2c i T n R n =c n +3c i T i Intuition: The response time of task T n is delayed by the interference of a task T i with higher priority. Advancing the release time of T i may increase the completion time of T n.

Optimality of Rate Monotonic Scheduling 27 Observation: If all tasks are feasible at their critical instants, then the task set is schedulable in any other condition. Theorem: If a task set is schedulable by an arbitrary fixed priority assignment, then it is also schedulable by RM. PROOF: Let T and T 2 be two periodic tasks with < 2. Assume that their priorities are not assigned according to RM, ie P 2 > P. At a critical instant, the schedule is feasible if the following inequality is satisfied: c c (Eq. ) 2 T T 2

Optimality of Rate Monotonic Scheduling 28 Now we want to show that T and T 2 are also schedulable with the RM priority scheme, ie when P > P 2. 2 Let m be the number of periods of T entirely contained in 2. Then two cases have to be distinguished: Case : The computation time c is short enough that all requests of T within the critical time zone of T 2 are completed before the second request of T 2. That is: c 2 - m T T 2 2 m

Optimality of Rate Monotonic Scheduling 29 T T 2 2 m Then the task set is schedulable if m ) c c (Eq. 2) ( 2 2 We have to show that Eq. Eq.2. c c (Eq. ) mc mc c 2 ( m ) c ( m ) c mc c c 2 2 mc 2 2 m mc 2 m c m c m, since m, since c 2 2 m

Optimality of Rate Monotonic Scheduling 30 T T 2 2 m Case 2: The execution of the last request of T in the critical time zone of T 2 overlaps the second request of T 2. That is: c 2 - m Then the task set obviously is schedulable, if mc c m (Eq. 3) 2 We have to show that Eq. Eq.3.

Optimality of Rate Monotonic Scheduling 3 T T 2 2 m Consider again Eq.. mc mc c c 2 c mc 2 2 mc m mc 2 (Eq. ) m, since m This directly shows mc c m (Eq. 3) 2

32 Deadline Monotonic Scheduling Let each process have a unique priority P i based on its relative deadline d i. Same as rate monotonic, if each task s relative deadline equals its period. We assume that the shorter the deadline, the higher the priority, ie d i < d j P i > P j. Example schedule: T with = d =3 and c =0.5, T 2 with 2 =4, d 2 =2 and c 2 = and T 3 with 3 =d 3 =6 and c 3 =2. T T 2 T 3

Schedulability Analysis 33 The rate monotonic schedulability test can be applied also to deadline monotonic scheduling, by reducing periods to relative deadlines: N ci N N(2 ) d However, this test significantly overestimates the workload on the processor. Observations: i i The worst-case processor demand occurs when all tasks are released at their critical instants. For each task T i the sum of its processing time and the interference (preemption) imposed by higher priority tasks must be less than or equal to its deadline d i.

Schedulability Analysis 34 Assume that tasks are ordered by increasing relative deadlines: i<j d i <d j P i >P j. Then a task set = { T i } i=..n is schedulable if the following condition is satisfied: i N : c I d i i where I i is a measure of the interference of T i, which can be computed as the sum of the processing times of all higher-priority tasks released before d i : i di I i c j j j i T k T i d i

Schedulability Analysis 35 T k T i d i Note that this test is sufficient but not necessary. I i is calculated by assuming that each higher-priority task exactly d interferes i times during the execution time of T i. However, j since T i may terminate earlier, the actual interference may be smaller. A sufficient and necessary schedulability test for DM must take the exact interleaving of higher-priority tasks into account for each process.