1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.

Slides:



Advertisements
Similar presentations
Washington WASHINGTON UNIVERSITY IN ST LOUIS Real-Time: Periodic Tasks Fred Kuhns Applied Research Laboratory Computer Science Washington University.
Advertisements

Real Time Scheduling.
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Priority Inheritance and Priority Ceiling Protocols
Washington WASHINGTON UNIVERSITY IN ST LOUIS Resource and Resource Access Control Fred Kuhns Applied Research Laboratory Computer Science and Engineering.
Outline Introduction Assumptions and notations
Introduction to Embedded Systems Resource Management - III Lecture 19.
Priority INHERITANCE PROTOCOLS
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
0 Synchronization Problem Resource sharing –Requires mutual exclusion –Critical section A code section that should be executed mutually exclusively by.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
Resource Access Protocols
CPE555A: Real-Time Embedded Systems
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
CSE 522 Real-Time Scheduling (3)
CSE 522 Real-Time Scheduling (4)
An Introduction to Real Time Systems
Mehdi Kargahi School of ECE University of Tehran
Is It Time Yet? Wing On Chan. Distributed Systems – Chapter 18 - Scheduling Hermann Kopetz.
Task Allocation and Scheduling n Problem: How to assign tasks to processors and to schedule them in such a way that deadlines are met n Our initial focus:
Module 2 Priority Driven Scheduling of Periodic Task
Courseware Scheduling Uniprocessor Real-Time Systems Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens.
Resource Access Control in Real-Time Systems Resources, Resource Access, and How Things Can Go Wrong: The Mars Pathfinder Incident Resources, Critical.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
Spring 2002Real-Time Systems (Shin) Rate Monotonic Analysis Assumptions – A1. No nonpreemptible parts in a task, and negligible preemption cost –
UCDavis, ecs251 Fall /23/2007ecs251, fall Operating System Models ecs251 Fall 2007 : Operating System Models #3: Priority Inversion Dr. S.
Chapter 4 – Periodic Task Scheduling In many real-time systems periodic tasks dominate the demand. Three classic periodic task scheduling algorithms: –
Introduction to Embedded Systems
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Combined Scheduling of Periodic and Aperiodic Tasks.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Scheduling policies for real- time embedded systems.
Real Time Operating Systems Schedulability - Part 3 Course originally developed by Maj Ron Smith 10/24/2015Dr Alain Beaulieu1.
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.
CompSci 143A1 5. Process and thread scheduling 5.1 Organization of Schedulers – Embedded and Autonomous Schedulers – Priority Scheduling 5.2 Scheduling.
6. Application mapping 6.1 Problem definition
RTOS task scheduling models
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 2006 Universität Dortmund Periodic scheduling For periodic scheduling, the best that we can do is to.
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems RMS and EDF Schedulers.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
Special Class on Real-Time Systems
Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.
B. RAMAMURTHY 12/25/2015 Realtime System Fundamentals : Scheduling and Priority-based scheduling Pag e 1.
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.
Introduction to Embedded Systems Rabie A. Ramadan 5.
A presentation for Brian Evans’ Embedded Software Class By Nate Forman Liaison Technology Inc. 3/30/2000 For Real-Time Scheduling.
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.
CS333 Intro to Operating Systems Jonathan Walpole.
Sandtids systemer 2.modul el. Henriks 1. forsøg m. Power Point.
CS333 Intro to Operating Systems Jonathan Walpole.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
Lecture 6: Real-Time Scheduling
Distributed Process Scheduling- Real Time Scheduling Csc8320(Fall 2013)
Scheduling and Resource Access Protocols: Basic Aspects
EEE 6494 Embedded Systems Design
EE5900 Cyber-Physical Systems
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall2014 9/20/2018.
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall /27/2018.
Real Time Scheduling Mrs. K.M. Sanghavi.
CSCI1600: Embedded and Real Time Software
Lecture 2 Part 2 Process Synchronization
CSCI1600: Embedded and Real Time Software
CHAPTER 8 Resources and Resource Access Control
Real-Time Process Scheduling Concepts, Design and Implementations
The End Of The Line For Static Cyclic Scheduling?
Ch 4. Periodic Task Scheduling
Real-Time Process Scheduling Concepts, Design and Implementations
Presentation transcript:

1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling

2 Priority-driven Preemptive Scheduling Assumptions & Definitions Tasks are periodic No aperiodic or sporadic tasks Job (instance) deadline = end of period No resource constraints Tasks are preemptable Laxity (Slack) of a Task Ti = d i – (t + c i ’) where di: deadline; t : current time; c i ’ : remaining computation time. t C’ i Laxity didi

3 Rate Monotonic Scheduling (RMS) Schedulability check (off-line) - A set of n tasks is schedulable on a uniprocessor by the RMS algorithm if the processor utilization (utilization test) c i is the execution time and p i is the period, The term n(2 1/n -1) approaches ln 2, (  0.69 as n   ). - This condition is sufficient, but not necessary.

4 RMS (cont.) Schedule construction (online) - Task with the smallest period is assigned the highest priority (static priority). - At any time, the highest priority task is executed.

5 RMS Scheduler - Example 1 Task set: T i = (c i, p i ) [computation time, period] T1 = (2,4) and T2 = (1,8) Schedulability check: 2/4 + 1/8 = = ≤ 2(√2 -1) = T11T11 T21T21 T12T Active Tasks : {T1, T2} Active Tasks : {T2} Active Tasks : {T1}

6 RMS scheduler – Example 2 Task set: T i = (c i, p i ) T1 = (2,4) and T2 = (4,8) Schedulability check: 2/4 + 4/8 = = 1.0 > 2(√2 -1) = T11T11 T21T21 T12T Active Tasks : {T1, T2} Active Tasks : {T2} Active Tasks : {T2, T1} T21T21 Active Tasks : {T2} Some task sets that FAIL the utilization-based schedulability test are also schedulable under RMS

RMS is not optimal T 1 =(1,2) and T 2 =(2.5,5) 7

8 Earliest Deadline First (EDF) Schedulability check (off-line) - A set of n tasks is schedulable on a uniprocessor by the EDF algorithm if the processor utilization. This condition is both necessary and sufficient. -Least Laxity First (LLF) algorithm has the same schedulability check.

9 EDF/LLF (cont.) Schedule construction (online) –EDF/LLF: Task with the smallest deadline/laxity is assigned the highest priority (dynamic priority). –At any time, the highest priority task is executed. It is optimal (i.e., whenever there is a feasible schedule, EDF can always compute it) when preemption is allowed and no resource constraint is considered. –Given any two tasks in a feasible schedule, if they are not scheduled in the order of earliest deadline, you can always swap them and still generate a feasible schedule.

10 EDF scheduler - Example Task set: T i = (c i, p i, d i ) T1 = (1,3,3) and T2 = (4,6,6) Schedulability check: 1/3 + 4/6 = = 1.0 T11T11 T21T21 T12T Active Tasks : {T1, T2} Active Tasks : {T2} Active Tasks : {T2, T1} Active Tasks : {T1} Unlike RMS, Only those task sets which pass the schedulability test are schedulable under EDF 3 T21T21

11 Comparison of RMS and EDF T1T1 T2T2 RMS schedule T1T1 T2T2 EDF schedule Deadline miss Process Period,T WCET,C T T 2 7 4

12 Resource sharing Periodic tasks Task can have resource access Semaphore is used for mutual exclusion RMS scheduling

13 Background – Task State diagram Ready State: waiting in ready queue Running State: CPU executing the task Blocked: waiting in the semaphore queue until the shared resource is free Semaphore types – mutex (binary semaphore), counting semaphore

14 Task State Diagram READYRUN WAITING Activate scheduling Preemption Termination Wait on busy resource Signal free resource Process/Task state diagram with resource constraints

15 Priority Inversion Problem Priority inversion is an undesirable situation in which a higher priority task gets blocked (waits for CPU) for more time than that it is supposed to, by lower priority tasks. Example: Let T 1, T 2, and T 3 be the three periodic tasks with decreasing order of priorities. Let T 1 and T 3 share a resource S.

16 Priority Inversion - Example T3 obtains a lock on the semaphore S and enters its critical section to use a shared resource. T1 becomes ready to run and preempts T3. Then, T1 tries to enter its critical section by first trying to lock S. But, S is already locked by T3 and hence T1 is blocked. T2 becomes ready to run. Since only T2 and T3 are ready to run, T2 preempts T3 while T3 is in its critical section. Ideally, one would prefer that the highest priority task (T1) be blocked no longer than the time for T3 to complete its critical section. However, the duration of blocking is, in fact, unpredictable because task T2 got executed in between.

17 Priority Inversion example T1 T2 T3T3 T3 0 T3 is the only active task Preempted by higher priority task T1 T1T1 Makes a request for resource S and gets blocked T3T3 Preempted by higher priority task T2 T2T2 T3T3 T3 completes T1T1 Resource S is available and T1 is scheduled here K1 K2 K3 T2 completes L1 Total blocking time for task T1 = (K2+K3) + (L1) Highest priority Least priority Medium priority T1 and T3 share resource S A higher priority task waits for a lower priority task

18 Priority Inheritance Protocol Priority inheritance protocol solves the problem of priority inversion. Under this protocol, if a higher priority task T H is blocked by a lower priority task T L, because T L is currently executing critical section needed by T H, T L temporarily inherits the priority of T H. When blocking ceases (i.e., T L exits the critical section), T L resumes its original priority. Unfortunately, priority inheritance may lead to deadlock.

19 Resource access control - example Task Ticici pipi cixcix ciyciy cizciz T T T T2 and T3 have access to a shared resource R c i x : Task duration before entering the critical section c i y : Critical section duration c i z : Task duration after the critical section ci = c i x + c i y + c i z By RMS, T3 > T1 > T2

20 Schedules Locks R Preempted by T3 T3T1T2T3T2T1T2T3 T2 T3T1T2T3T2T3T1T3T2 Direct blocking of T3 by T2 Priority inversion of T3 by T RMS Schedule RMS Schedule with Priority Inheritance Protocol 0 Direct blocking of T3 by T2 Inheritance blocking of T1 by T2 Release R Task Ticici pipi cixcix ciyciy cizciz T T T326110

21 Priority Inheritance Protocol – Deadlock Assume T2 has higher priority than T1

22 Priority Ceiling Protocol Priority ceiling protocol solves the priority inversion problem without getting into deadlock. For each semaphore, a priority ceiling is defined, whose value is the highest priority of all the tasks that may lock it. When a task T i attempts to execute one of its critical sections, it will be suspended unless its priority is higher than the priority ceiling of all semaphores currently locked by tasks other than T i. If task T i is unable to enter its critical section for this reason, the task that holds the lock on the semaphore with the highest priority ceiling is said to be blocking T i and hence inherits the priority of T i.

23 Priority Ceiling Protocol - properties This protocol is the same as the priority inheritance protocol, except that a task T i can also be blocked from entering a critical section if any other task is currently holding a semaphore whose priority ceiling is greater than or equal to the priority of task T i.

24 Priority Celiling Protocol - Example For the previous example, the priority ceiling for both CS 1 and CS 2 is the priority of T 2. From time t 0 to t 2, the operations are the same as before. At time t 3, T 2 attempts to lock CS 1, but is blocked since CS 2 (which has been locked by T 1 ) has a priority ceiling equal to the priority of T 2. Thus T 1 inherits the priority of T 2 and proceeds to completion, thereby preventing deadlock situation.

25 Scheduling tasks with precedence relations Scheduler {T1, T2} Conventional task set T1T2 Modify task parameters in order to respect precedence constraints Scheduler task set with precedence constraints

26 Modifying the task parameters for RMS While using the RMS scheduler the task parameters (ready time) need to be modified in order to respect the precedence constraints R j* ≥ Max (R j, R i* ) where R i* is the modified ready time of the task T i Priority Prio i ≥ Prio j TiTj

27 Modifying ready times for RMS: example T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3025 T40110 T50312 Initial Task Parameters

28 Modifying the Ready times for RMS T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3025 T40110 T50312 Initial Task Parameters R1 = 0R2 = 5 R3 = 0 R4 = 0 R5 = 0 R3’ = max(R1, R3) R3’ = 0 R4’ = max(R1, R2,R4) R4’ = 5 R5’ = max(R3’, R4’,R5) R5’ = 5

29 Modified Ready times for RMS T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3025 T45110 T55312 Modified Task Parameters R1 = 0R2 = 5 R3’ = 0 R4’ = 5 R5’ = 5

30 Assigning task priorities for RMS T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3025 T45110 T55312 Modified Task Parameters R1 = 0R2 = 5 R3’ = 0 R4’ = 5 R5’ = 5 Assume all tasks of a connected component have the same period. Therefore, as per RMS all tasks will have a tie. We assign priorities to break the ties. Priority

31 Modifying task parameters for EDF While using the EDF scheduler the task parameters need to be modified in order to respect the precedence constraints R j* ≥ Max (R j, (R i* + C i )) D i* ≥ Min (D i, (D j* – C j )) TiTj

32 Modifying the Ready times for EDF T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3025 T40110 T50312 Initial Task Parameters R1 = 0R2 = 5 R3 = 0 R4 = 0 R5 = 0 R3’ = max(R1 + C1, R3) R3’ = 1 R4’ = max(R1+C1, R2+C2,R4) R4’ = 7 R5’ = max(R3’+C3, R4’+C4,R5) R5’ = 8

33 Modifying the Ready times for EDF T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3125 T47110 T58312 Modified Task Parameters R1 = 0R2 = 5 R3’ = 1 R4’ = 7 R5’ = 8

34 Modifying the Deadlines for EDF T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1015 T2527 T3125 T47110 T58312 Modified Task Parameters D1 = 5D2 = 7 D3 = 5 D4 = 10 D5 = 12 D3’ = Min( (D5 – C5), D3) D4’ = Min( (D5 – C5), D4) D3’ = 5 D4’ = 9 D2’ = Min( (D4’ – C4), D2) D2’ = Min( (D4’ – C4), (D3’ – C3), D1) D2’ = 7D1’ = 3

35 Modifying the Deadlines for EDF T1 1 T2 2 T3 2 T4 1 T5 3 TaskRiRi CiCi DiDi T1013 T2527 T3125 T4719 T58312 Modified Task Parameters D5 = 12 D3’ = 5 D4’ = 9 D2’ = 7D1’ = 3