Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 522 Real-Time Scheduling (2)

Similar presentations


Presentation on theme: "CSE 522 Real-Time Scheduling (2)"— Presentation transcript:

1 CSE 522 Real-Time Scheduling (2)
Computer Science & Engineering Department Arizona State University Tempe, AZ 85287 Dr. Yann-Hang Lee (480)

2 Priority-Driven Scheduling of Periodic Tasks
Why priority-driven scheduling use priority to represent urgency easy implementation of scheduler (compare priorities and dispatch tasks) tasks can be added or removed easily no direct control of execution instant How can we analyze the schedulability if we don’t know when a task is to be executed Let’s begin a deterministic case in one processor independent periodic tasks deadline = period preemptable no overhead for context switch

3 Priority-Driven Schedules
Assign priority when jobs arrive static -- all jobs of a task have a fixed priority dynamic -- different priorities to individual jobs of a task relative priorities don’t change while jobs are waiting Static priority schedules Rate-monotonic -- the smaller a task priority, the higher its priority Deadline-monotonic Dynamic priority schedules EDF -- earliest deadline first LSTF -- least slack time first Schedulable utilization: a scheduling algorithm can feasibly schedule any sets of priority tasks if the total utilization is equal to or less than the schedulable utilization of the algorithm

4 EDF Schedule A optimal algorithm under single processor and preemptable tasks How do we know a set of periodic tasks are schedulable under EDF ? If we know the schedulable utilization SU of EDF, then any sets of tasks are schedulable when U  SU Theorem: A set of n periodic tasks can be scheduled by EDF iff Proof the only-if part is obvious the if part --- show if there is a job misses its deadline, then U > 1

5 EDF Schedule Let the 1st unschedulable job be Ji,c that misses its deadline at t and the processor is never idle during [0,t] how much execution we have done before t Case 1: no type D jobs and let’s ignore type C jobs Case 2: if type D jobs exist and are executed before r let t’ be the latest instant that type D jobs execute how much execution we have done in [t’, t] Ji,c is released Ji,c misses its deadline t r A B C D

6 Extension of EDF Schedulable Utilization
If Di  pi, EDF is schedulable iff U  1 What can we do if Di < pi density of task k : k = ek / min(pk,Dk) EDF is schedulable if the total density is equal to or less than 1 proof: if there is a job missing its deadline, then the total density > 1 there is no “only-if” part ---- if the total density > 1, EDF may or may not schedulable If Di  pi, LSTF is schedulable iff U  1 Predicable for single-processor preemptive schedule of independent tasks Robust independent of phases periods are lower bound  applicable to sporadic tasks with minimum separations

7 General EDF Feasibility Analysis
Processor demand: all processing request during a period [ti, t2), i.e., Loading factor: Each set of real-time jobs is feasibly scheduled by EDF iff How to compute loading factor?

8 Sporadic Tasks under EDF
minimum separation Ti ≠ Di Worst possible scenario: arrives synchronously at the maximum rate A sporadic task set is feasibly scheduled by EDF iff Need to show that Hybrid task sets (with both periodic and sporadic task) are schedulable under EDF if

9 EDF Schedulability Test
If Di ≤ Ti and synchronous task sets loading factor u[0,t)≤1 for all t L: synchronous busy period, can be compute iteratively by Test loading factor at deadline instants that are less than L

10 EDF Scheduling Example
L0=7, L1=9, L2=11, L3=14, L4=16 the set of points to be tested: D={4,5,7,10,13,16} Task(i) Period WCET Deadline 1 6 2 4 2 8 5 3 9 3 7 t h u 4 2 0.5 5 0.8 7 1 10 9 0.9 13 11 0.85 16

11 Example of EDF Schedule
A digital robot with EDF schedule control loop: ec  8ms at 100Hz BIST: eb  50ms given BIST can be done every 250ms Add a telemetry task to send and receive messages with et  15ms if BIST is done every 1000ms the telemetry task can have a relative deadline of 100ms  sending or receiving must be separated at least 100ms

12 Rate-Monotonic Algorithm
A base case: no additional overhead, simple periodic tasks with pi =Di Assign priorities according their periods Ti has a higher priority that Tk if i < k ( pi < pk ) Is RM optimal?  if there is a feasible fixed-priority schedule, then RM is feasible How do we know RM is feasible  schedulability test Results: RM is optimal if pi  Di sufficient condition  utilization test a complete test  what is the worst response time given all possible arrivals and preemptions

13 Critical Instant Critical instant of Ti: a job of Ti arriving at the instant has a maximum response time If we can find the critical instant of Ti, then check whether all jobs of Ti meet their deadlines let’s increase ei until the maximum response time = Di  schedulable utilization In-phase instant is critical: all higher priority tasks are released at the same instant of Ji,c (assume all jobs are completed before the next job of the same task is released.) which T2 has the maximum response time T T2 T1, T2 T T1

14 Schedulability Test: Time-Demand Analysis
Consider in-phase instant only If Ji is done at t, then the total work must be done in [0,t] is (from Ji and all higher priority tasks) Can we find a t  Di such that wi(t)  t cannot check all t  [0, Di] check all arrival instants and Di The completion time of Ji satisfies t w(t) time Di

15 Schedulability Test EDF has a schedulable utilization of 1, how about RMS If Di=pi, the schedulable utilization exists if U  n ( 21/n - 1 ), done else do time-demand analysis if Di < pi, do time-demand analysis if Di > pi, there may be more than one jobs of task i in the system examine all jobs of task i in a level-i busy interval (in-phase) the following equations represent:

16 Schedulable Utilization of RMS
Must be less than 1 Let’s consider two tasks and deadline=period T2 can only be executed when T1 is not in the system Let p2 < 2p1. What is the maximum schedulable e2 If p2 < p1+e1, max(e2)=p1-e  U=e1/p1+(p1-e1)/p2 Else, max(e2)=p2-2e1  U=e1/p1+(p2-2e1)/p2 T1 p p1 p2 maximal e2

17 Schedulable Utilization of RMS
Given e1, p1, and p2, plot U The minimum U occurs when p2=p1+e1 where U= e1/p1+(p1-e1)/(p1+e1) What is the minimum U take the derivative wrt to p1 and set dU/dp1=0 we will get e1=(21/2-1)p1 and U=0.828… p2=p p1 U 1

18 Schedulable Utilization of RMA
U  n ( 21/n - 1 ) Is there a case that is feasible and gives the minimal schedulable utilization When pn  2 p1 processor must be busy in [0,pn] become unscheduable if increase ei processor will be idle if increase pi T1 T2 T3 T4 T5 p5

19 Schedulable Utilization of RMA
What do we have from the timeline diagram ek = pk+1 - pk for k=1,2,..,n-1 en = pn - 2(e1 + e en-1 ) =2p1 - pn Can we increase e1 and decrease ek by the same amount still schedulable for the 1st arrival of all tasks utilization is higher Can we decrease e1 and increase ek When will U be minimum when q2,1=q3,2= = 2/n

20 Schedulable Utilization of RMA
When pn > 2pk and schedulable construct a new task set that is schedulable and pn > 2pk the original set has a higher utilization Tk Tn pn lpk

21 Schedulability: RT Test
Theorem: for a set of independent, periodic tasks, if each task meets its first deadline, with worst-case task phasing, the deadline will always be met. Response Time (RT) test: let an = response time of task i. an may be computed by the following iterative formula: Test Terminates when an+1 = an Task i is schedulable if its response time is before its deadline: an ≤ pi

22 Sample Problem: UB Test
Task 1 20 100 0.200 Task 2 40 150 0.267 Task 3 350 0.286 Total utilization is = .753 < U(3) =.779 The periodic tasks in the sample problem are schedulable according to the UB test.

23 Example: Applying RT Test (1)
If we increase the compute time of ז1 from 20 to 40; is the task set still schedulable? Utilization for the first task : 40/100=0.4 < U(1) Utilization of first two tasks: < U(2) = 0.828 First two tasks are schedulable by UB test Utilization of all three tasks: > U(3) = 0.779 UB test is inconclusive Need to apply RT test

24 Example: Applying RT Test (2)
Use RT test to determine if ז3 meets its first deadline: i = 3

25 Example: Applying RT Test (3)
a3 = a2 = Done! Task is schedulable using RT test. a3 = 300 < p3 = 350

26 Modeling Task Switching

27 Schedulability with Interrupts
Interrupt processing can be inconsistent with rate monotonic priority assignment. interrupt handler executes with high priority despite its period interrupt processing may delay execution of tasks with shorter periods Effects of interrupt processing must be taken into account in schedulability model. Task(i) Period(p) WCET(e) Priority Deadline(D) 3 200 60 HW 1 100 20 High 2 150 40 Medium 4 350 Low

28 UB Test with ANY FIXED PRIORITY
Test is applied to each task. Determine effective utilization (fi) of each task i using when di=pi fi = Compare effective utilization against bound, U(n). n = num(Hn) + 1 num(Hn) = the number of tasks in the set Hn Preemption form the tasks that can hit more than once (with period less that pi) Execution of a task under test Preemption from tasks That can hit only once (with period greater than pi )

29 UB Test with Interrupt Priority
Test is applied to each task. Determine effective utilization (fi) of each task i using when di<pi (ei must be done within di, not pi) fi = Compare effective utilization against bound, U(n). n = num(Hn) + 1 num(Hn) = the number of tasks in the set Hn Preemption form the tasks that can hit more than once (with period less that di) Execution of a task under test Preemption from tasks That can hit only once (with period greater than di )

30 UB Test with Interrupt Priority: 3
For 3, no tasks have a higher priority: H = Hn =H1 = { }. f3 = Note that utilization bound is U(1): num(Hn) = 0. f3 =

31 UB Test with Interrupt Priority: 1
For 1, 3 has a higher priority: H = {3}; Hn = {}; H1 = {3}. f1 = Note that utilization bound is U(1): num(Hn) = 0. f1 =

32 UB Test with Interrupt Priority: 2
For 2 : H={1, 3}; Hn={1 }; H1={3 }; Note that utilization bound is U(2): num(Hn) = 1.

33 UB Test with Interrupt Priority:
For 4 : H={1, 2, 3}; Hn={1 , 2, 3 }; H1={}; Note that utilization bound is U(4): num(Hn) = 3.

34 Is There a RT Analysis for EDF
Does a critical instant exist? releasing task instance i at the start of the busy period may not lead to its worst-case response time. i arrives at a with deadline d, is finished in t2 t1 the last time no pending instances with arrival time earlier than ti and deadline ≤ d [t1, t2) –the busy period of instances with deadlines ≤ d “shift left” all instances of other tasks to start at t1  increase busy period

35 RT Analysis for EDF (1) Deadline busy period where WCET happens:
only tasks with deadlines less than and equal to d get executed started at 0 for the instance of i arrived at a: Li(a) higher priority workload Then, an iterative formula for Li(a) The response time is:

36 RT Analysis for EDT (2) Choice of “a”:
Li(a) > a (arrives before deadline busy period ends) a+Di coincides with the absolute deadlines of other tasks in the interval [0, L-Ci), L is the busy period of synchronous arrivals

37 Summary of Feasibility Analysis (1)
A set of tasks {Ci, Di, Ti,, i} Dynamic priority -- EDF is optimal Di ≥ Ti -- utilization bound on slide #4 (iff) Di < Ti -- all loading factor less than 1 on slide 7 (iff) Synchronous or Sporadic – busy period analysis and testing algorithm on slide #9 (iff) Asynchronous – if the cooresponding synchronous task set is schedulable. worst case execution time – slide #34 necessary condition: U ≤ 1 sufficient condition: ∑(Ci / min{Di , Ti }) ≤ 1

38 Summary of Feasibility Analysis (2)
Static priority Rate monotonic – optimal if Di ≥ Ti Deadline monotonic – optimal if Di < Ti Necessary condition: U ≤ 1 Synchronous Sufficient condition RM and DM -- ∑(Ci / min{Di , Ti }) ≤ n(21/n-1 ) (slide #12) fixed priorities – effective utilization for each task ≤ n(21/n-1 ) (slide #28) worst case response time (i.e. 1st arrival) ≤ Di (slide #21) (iff) Asynchronous the conditions for synchronous case are sufficient

39 Project outline submissions
5 late submissions; one on March 31 One submitted as assignment 3 Toyota UA RTOS for automotive Systems Real-time Communication on CAN bus AFDX Avionics Network Real-time Hypervisor RTSJ and SCJ Scheduling for multicore Others 8 5 2 16 9 12 3


Download ppt "CSE 522 Real-Time Scheduling (2)"

Similar presentations


Ads by Google