1 / 39

CSE 522 Real-Time Scheduling (2)

CSE 522 Real-Time Scheduling (2) . Computer Science & Engineering Department Arizona State University Tempe, AZ 85287 Dr. Yann -Hang Lee yhlee@asu.edu (480) 727-7507. Priority-Driven Scheduling of Periodic Tasks. Why priority-driven scheduling use priority to represent urgency

wauna
Download Presentation

CSE 522 Real-Time Scheduling (2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 522 Real-Time Scheduling (2) Computer Science & Engineering DepartmentArizona State University Tempe, AZ 85287 Dr. Yann-Hang Leeyhlee@asu.edu(480) 727-7507

  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. B A C D 0 t r Ji,cis released Ji,cmisses its deadline 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]

  6. Extension of EDF Schedulable Utilization • If Di  pi, EDF is schedulable iffU  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 iffU  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}

  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 • given • 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. T1, T2 T1 T2 T2 T1 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 eiuntil 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

  14. t w(t) time Di 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 Jisatisfies

  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, dotime-demand analysis • if Di > pi, there may be more than one jobs of task i in the system • examine alljobs of task iin a level-ibusy 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 Ifp2 < p1+e1, max(e2)=p1-e1  U=e1/p1+(p1-e1)/p2 Else, max(e2)=p2-2e1 U=e1/p1+(p2-2e1)/p2 p2 maximal e2 p2 T1 T1 T1 0 p12p1

  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… U 1 p2=p1 2p1

  18. T1 T2 T3 T4 T5 p5 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

  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 + e2 + . . . . + 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. Tk Tn Tk Tn lpk pn Schedulable Utilization of RMA • When pn > 2pkand schedulable • construct a new task set that is schedulable and pn > 2pk • the original set has a higher utilization

  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. anmay 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 • Total utilization is .200 + .267 + .286 = .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 ז1from 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: 0.667 < U(2) = 0.828 • First two tasks are schedulable by UB test • Utilization of all three tasks: 0.953 > 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 = 300 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.

  28. Preemption from tasks That can hit only once (with period greater than pi) Preemption form the tasks that can hit more than once (with period less that pi) Execution of a task under test UB Test with ANY FIXED PRIORITY • Test is applied to each task. • Determine effective utilization (fi) of each task iusing 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

  29. Preemption from tasks That can hit only once (with period greater than di) Preemption form the tasks that can hit more than once (with period less that di) Execution of a task under test UB Test with Interrupt Priority • Test is applied to each task. • Determine effective utilization (fi) of each task iusing 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

  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 • t1the last time no pending instances with arrival time earlier than tiand 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 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. • iarrives at a with deadline d, is finished in t2

  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 iarrived 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

More Related