CPE555A: Real-Time Embedded Systems

Slides:



Advertisements
Similar presentations
EE5900 Advanced Embedded System For Smart Infrastructure
Advertisements

Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
REAL TIME SYSTEM Scheduling.
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
REAL TIME SYSTEMS – SCHEDULING ISSUES
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Dynamic Planning Based Scheduling.
1 Swiss Federal Institute of Technology Computer Engineering and Networks Laboratory Embedded Systems Exercise 2: Scheduling Real-Time Aperiodic Tasks.
Tasks Periodic The period is the amount of time between each iteration of a regularly repeated task Time driven The task is automatically activated by.
Module 2 Priority Driven Scheduling of Periodic Task
CSE 421 Algorithms Richard Anderson Lecture 6 Greedy Algorithms.
Deterministic Scheduling
EE 249, Fall Discussion: Scheduling Haibo Zeng Amit Mahajan.
Embedded Systems Exercise 3: Scheduling Real-Time Periodic and Mixed Task Sets 18. May 2005 Alexander Maxiaguine.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
Real-Time Operating System Chapter – 8 Embedded System: An integrated approach.
A Categorization of Real-Time Multiprocessor Scheduling Problems and Algorithms Presentation by Tony DeLuce CS 537 Scheduling Algorithms Spring Quarter.
More Scheduling cs550 Operating Systems David Monismith.
Module 2 Clock-Driven Scheduling
Task Scheduling By Dr. Amin Danial Asham.
Scheduling policies for real- time embedded systems.
Multiprocessor Real-time Scheduling Jing Ma 马靖. Classification Partitioned Scheduling In the partitioned approach, the tasks are statically partitioned.
CS Spring 2011 CS 414 – Multimedia Systems Design Lecture 31 – Multimedia OS (Part 1) Klara Nahrstedt Spring 2011.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Real-Time Scheduling CS 3204 – Operating Systems Lecture 20 3/3/2006 Shahrooz Feizabadi.
CS244-Introduction to Embedded Systems and Ubiquitous Computing Instructor: Eli Bozorgzadeh Computer Science Department UC Irvine Winter 2010.
Summary :-Distributed Process Scheduling Prepared By:- Monika Patel.
6. Application mapping 6.1 Problem definition
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems RMS and EDF Schedulers.
CS244-Introduction to Embedded Systems and Ubiquitous Computing Instructor: Eli Bozorgzadeh Computer Science Department UC Irvine Winter 2010.
Mapping: Applications  Processors
CSE 522 Real-Time Scheduling (2)
Module 2 Overview of Real Time System Scheduling
Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
Real time scheduling G.Anuradha Ref:- Stallings. Real time computing Correctness of the system depends not only on the logical result of computation,
Introduction to Embedded Systems Rabie A. Ramadan 5.
CSCI1600: Embedded and Real Time Software Lecture 23: Real Time Scheduling I Steven Reiss, Fall 2015.
Lecture 2, CS52701 The Real Time Computing Environment I CS 5270 Lecture 2.
CS Spring 2009 CS 414 – Multimedia Systems Design Lecture 31 – Process Management (Part 1) Klara Nahrstedt Spring 2009.
CS333 Intro to Operating Systems Jonathan Walpole.
For a good summary, visit:
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
CS Spring 2010 CS 414 – Multimedia Systems Design Lecture 32 – Multimedia OS Klara Nahrstedt Spring 2010.
Lecture 6: Real-Time Scheduling
Embedded System Scheduling
Lecture 12: Real-Time Scheduling
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Scheduling and Resource Access Protocols: Basic Aspects
Networks and Operating Systems: Exercise Session 2
EEE 6494 Embedded Systems Design
Lecture 24: Process Scheduling Examples and for Real-time Systems
CprE 458/558: Real-Time Systems
Real Time Scheduling Mrs. K.M. Sanghavi.
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Limited-Preemption Scheduling of Sporadic Tasks Systems
Richard Anderson Lecture 6 Greedy Algorithms
Richard Anderson Autumn 2016 Lecture 7
CSCI1600: Embedded and Real Time Software
NET 424: REAL-TIME SYSTEMS (Practical Part)
Richard Anderson Lecture 7 Greedy Algorithms
Richard Anderson Winter 2019 Lecture 7
Real-Time Process Scheduling Concepts, Design and Implementations
Richard Anderson Autumn 2015 Lecture 7
Ch 4. Periodic Task Scheduling
Real-Time Process Scheduling Concepts, Design and Implementations
Richard Anderson Autumn 2019 Lecture 7
Presentation transcript:

CPE555A: Real-Time Embedded Systems Lecture 6 Ali Zaringhalam Stevens Institute of Technology Spring 2015, arz CS555A – Real-Time Embedded Systems Stevens Institute of Technology 1

Outline Scheduling Earliest-Due-Date (EDD) Earliest-Deadline-First (EDF) Latest Deadline First (LDF) Rate Monotonic Scheduling (RMS) CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 2 2

The Scheduling Problem Input A set of n tasks Γ = {τ1, τ2, . . . , τn}, A set of m processors P = {P1, P2, . . . , Pm} A set of s types of resources R = {R1,R2, . . . , Rs} Constraints: timing (deadline), precedence Output Assigning processors from P and resources from R to tasks from Γ in order to complete all tasks under the specified constraints This problem, in its general form, has been shown to be computationally intractable To make the problem of constructing feasible schedules tractable, certain assumptions are made CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 3 3

Scheduling Classification - 1 Preemptive The running task can be interrupted at any time to assign the processor to another active task, according to a predefined scheduling policy Non-preemptive A task, once started, is executed by the processor until completion. All scheduling decisions are taken when the current task terminates its execution CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 4 4

Scheduling Classification - 2 Static Scheduling decisions are based on fixed parameters (e.g. priority), assigned to tasks before their activation Dynamic Scheduling decisions are based on dynamic parameters (e.g. priority) that may change during task execution CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 5 5

Scheduling Classification - 3 Off-line All tasks are known at start & never change The scheduling algorithm is executed on the entire task set before task activation The schedule is stored in a table and later executed by a dispatcher On-line Tasks can arrive at run time The scheduling decisions are taken at runtime every time a new task enters the system or when a running task terminates CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 6 6

Scheduling Classification - 4 Optimal An optimal schedule minimizes some given cost function defined over the task set If there is no cost function, then the only concern is to achieve a feasible schedule meeting deadlines An algorithm is said to be optimal with respect to feasibility if it is able to find a feasible schedule, if one exists Heuristic Uses a heuristic approach in taking its scheduling decisions A heuristic algorithm tends toward the optimal schedule, but does not guarantee finding it CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 7 7

Guarantee-Based Algorithms A dynamic scheduler with real-time deadline and admission control A new task arrives The task is accepted only if the deadlines of current tasks are unaffected CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 8 8

Example Scheduler Metrics CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 9 9

Earliest Due Date (EDD) Jackson’s algorithm A set of n aperiodic tasks A single processor Optimization metric Minimizing maximum lateness Lmax=Maxi(fi-di) Designation: 1 | sync | Lmax sync means that tasks arrive “synchronously”, at the same time Each task can have a different computation time and deadline But they all arrive at the same time CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 10 10

EDD Algorithm No random task arrival. All tasks arrive at the same time. Given a set of n independent tasks, any algorithm that executes the tasks in order of non-decreasing deadlines is optimal with respect to minimizing the maximum lateness Because all tasks arrive at the same time, preemption is not an issue The static priority assigned to each task is the deadline: the shorter the deadline, the higher the priority We can assume that all tasks arrive at t=0 Each task is characterized by computation time and deadline (C,d) CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 11 11

Proof of EDD Suppose there was a non-EDD schedule S. There must be two tasks a and b where a immediately precedes b but da > db. Why? The schedule can be improved to reduce maximum lateness by interchanging a and b No non-EDD schedule can do better in minimizing maximum lateness The complexity of the EDD algorithm is O(nxlogn): the complexity of the sorting algorithm Because if there were no such instance, then the schedule would be EDD. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 12 12

EDD & Non-EDD Schedules Note that fj=f’i because tasks execute consecutively Non-EDD Non-EDD: i finishes earlier but has a later deadline than j. In this example both fi-di and fj-dj are negative. EDD Two cases for possible value of L’max: L’max = f’i – di = fj-di <= fj – dj L’max = f’j – dj <= fj – dj The non-EDD Lmax = fj-dj So in both cases L’max <= Lmax So EDD is no worst than non-EDD Tasks are scheduled as soon as the CPU is available. There is no preemption. A task runs to completion. If the schedule is feasible, all deadlines are met and fi-di is negative for all i. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 13 13

Example 1 J1 J2 J3 J4 J5 fi 1 8 4 7 3 di 10 5 Li -2 -3 -1 J4 has maximum lateness = -1 Queue J2 J4 J3 J5 J1 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 14 14 Dequeue

EDD & Feasibility EDD produces a schedule which minimizes maximum lateness But it may not be a feasible schedule in the sense of meeting all deadlines So EDD cannot be relied upon to obtain a feasible schedule meeting all deadlines But if there does exist a feasible schedule, then EDD can find it From any feasible schedule you can use EDD to obtain another feasible schedule which minimizes maximum lateness Complexity of EDD O(nlogn) – A heap sorting algorithm CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 15 15

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Example 2 J1 J2 J3 J4 J5 fi 1 4 2 10 6 di 5 8 Li -1 -2 Deadline missed Queue J4 J5 J2 J3 J1 Dequeue CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 16 16

Dynamic Run-Time Scheduler The scheduler lets a task to continue to completion before scheduling another task There is no timer interrupt The scheduler is invoked by the ISR or the OS service call invoked by the user CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 17 17

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Typically a lower numerical value represents a higher priority By user Or by the scheduler to prevent starvation of lower-priority tasks Tasks are switched in and out when the timer interrupt kicks in and invokes the scheduler . A non-preemptive priority-based scheduler allows a task to complete. The next task to run is determined by priority. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 18 18

Earliest Deadline First (EDF) Horn’s algorithm N independent tasks with arbitrary arrival time. Tasks are not synchronous Preemption is allowed 1 | preemp | Lmax Optimization metric is the same as in EDD Minimizing maximum lateness Lmax=Maxi(fi-di) CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 19 19

CS555A – Real-Time Embedded Systems Stevens Institute of Technology EDF Algorithm 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. Complexity O(n2) if ready queue is a linear list O(nlogn) if the ready queue is implemented as a heap CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 20 20

CS555A – Real-Time Embedded Systems Stevens Institute of Technology EDF Proof At time t=4, the executing task J4 has a deadline of td=15. s(t)=arrival time; s(tE)=execution time. Task J2 arrives at t=4. The scheduler rethinks the existing schedule and makes changes. This is a non-EDF feasible schedule Maximum lateness is Lmax=0 associated with J1 Preemption is allowed: so break up time in slices. Tasks can execute in disjointed intervals Interchanging the execution of J4 and J2 at t=4 does not increase maximum lateness CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 21 21

CS555A – Real-Time Embedded Systems Stevens Institute of Technology EDF Proof - Continued After the interchange the resulting schedule is also feasible because the deadline of J4 is after the deadline associated with J2. Interchange the execution of J2 and J4 at t=4. Maximum lateness remains the same at L=0 for J1 Continue this in all time slices CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 22 22

Example Completed tasks None CS555A – Real-Time Embedded Systems Both J1 and J2 arrive at t=0. J1 is scheduled first because its deadline is (d1=2) < (d2=5). Completed tasks None CS555A – Real-Time Embedded Systems Stevens Institute of Technology CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 23 23

Example - Continued Completed tasks J1 J3 arrives at t=2. J3 has a deadline of d3=4 whereas the currently executing task J2 has a deadline of d2=5. Because d3 < d2, J2 is preempted and J3 is dispatched for execution. Completed tasks J1 preemption CS555A – Real-Time Embedded Systems Stevens Institute of Technology CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 24 24

Example - Continued Completed tasks J1 J4 arrives at t=3. Its deadline is d4=10. The earliest deadline is still d3=4. So J3 remains in execution. No preemption at t=3. Completed tasks J1 CS555A – Real-Time Embedded Systems Stevens Institute of Technology CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 25 25

Example - Continued Lmax = 0 Completed tasks J1 J2 J3 J5 arrives at t=6. Its deadline is d5=9. which is earlier than the d4=10 of J4 which is currently executing. So J4 is preempted and J5 is dispatched. Lmax = 0 Completed tasks J1 J2 J3 preemption CS555A – Real-Time Embedded Systems Stevens Institute of Technology CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 26 26

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Some Observations A schedule is computed at t=0 based on the ready tasks The schedule is re-examined only when a new task arrives You can view the task with the earliest deadline as having the highest priority If a feasible schedule (one that meets all deadlines) exists, EDF will find it. It also has the minimum lateness However an EDF schedule is not necessarily feasible (may not meet deadlines) CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 27 27

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 28 28

CS555A – Real-Time Embedded Systems Stevens Institute of Technology After task 1, task 4 has the earliest deadline but it cant’ be scheduled because it has a dependency on task 2 which must be scheduled first. So task 3 is the first EDF task meeting dependency requirements that can be scheduled. NO. Task 1: meets deadline d=2 Task 2: meets deadline d=5 Task 3: meets deadline d=4 Task 4: does NOT meet deadline d=3 Task 5: meets deadline d=5 Task 6: meets deadline d=6 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 29 29

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 30 30

CS555A – Real-Time Embedded Systems Stevens Institute of Technology LDF assumes a fixed, finite set of tasks with deadlines. No arrival of new tasks. No preemption. 6 Stack Push What’s nice about a leaf node is that no other task is dependent on it. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 31 31

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 32 32

CS555A – Real-Time Embedded Systems Stevens Institute of Technology 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 33 33

CS555A – Real-Time Embedded Systems Stevens Institute of Technology 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 34 34

CS555A – Real-Time Embedded Systems Stevens Institute of Technology 3 5 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 35 35

CS555A – Real-Time Embedded Systems Stevens Institute of Technology 4 3 5 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 36 36

CS555A – Real-Time Embedded Systems Stevens Institute of Technology 2 4 3 5 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 37 37

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Stack Pop 1 2 4 3 5 6 Stack Push CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 38 38

The complexity of LDF is O(n2). So it is also optimal with respect to feasibility. Why? The complexity of LDF is O(n2). CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 39 39

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 40 40

EDF With Precedence Assume all tasks arrive at ai=ri=0 All tasks require execution time ci=1 r4=0 c4=1 d4=3 r2=0 c2=1 d2=5 4 2 r5=0 c5=1 d5=5 5 r1=0 c1=1 d1=1 1 Rule of thumb for this strategy: the deadline of a task cannot exceed its own deadline or the minimum slack time of its dependent tasks. 3 r6=0 c6=1 d6=6 6 r3=0 c3=1 d3=4 CS555A – Real-Time Embedded Systems Stevens Institute of Technology ej is extecution time of task j 41 41

Timing Definitions - Continued /ri Start time si is the time at which a task starts its execution Finishing time fi is the time at which a task finishes its execution Response time Ri is the difference between the finishing time and the request time: Ri = fi − ri Lateness: Li = fi −di represents the delay of a task completion with respect to its deadline; note that if a task completes before the deadline, its lateness is negative Laxity or Slack time: Xi = di − ai − Ci is the maximum time a task can be delayed on its activation to complete within its deadline Xi = di − Ci when ai=0 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 42 42

EDF With Precedence Start with i=1 Tasks immediately depending on 1 d2-c2=4 d3-c3=3 d1’=min(1, min(4,3))=1 r2=0 c2=1 d2=5 r4=0 c4=1 d4=3 4 2 r5=0 c5=1 d5=5 5 r1=0 c1=1 d1’’=1 1 r3=0 c3=1 d3=4 3 Slack time: Xi = di − ai − Ci = di – Ci because ai = ri = 0 Rule of Thumb:The deadline of a task cannot exceed its own deadline or the minimum slack time of its dependent tasks. r6=0 c6=1 d6=6 6 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 43 43

EDF With Precedence Next select i=2 with d2=5 Tasks immediately depending on 2 D(2) = {4, 5} d4-c4=2 d5-c5=4 d2’=min(5, min(2,4))=2 r2=0 c2=1 d2’’=2 r4=0 c4=1 d4=3 4 2 r5=0 c5=1 d5=5 5 r1=0 c1=1 d1’’=1 1 r3=0 c3=1 d3=4 3 Slack time: Xi = di − ai − Ci = di – Ci because ai = ri = 0 Rule of Thumb:The deadline of a task cannot exceed its own deadline or the minimum slack time of its dependent tasks. r6=0 c6=1 d6=6 6 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 44 44

EDF With Precedence Next select i=3 with d3=4 Tasks immediately depending on 3 D(3) = {6} d6-c6=5 d3’=min(4, min(5))=4 r2=0 c2=1 d2’’=2 r4=0 c4=1 d4=3 4 2 r5=0 c5=1 d5=5 5 r1=0 c1=1 d1’’=1 1 r3=0 c3=1 d3’=4 3 Slack time: Xi = di − ai − Ci = di – Ci because ai = ri = 0 The deadline of a task cannot exceed its own deadline or the minimum slack time of its dependent tasks. r6=0 c6=1 d6=6 6 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 45 45

EDF With Precedence The remaining nodes are leaf nodes. No other task depends on them So their deadlines remain unchanged r2=0 c2=1 d2’’=2 r4=0 c4=1 d4’=3 4 2 r5=0 c5=1 d5’=5 5 r1=0 c1=1 d1’’=1 1 r3=0 c3=1 d3’=4 3 Slack time: Xi = di − ai − Ci = di – Ci because ai = ri = 0 The deadline of a task cannot exceed its own deadline or the minimum slack time of its dependent tasks. r6=0 c6=1 d6’=6 6 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 46 46

EDF With Precedence Now apply normal EDF: Task 1 Task 2 Task 4 Task 3 5 r1=0 c1=1 d1’’=1 1 r3=0 c3=1 d3’=4 3 r6=0 c6=1 d6’=6 6 EDF with precedence rationalizes deadlines. Instead of accepting the given deadline, the algorithm ensures that the assigned “virtual” deadlines take into account deadlines of successor. A task cannot have a later deadline than the minimum slack of its successors. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 47 47

Optimality EDF with precedence is optimal in the sense of minimizing maximum lateness A schedule obtained may not be feasible Tasks may not meet their deadline But if a feasible schedule exists, EDF with precedence will find it. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz 48 48

Periodic Tasks T A periodic task is a sequence of jobs that are released at times 0+fi, Ti +fi, 2 Ti +fi, … A periodic task ti is specified using the parameters Ti – period Ci – maximum execution time fi– phase or offset (almost always zero) Di – relative deadline (almost always Ti) CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Sporadic Tasks Sporadic tasks are characterized by a minimum inter-arrival time, rather than a fixed period (the earliest, the task arrives again) Minimum spacing is necessary to ensure execution within C (maximum execution time) Many of the analysis for periodic tasks apply to sporadic tasks if Ti is interpreted as the minimum time between arrivals CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Scheduling Points Scheduling point is where the scheduler must examine the schedule and make scheduling decisions This includes preemption of the currently running task For periodic tasks, the scheduler kicks in at the fixed period For sporadic tasks, the scheduler kicks in when tasks arrive CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Scheduling Assumptions - 1 The instances of a periodic task ti are regularly activated at a constant rate. The interval Ti between two consecutive activations is the period of the task All instances of a periodic task ti have the same worst-case execution time Ci All instances of a periodic task ti have the same relative deadline Di which is equal to the period Ti What’s relative deadline? CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Scheduling Assumptions - 2 All tasks in the task set are independent; that is, there are no precedence relations and no resource constraints No task can suspend itself, for example on I/O operations All tasks are released as soon as they arrive (ai=ri) All context-switching overheads are assumed to be zero CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Hyperperiod Or Major Cycle A periodic system schedule can be defined by giving a finite-length schedule that is repeated over and over. The length of the smallest such schedule is called the hyperperiod for that task set For a purely periodic task set, the hyperperiod is given by the Least Common Multiple of the periods Hyperperiod = LCM(Ti) for all i CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Harmonic Task Set A periodic task set is harmonic if Every period evenly divides all larger periods Every period is evenly divisible by all smaller periods The hyperperiod of a harmonic task set is equal to the largest task period (because it is the LCM!) Example: three tasks with periods 25, 50 and 100 100/50=2; 100/25=4; 50/25=2 100:50:25 = 4:2:1 Hyperperiod: 100 Scheduling algorithms may be simpler and more efficient for harmonic task sets CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Timeline Scheduling Time Line Scheduling It is an off-line static scheduling strategy Divide the time line into time slices for scheduling purposes Use the Greatest Common Divisor of the Task Periods as the time slice This is the same as the smallest period in a harmonic task set It is referred to as the Minor Cycle CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Example Three tasks with periods 25, 50, 100 Hyperperiod Must be scheduled every 25 units. Must be scheduled every 50 units. Must be scheduled every 100 units. Three tasks with periods 25, 50, 100 Hyperperiod/Major cycle (LCM): 100 Time slice/minor cycle (GCD) : 25 A feasible schedule exists if CA+CB < 25 CA+CC < 25 These are sufficiency conditions. They are not necessary conditions (i.e., there may be feasible solutions even if these conditions are not met. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Timeline Scheduling Notes Advantage: design simplicity A timer interrupts every “minor cycle” A table-driven scheduler executes programs in the order computed in the major cycle Disadvantage: Could cause instability during CPU overload if a task does not terminate at the minor-cycle boundary Difficult to maintain a static schedule when task periods or execution times change CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Rate-Monotonic Scheduling Assume n tasks running periodically Periods: T1, T2,….Tn Worst-case execution time: C1, C2,….Cn Relative deadline (relative to release time) Di = Ti No precedence constraints Preemptive with fixed/static priorities Theorem: if any static priority assignment yields a feasible schedule, then priorities ordered by period (smallest period has the highest priority) also yields a feasible schedule CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Optimal Feasibility Optimality with respect to feasibility means: if there is a feasible schedule S, then RMS can also schedule it If RMS executes every task to completion once within its designated period, then it satisfies the feasibility objective There may be other feasible schedules that are not RMS CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

finish The scheduler kicks in whenever a task arrives Note that if we make the red task longer, at some point the blue task may not be able to complete within C1 and misses its deadline. In this case there is no feasible RMS solution. finish The scheduler kicks in whenever a task arrives at its periodic interval. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

The worst-case processor demand occurs when all tasks are released simultaneously. This is referred to as the critical instant. The response time is longest. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

RMS solution: T2 has a higher priority We have two tasks RMS solution: T2 has a higher priority Non-RMS solution: which task has a higher priority? CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

CS555A – Real-Time Embedded Systems Stevens Institute of Technology With only two tasks, the non-RMS schedule is the one where the blue task with the longer period has a higher priority. So we have to only consider feasible non-RMS scheduling scenarios. CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Comments The proof can be extended to an arbitrary number of tasks The proof is for optimality with respect to feasibility. Other optimality criteria such as processor utilization are not considered. In fact RMS schedulers cannot always achieve 100% utilization. RMS is essentially a preemptive scheduling algorithm with fixed priority given by the task period Spring 2015, arz

What Have We Shown? We have shown that in cases where there exists a feasible scheduling solution under conditions stated in the theorem, the RMS scheduling algorithm also works RMS is optimal in the sense that it yields a feasible solution when there exists a feasible solution under any strategy This is called: optimality with respect to feasibility CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

What Have We Shown? If C1+C2>T2, a non-RMS solution does not exist in the two-task example RMS does not have to satisfy this constraint Therefore it can cover more than non-RMS solutions But there may be cases where there is no feasible solution. In these cases RMS can’t help either. Examples: Suppose in the two-task example, the period of the longer task is shorter CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz

Example: Infeasible RMS Schedule time processing period ) , ( = i C T P Deadline Miss 1st run 2nd run 3rd run ) 1 , 4 ( = P 1st run 2nd run ) 2 , 5 ( = P 1st run 1st run ) 2 , 7 ( 3 = P 5 10 15 CS555A – Real-Time Embedded Systems Stevens Institute of Technology Spring 2015, arz