Presentation is loading. Please wait.

Presentation is loading. Please wait.

2/23/2016COSC-4301-01, Lecture 21 Real-Time Systems, COSC-4301-01, Lecture 2 Stefan Andrei.

Similar presentations


Presentation on theme: "2/23/2016COSC-4301-01, Lecture 21 Real-Time Systems, COSC-4301-01, Lecture 2 Stefan Andrei."— Presentation transcript:

1 2/23/2016COSC-4301-01, Lecture 21 Real-Time Systems, COSC-4301-01, Lecture 2 Stefan Andrei

2 2/23/2016 COSC-4301-01, Lecture 2 2 1-2 Reminder of last lecture Introduction in Real-Time Systems:  Chapter 1 of [Cheng; 2002];  Chapter 1 of [Kopetz; 1997];  Chapter 1 of [Stankovic, Spuri, Ramamritham, Buttazzo; 1998])

3 2/23/2016 COSC-4301-01, Lecture 2 3 Overview of this lecture Real-Time Scheduling and Schedulability Analysis  Schedulability test  Schedulability utilization  Optimal scheduler  Determining computation time  Uniprocessor scheduling Scheduling preemptable and independent tasks  Fixed-priority schedulers: RM, DM  Dynamic-priority schedulers: EDF, LL

4 2/23/2016 COSC-4301-01, Lecture 2 4 Scheduling General definition (uniprocessor, multiprocessor, distributed system):  Given a set of (computer) tasks (a.k.a., processes), scheduling is to determine when to execute which task, thus determining the execution order of these tasks.  Example: T1=‘fetch children to school’, T2=‘do classes’, T3=‘do shopping’ by the same person (uniprocessor).  For the multiprocessors and distributed systems, scheduling means also to determine an assignment of these tasks to a specific person in a team of people.  Example: T1 and T3 are done by processor P1 (e.g., spouse), and T2 is done by processor P2 (multiprocessor).

5 2/23/2016 COSC-4301-01, Lecture 2 5 Scheduling (cont) Is a central activity of a computer system, usually performed by the operating system. Is also necessary in many non-computer systems (e.g., assembly lines). In non-real-time systems, the typical goal of scheduling is to maximize average throughput (number of tasks completed per unit time) and/or to minimize average waiting time of the tasks. In the case of real-time scheduling, the goal is to meet the deadline of every task by ensuring each task can complete execution by its specified deadline. The deadline is obtained from the environmental constraints imposed by the application.

6 2/23/2016 COSC-4301-01, Lecture 2 6 Scheduling analysis Is to determine whether a specific task of a set of tasks satisfying certain constraints can be successfully scheduled (completing execution of every task by its specified deadline) using a specific scheduler. Schedulability test: validate whether a given application can satisfy its specified deadlines when scheduled according to a specific scheduling algorithm.

7 2/23/2016 COSC-4301-01, Lecture 2 7 Schedulability test Is often done at compile time, before the computer system and its tasks start their execution. If the test can be performed efficiently, then it can be done at run-time as an on-line test. Types of schedulers:  Compile-time (a.k.a., static) schedulers  Run-time (a.k.a., on-line or dynamic) schedulers. Schedulable utilization: is the maximum utilization allowed for a set of tasks that will guarantee a feasible scheduling of this task set.

8 2/23/2016 COSC-4301-01, Lecture 2 8 Hard and soft real-time systems Hard real-time system:  Requires that every task or task instance completes its execution by its specified deadline;  Failure to do so even for a single task or task instance may lead to catastrophic consequences. Soft real-time system:  Allows some tasks or task instances to miss their deadlines, but a task or task instance that misses its deadline may be less useful or valuable to the system.

9 2/23/2016 COSC-4301-01, Lecture 2 9 Optimal scheduler Is one which may fail to meet the deadline of a task only if no other scheduler can meet its deadline. Examples include uniprocessor earliest- deadline-first (EDF) and least-laxity-first (LLF) schedulers for independent tasks with no synchronization constraints and no resource requirements.

10 2/23/2016 COSC-4301-01, Lecture 2 10 Real-time scheduling. Task’s characterization Characterization of a task:  c: computation time (a.k.a., WCET – Worst Case Execution Time)  S: start time (a.k.a., release or ready time)  d: deadline (i.e., relative to the start time)  p: period (a.k.a., minimum separation)  Hence, a task T can be denoted as (S, c, d, p) Some characterizations include also:  D: absolute deadline (a.k.a., wall clock time deadline). Usually D = S + d.  Thus, a task T can be denoted as (S, c, d, D, p)

11 2/23/2016 COSC-4301-01, Lecture 2 11 Types of tasks Single-instance task: executes only once. Periodic task: has many instances or iterations, and there is a fixed period between two consecutive releases of the same task.  Example: a periodic task may perform signal processing of a radar scan once every 2 seconds, so the period of this task is 2 seconds.

12 Types of tasks (cont) Sporadic task: has zero or more instances, and there is a minimum separation between two consecutive releases of the same task.  Example: a sporadic task may perform emergency maneuvers of an airplane when the emergency button is pressed, but there is a minimum separation of 20 seconds between two emergency requests.  An aperiodic task is a sporadic task with either a soft deadline or no deadline. 2/23/2016 COSC-4301-01, Lecture 2 12

13 2/23/2016 COSC-4301-01, Lecture 2 13 Determining S, d, p, and c The application and the environment in which the application is embedded are main factors determining S, d, and p. c, the computation time of a task, is dependent on its source code, object code, execution architecture, memory management policies, and actual number of page faults and I/O. c is not just an upper bound on the execution time of task code without interruption, but it has to include the time of the central processing unit (CPU) for handling page faults, I/O requests, etc.

14 2/23/2016 COSC-4301-01, Lecture 2 14 Determining c Is crucial to successfully scheduling it in a real-time system. An overly pessimistic estimation of c will result in wasted CPU time, whereas an under-approximation would result in missed deadlines. First solution: testing the tasks and use the largest value of c during these tests.  Disadvantage: the largest value seen during testing may not be the largest observed in the working system.

15 2/23/2016 COSC-4301-01, Lecture 2 15 Determining c Second solution: analyzing the source code (an advantage is that these methods are safe).  Disadvantage: using an overly simplified model of the CPU may result in over-approximating c. Third solution: running the tasks in systems with several levels of memory components (e.g., cache, main memory).  Disadvantage: there are restrictions in their models and thus the proposed analysis techniques cannot be applied in systems not satisfying their constraints.

16 2/23/2016 COSC-4301-01, Lecture 2 16 Determining c Fourth solution: use a probability approach to model WCET of a process.  Main idea: model the distribution of c and use it to compute a confidence level for any given c.  Advantage: in soft real-time systems, if the designer wants a confidence of 99% on the estimation for WCET, he/she can determine which WCET to use from the probability approach.  Disadvantage: is not recommended in hard real-time systems as WCET is just an approximation.

17 2/23/2016 COSC-4301-01, Lecture 2 17 Scheduling Uniprocessor scheduling Multiprocessor scheduling

18 2/23/2016 COSC-4301-01, Lecture 2 18 Uniprocessor scheduling. Basic Assumptions Compile-time/static (i.e., priority of tasks do not change during run-time); Preemptive tasks (i.e., tasks can be interrupted and resumed later); No precedence constraints (i.e., all are independent); Negligible context-switching time; Periodic tasks.

19 2/23/2016 COSC-4301-01, Lecture 2 19 Rate-Monotonic (RM) scheduling strategy Is a fixed and static priority scheduling strategy (Rate-Monotonic Scheduler - RMS). The task’s priority is task’s fixed period. RMS executes at any time instant the instance of the ready task with the shortest period first. More formal, task J i has a higher priority than task J k if and only if p i < p k.

20 2/23/2016 COSC-4301-01, Lecture 2 20 RM-scheduling strategy. Example J 1 : S 1 = 0, c 1 = 2, p 1 = d 1 = 5 J 2 : S 2 = 1, c 2 = 1, p 2 = d 2 = 4 J 3 : S 3 = 2, c 3 = 2, p 3 = d 3 = 20  Figure 3.1 from [Cheng; 2005], page 45

21 2/23/2016 COSC-4301-01, Lecture 2 21 RM-scheduling strategy. Considerations U = c 1 /p 1 + … + c n /p n If a task set is RM-schedulable, then U ≤ 1. So, if U > 1, then the task set is not RM- schedulable. In general, the RM-scheduling strategy is not optimal because there exist schedulable task sets that are not RM-schedulable. There is a special class of periodic tasks sets for which the RM-scheduling is optimal: their periods p i are multiples of each other.

22 2/23/2016 COSC-4301-01, Lecture 2 22 RM-schedulability test 1 Given a set of n independent, preemptable, and periodic tasks on a uniprocessor such that d i ≥ p i and p i are multiples of each other, let U be the total utilization of this tasks set (U = c 1 /p 1 + … + c n /p n ). The task set is RM-schedulable if and only if U ≤ 1.

23 2/23/2016 COSC-4301-01, Lecture 2 23 RM-schedulability test 1. Example J 1 : S 1 = 0, c 1 = 1, d 1 = p 1 = 4 J 2 : S 2 = 0, c 2 = 1, d 2 = p 2 = 2 J 3 : S 3 = 0, c 3 = 2, d 3 = p 3 = 8 p i are exact multiples of each other (p 2 < p 1 < p 3, p 1 = 2p 2, p 3 = 4p 2 ). U = c 1 /p 1 + c 2 /p 2 + c 3 /p 3 = 1/4 +1/2 + 2/8 = 1. By applying RM-Schedulability Test 1, then this tasks set is RM-schedulable.

24 2/23/2016 COSC-4301-01, Lecture 2 24 RM-schedulability test 2 Liu and Layland’s sufficient condition (1973):  Given a set of n independent, preemptable, and periodic tasks on a uniprocessor, let U be the total utilization of this tasks set. The task set is schedulable if U ≤ n(2 1/n – 1).  Remarks: For n=2, n(2 1/n – 1) equals to 0.8284… For n=3, n(2 1/n – 1) equals to 0.7797… lim n  n(2 1/n – 1) = ln 2 ≈ 0.6931…

25 2/23/2016 COSC-4301-01, Lecture 2 25 RM-schedulability test 2. Example J 1 : S 1 = 0, c 1 = 1, p 1 = 4 J 2 : S 2 = 0, c 2 = 1, p 2 = 5 J 3 : S 3 = 0, c 3 = 3, p 3 = 10 U = c 1 /p 1 + c 2 /p 2 + c 3 /p 3 = 1/4 +1/5 + 3/10 = 0.75 By applying RM-Schedulability Test 2, this task set is RM-schedulable.

26 2/23/2016 COSC-4301-01, Lecture 2 26 RM-schedulability test 2. Example J 1 : S 1 = 0, c 1 = 1, p 1 = 4 J 2 : S 2 = 0, c 2 = 1, p 2 = 3 J 3 : S 3 = 0, c 3 = 2, p 3 = 6 U = c 1 /p 1 + c 2 /p 2 + c 3 /p 3 = 1/4 +1/3 + 2/6 = 0.91666… The RM-Schedulability Test 1 cannot be applied since periods are not exact multiples of each other. The RM-Schedulability Test 2 cannot be applied since U > 3(2 0.33 -1) ≈ 0.7797. However, this tasks set is RM-schedulable…

27 2/23/2016 COSC-4301-01, Lecture 2 27 RM-schedulability test 2. Example (cont) J 1 : S 1 = 0, c 1 = 1, p 1 = 4 J 2 : S 2 = 0, c 2 = 1, p 2 = 3 J 3 : S 3 = 0, c 3 = 2, p 3 = 6 478910 J3J3 23561112 J2J2 J1J1 10

28 2/23/2016 COSC-4301-01, Lecture 2 28 Hence, it makes sense to look for stronger analytical conditions to ensure the schedulability without running the task set. Necessary and sufficient condition requires checking inequalities that depend on time t. Let J 1, …, J i sorted increasingly according to their period. Let w i (t)=Σ k=1 i c k  t / p k , 0 < t ≤ p i Task J i is RM-schedulable if and only if w i (t) ≤ t, for a time instant t, t = k p j,  j = 1, …, i,  k = 1, …,  p i /p j  If d i ≠ p i, we replace p i by min(d i, p i ) above. RM-schedulability test 3

29 2/23/2016 COSC-4301-01, Lecture 2 29 RM-schedulability test 3. First Example We sort the jobs according to their period:  J 1 : S 1 = 0, c 1 = 1, p 1 = 3  J 2 : S 2 = 0, c 2 = 1, p 2 = 3  J 3 : S 3 = 0, c 3 = 1, p 3 = 3 U = 1/3 + 1/3 + 1/3 = 1, so Test 2 cannot be applied. We need to check the following inequalities:  w 1 (3) ≤ 3,  w 2 (3) ≤ 3,  w 3 (3) ≤ 3.

30 2/23/2016 COSC-4301-01, Lecture 2 30 RM-schedulability test 3. First Example w 1 (3) = 1 w 2 (3) = 2 w 3 (3) = 3 Since  i  t such that w i (t) ≤ t, it means this tasks set is RM-schedulable according to Schedulability Test 3.

31 2/23/2016 COSC-4301-01, Lecture 2 31 RM-schedulability. Second Example Let us consider the following preemptable task set T={J 1, J 2, J 3 }: J 1 : S 1 = 0, c 1 = 1, p 1 = d 1 = 4 J 2 : S 2 = 1, c 2 = 2, p 2 = d 2 = 6 J 3 : S 3 = 3, c 3 = 4, p 3 = d 3 = 10 1. compute the utilization rate. 2. analyze whether T is feasible using RM- scheduling method. In the affirmative case, provide a schedule.

32 2/23/2016 COSC-4301-01, Lecture 2 32 RM-schedulability. Second Example The utilization rate:  U = C 1 /P 1 + C 2 /P 2 + C 3 /P 3 = 1/4 + 2/6 + 4/10 = 59/60 = 0.98 Schedulability Test 1 For this test U ≤ 1. But the task periods are not exact multiples of each other, so Schedulability Test 1 cannot be applied.

33 2/23/2016 COSC-4301-01, Lecture 2 33 RM-schedulability. Second Example Schedulability test 2 For this test, we check whether the utilization rate (U) is less or equal than n(2 1/n -1). Here n = 3, so n(2 1/n -1) = 3(2 1/3 -1) = 0.7797… Since U > n(2 1/n -1), the Schedulability Test 2 cannot be applied (as 0.98 … > 0.7797…).

34 2/23/2016 COSC-4301-01, Lecture 2 34 RM-schedulability. Second Example For Schedulability test 3, we start with the job J 1 that has the smallest deadline. For J 1 : i = 1, j = 1, k = 1 Thus t = k * p j = 1 * 4 = 4 w 1 (t) = c 1 [t / p 1 ] = 1 Now, J 1 is RM-schedulable if and only if w 1 (t) ≤ 4. Therefore, J 1 is RM-schedulable.

35 2/23/2016 COSC-4301-01, Lecture 2 35 RM-schedulability. Second Example For J 2 : i = 2; j  {1, 2}, k = 1. Thus t = k * p j where k = 1. For j = 1: t = 1 * p 1 = 4. For j = 2: t = 1 * p 2 = 6. Hence, we get the values of t  {4, 6}. Substituting the respective values of t and j, we get the following conditions (at least one should hold):  c 1 + c 2 ≤ kp 1, that is, 3 ≤ 4 or  2c 1 + c 2 ≤ kp 2, that is, 4 ≤ 6. (In fact, both of these conditions hold.) So, J 2 is RM-schedulable together with J 1.

36 2/23/2016 COSC-4301-01, Lecture 2 36 RM-schedulability. Second Example For J 3 : i = 3; j  {1, 2, 3}, k  {1, 2}, and t = k * p j. For k = 1, j  {1, 2, 3}, we have t  {4, 6, 10}. For k = 2, j  {1, 2, 3}, we have t  {8, 12, 20}. Hence t  {4, 6, 10, 8, 12, 20}. Substituting the values of t and j, we get:  c 1 + c 2 + c 3 ≤ 4, that is, 7 ≤ 4, or  2c 1 + c 2 + c 3 ≤ 6, that is, 8 ≤ 6, or  2c 1 + 2c 2 + c 3 ≤ 8, that is, 10 ≤ 8, or  3c 1 + 2c 2 + c 3 ≤ 10, that is, 11 ≤ 10, or  3c 1 + 2c 2 + 2c 3 ≤ 12, that is, 15 ≤ 12, or  5c 1 + 4c 2 + 2c 3 ≤ 20, that is, 21 ≤ 20. Since none of the above condition holds, J 3 is not RM- schedulable together with J 1, and J 2.

37 2/23/2016 COSC-4301-01, Lecture 2 37 The RM scheduling attempt It can be seen that J 3 misses its deadline at t=53.

38 2/23/2016 COSC-4301-01, Lecture 2 38 Dynamic-priority schedulers Earliest Deadline First (EDF) Least Laxity First (LLF) Reminder: An optimal scheduler is one which may fail to meet a deadline of a task only if no other schedule can meet its deadline. Both above strategies are optimal.

39 2/23/2016 COSC-4301-01, Lecture 2 39 Earliest Deadline First (EDF or ED) Executes at every instant the ready task with the earliest absolute deadline first (i.e., D). Reminder: D = S + d. If two tasks or more have the same deadlines, EDF randomly selects one for execution next. EDF is a dynamic-priority scheduler since task priorities may change at run-time depending on the nearness of their absolute deadline.

40 2/23/2016 COSC-4301-01, Lecture 2 40 EDF terminology [Krishna & Shin, 1997] call EDF a deadline- monotonic (DM) scheduling algorithm; [Liu, 2000] defines DM algorithm as a fixed- priority scheduler that assigns higher priorities to tasks with shorter relative deadlines. [Cheng, 2002] and we use EDF or DM to refer to dynamic-priority scheduling algorithm.

41 2/23/2016 COSC-4301-01, Lecture 2 41 Example. FIFO scheduler fails Four single-instance tasks (for simplicity):  J 1 : S 1 = 0, c 1 = 4, D 1 = 15  J 2 : S 2 = 0, c 2 = 3, D 2 = 12  J 3 : S 3 = 2, c 3 = 5, D 3 = 9  J 4 : S 4 = 5, c 4 = 2, D 4 = 8 A FIFO (First-In-First-Out) scheduler (often used in non-real-time operating systems) executes the tasks in the order of their arrivals and their deadlines are not considered.

42 2/23/2016 COSC-4301-01, Lecture 2 42 Example. FIFO scheduler fails The FIFO (First-In-First-Out) scheduler gives an infeasible schedule (J 3 misses its deadline – D 3 = 9; also, J 4 misses its deadline – D 4 = 8). 111315235612 J2J2 J1J1 147891014 J3J3 J4J4 0

43 2/23/2016 COSC-4301-01, Lecture 2 43 Example. EDF scheduler works At time 0, since D 1 > D 2, then J 2 has a higher priority than J 1 ; At time 2, since D 3 < D 2, then J 2 is preempted and J 3 begins execution; At time 5, since D 4 < D 3, then J 3 is preempted and J 4 begins execution, and so on, so forth. 235612 J3J3 147891014 J3J3 J4J4 0111315 J2J2 J2J2 J1J1

44 2/23/2016 COSC-4301-01, Lecture 2 44 EDF algorithm is optimal Theorem [Dertouzos; 1974]. Given a set S of independent (no resource contention or precedence constraints) and preemptable tasks with arbitrary start times and deadlines on a uniprocessor, the EDF algorithm yields a feasible schedule for S if and only if S has feasible schedules. [Dertouzos; 1974] M.L. Dertouzos, Control Robotics: the Procedural Control of Physical Processes, Information Processing 74, North-Holland Publishing Company, 1974

45 2/23/2016 COSC-4301-01, Lecture 2 45 Least-Laxity-First (LL or LLF) Like EDF, the LL strategy is another run-time optimal scheduler. It is also known as Minimum-Laxity-First (MLF) or Least- Slack-Time-First (LST) algorithm. Let c(i) denote the remaining computation time of a task at time i. Let d(i) denote the deadline of a task relative to the current time i. The laxity (or slack) of a task at time i is d(i)-c(i). The laxity is the maximum time a task can delay execution without missing its deadline in the future. The LL scheduler executes at every instant the ready task with the smallest laxity.

46 2/23/2016 COSC-4301-01, Lecture 2 46 Example: LL scheduling J 1 : S 1 = 0, c 1 = 2, d 1 = 6 = p 1 J 2 : S 2 = 0, c 2 = 3, d 2 = 7 = p 2 J 3 : S 3 = 0, c 3 = 2, d 3 = 11 = p 3 At i=0:  c 1 (0)=2, d 1 (0)=6-i=6, l 1 (0)=6-2=4  c 2 (0)=3, d 2 (0)=7-i=7, l 2 (0)=7-3=4  c 3 (0)=2, d 3 (0)=11-i=11, l 3 (0)=11-2=9  The LL scheduler chooses the minimum laxity task (say J 1 ). At i=1:  c 1 (1)=1, d 1 (1)=6-i=5, l 1 (1)=5-1=4  c 2 (1)=3, d 2 (1)=7-i=6, l 2 (1)=6-3=3  c 3 (1)=2, d 3 (1)=11-i=10, l 3 (1)=10-2=8  The LL scheduler chooses J 2 since l 2 (1) is less l 1 (1) and l 3 (1).

47 LL is optimal [Mok; 1983] The Least Laxity First Algorithm is optimal for preemptable and independent tasks. However, the LL algorithm has the disadvantage of a potentially very large number of preemptions, and it is no longer optimal if preemption is not allowed [George et al.; 1996]. [Mok; 1983] A.K. Mok, Fundamental Design Problems of Distributed Systems for the Hard Real-Time Environment, Ph.D. Dissertation, MIT, 1983. [George et al.; 1996] L. George, N. Rivierre, M. Spuri, Preemptive and Non-Preemptive Real-Time Uni-Processor Scheduling, Rapport de Recherche RR-2966, INRIA, France, 1996. 2/23/2016 COSC-4301-01, Lecture 2 47

48 2/23/2016 COSC-4301-01, Lecture 2 48 Schedulability Test 4 Let c i denote the computation time of task J i. For a set of n periodic preemptable tasks such that the relative deadline d i of each task is equal to or greater than its respective period p i (d i ≥ p i ), a necessary and sufficient condition for feasible EDF and LL scheduling of this task set on a uniprocessor is: U = c 1 /p 1 + … + c n /p n ≤ 1. Remark: for a task set containing some tasks whose relative deadlines d i are less than their periods, no easy schedulability test exists with a necessary and sufficient condition.

49 2/23/2016 COSC-4301-01, Lecture 2 49 Schedulability test 5 A sufficient condition for feasible EDF and LL scheduling of a set of independent, preemptable, and periodic tasks on a uniprocessor is c 1 /min(d 1,p 1 )+ … + c n /min(d n,p n ) ≤ 1. Remarks:  The term c i /min(d i,p i ) is the density of task J i.  If the deadline and the period of each task are equal (d i = p i ), then Schedulability Test 5 is the same as Schedulability Test 4.

50 2/23/2016 COSC-4301-01, Lecture 2 50 Example 1 J 1 : S 1 = 0, c 1 = 2, d 1 = 6 = p 1 J 2 : S 2 = 0, c 2 = 3, d 2 = 7 = p 2 J 3 : S 3 = 0, c 3 = 2, d 3 = 11 = p 3 U = 2/6 + 3/7 + 2/11 = 218/232 < 1 and d i = p i for any i. Hence, this task set is feasible (according to Schedulability Test 4).

51 2/23/2016 COSC-4301-01, Lecture 2 51 Example 2 J 1 : S 1 = 0, c 1 = 1, d 1 = 4, p 1 = 5 J 2 : S 2 = 0, c 2 = 2, d 2 = 5, p 2 = 4 J 3 : S 3 = 0, c 3 = 1, d 3 = 5, p 3 = 5 Since d 1 < p 1, Schedulability Test 4 is not applicable. c 1 /min(d 1,p 1 )+ c 2 /min(d 2,p 2 ) + c 3 /min(d 3,p 3 ) = 1/4 + 2/4 + 1/5 = 19/20 < 1. Since the above number is smaller than 1, according to Schedulability Test 5, the above task set is EDF and LL schedulable.

52 2/23/2016 COSC-4301-01, Lecture 2 52 Example 3 J 1 : S 1 = 0, c 1 = 2, d 1 = 6, p 1 = 7 J 2 : S 2 = 0, c 2 = 3, d 2 = 7, p 2 = 6 J 3 : S 3 = 0, c 3 = 2, d 3 = 11, p 3 = 11 Since d 1 < p 1, Schedulability Test 4 is not applicable. c 1 /min(d 1,p 1 )+ c 2 /min(d 2,p 2 ) + c 3 /min(d 3,p 3 ) = 2/6 + 3/6 + 2/11 = 67/66 > 1. Schedulability Test 5 cannot be applied, as the above number is greater than 1.

53 2/23/2016 COSC-4301-01, Lecture 2 53 Schedulability test 6 [Krishna & Shin, 1997] Given a set of n independent, preemptable, and periodic tasks on a uniprocessor, let:  U be the total utilization of this tasks set (U = c 1 /p 1 + … + c n /p n ),  d max be the maximum relative deadline among these tasks’ deadlines,  P is the least common multiple (LCM) of these tasks’ periods,  s(t) be the sum of the computation tasks with absolute deadlines less than t. This task set is not EDF-schedulable if either of the following conditions holds:  U > 1   t t.

54 Revisiting Example 3 Let us consider the following preemptable task set T={J 1, J 2, J 3 }:  J 1 : S 1 = 0, c 1 = 2, d 1 = 6, p 1 = 7  J 2 : S 2 = 0, c 2 = 3, d 2 = 7, p 2 = 6  J 3 : S 3 = 0, c 3 = 2, d 3 = 11, p 3 = 11 We study the applicability of Schedulability Test 6:  U = 2/7 + 3/6 + 2/11 = 0.9675…  The minimum t such that the inequality s(t) > t is 29 (the LCM is 462, etc). 2/23/2016 COSC-4301-01, Lecture 2 54

55 Revisiting Example 3 We check whether  t such that s(t) > t, for some t  {1, …, 29}. 2/23/2016 COSC-4301-01, Lecture 2 55 51015202529 Since s(t)  t, for any t  {1, …, 29}, then Test 6 checks that the above task set could be EDF-schedulable.

56 2/23/2016 COSC-4301-01, Lecture 2 56 Comparing fixed and dynamic-priority schedulers RM and DM algorithms are fixed-priority schedulers. EDF and LL algorithms are dynamic-priority schedulers. Reminder:  A fixed-priority scheduler assigns the same priority to all instances of the same task.  A dynamic-priority scheduler may assign different priorities to different instances of the same task.

57 2/23/2016 COSC-4301-01, Lecture 2 57 Comparing fixed and dynamic-priority schedulers No optimal fixed-priority scheduling algorithm exists since we can find a schedulable task set that cannot be scheduled by a fixed- priority algorithm. Both EDF and LL algorithms are optimal dynamic-priority schedulers for preemptable tasks.

58 2/23/2016 COSC-4301-01, Lecture 2 58 Example 1 J 1 : S 1 = 0, c 1 = 5, p 1 = 10 = d 1 J 2 : S 2 = 0, c 2 = 12, p 2 = 25 = d 2 Since U = 5/10 + 12/25 = 0.98 ≤ 1, Schedulability Test 4 is satisfied, this task set is feasible (EDF-schedule is next slide).

59 2/23/2016 COSC-4301-01, Lecture 2 59 Example 1. EDF schedule LCM(10,25)=50 At time 0, D 1 = d 1 + S 1 = 10 and D 2 = d 2 + S 2 = 25, so J 1 has a higher priority than J 2. At time 5, J 2 is the only task ready to begin. At time 10, D 1 = d 1 + S 1 = 20 and D 2 = d 2 + S 2 = 25, so J 1 has a higher priority than J 2. At time 15, J 1 is the only task ready to begin. At time 20, D 1 = d 1 + S 1 = 30 and D 2 = d 2 + S 2 = 25, so J 2 has a higher priority than J 1 …  Figure 3.5 from [Cheng; 2005], page 53

60 2/23/2016 COSC-4301-01, Lecture 2 60 Example 1 (cont) The RM scheduler leads to an infeasible schedule (figure below). J 1 has a shorter period and thus a higher priority, so it is always scheduled first (before J 2 ). The first instance of J 2 is allocated only 10 time units before its deadline of 25, so it finishes at time 27, causing a miss of its deadline at 25.  Figure 3.6 from [Cheng; 2005], page 54.

61 2/23/2016 COSC-4301-01, Lecture 2 61 Example 2 J 1 : S 1 = 0, c 1 = 4, p 1 = 10 = d 1 J 2 : S 2 = 0, c 2 = 13, p 2 = 25 = d 2 Since U = 4/10 + 13/25 = 0.92 ≤ 1, Schedulability Test 4 is satisfied, this task set is feasible (EDF- schedule is below). LCM(10,25)=50.  Figure 3.8 from [Cheng; 2005], page 55.

62 2/23/2016 COSC-4301-01, Lecture 2 62 Example 2 (cont) The RM scheduler leads now to a feasible schedule. Previously, J 2 missed its deadline at time 25, so after decreasing c 1 from 5 to 4, J 2 can be executed by time 25. In fact, since 1 time unit remains available (between time 24 and 25), c 2 can be increased from 12 to 13.  Figure 3.7 from [Cheng; 2005], page 55.

63 2/23/2016 COSC-4301-01, Lecture 2 63 Additional constraints May complicate the scheduling of tasks with deadlines:  Frequency of tasks requesting service periodically;  Precedence relations among tasks and subtasks;  Resources shared by tasks;  Whether task preemption is allowed or not (if tasks are preemptable, we assume a task can be interrupted only at discrete (integer) time instants).

64 2/23/2016 COSC-4301-01, Lecture 2 64 Summary Real-Time Scheduling and schedulability analysis  Schedulability test  Schedulability utilization  Optimal scheduler  Determining computation time  Uniprocessor scheduling Scheduling preemptable and independent tasks  Fixed-priority schedulers: RM, DM  Dynamic-priority schedulers: EDF, LL

65 2/23/2016 COSC-4301-01, Lecture 2 65 Reading suggestions From [Cheng; 2002]  Chapter 3 (Introduction, Sections 3.1, 3.2.1) Chapters 3, 10 and 11 of [Kopetz; 1997] Chapter 2 of [Stankovic, Spuri, Ramamritham, Buttazzo; 1998]

66 2/23/2016 COSC-4301-01, Lecture 2 66 Coming up next Sporadic tasks Scheduling nonpreemptable tasks Scheduling nonpreemptable sporadic tasks Scheduling nonpreemptable tasks with precedence constraints Communicating periodic tasks: deterministic rendezvous model Chapter 3 of [Cheng; 2002], Sections 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5

67 2/23/2016 COSC-4301-01, Lecture 2 67 Thank you for your attention! Questions?


Download ppt "2/23/2016COSC-4301-01, Lecture 21 Real-Time Systems, COSC-4301-01, Lecture 2 Stefan Andrei."

Similar presentations


Ads by Google