Download presentation

Presentation is loading. Please wait.

Published byDarby Dunkley Modified over 2 years ago

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

2
2 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Priority-Driven Schedulers Assumptions, some of which will be relaxed at the end of this section: –Independent tasks –No sporadic or aperiodic tasks –Jobs ready when released –Jobs may be preempted at any time –Jobs never suspend themselves –Scheduling decisions made at job release and on completion –Interrelease times may vary: use the minimum for period –Uni-Processor environment –System overhead (including context switch) is negligible compared to job execution times and periods –Unlimited priority levels

3
3 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems What is a priority-driven scheduler Event-driven, work-conserving schedulers –scheduling decision made when event occurs: for example a job is released or completes –Resources allocated to the highest priority job, and only left idle if no jobs are waiting (ready). Jobs assigned explicit or implicit priorities –consequently FIFO and Round Robin may be considered priority driven. Priorities are defined by the queue ordering and may be varied when job executes Algorithm defined by priorities used and a set of rules (preemption, priority changes etc).

4
4 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Concepts Algorithms that consider a jobs urgency generally perform better than those that do not. –as the deadline for a job approaches, its urgency should increase. Contrast EDF with FIFO, the FIFO implicit priority is a jobs position in a queue. Static versus Dynamic assignment of workloads –for now we only consider the case where a set of tasks are statically assigned to a processor. Fixed versus Dynamic priority assignment. –Fixed priority: RM and DM –Dynamic Task, Fixed Job: EDF –Dynamic Job: LST (Least Slack First)

5
5 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Concepts: Schedulable Utilization "A scheduling algorithm can feasibly schedule any set of periodic tasks on a processor if the total utilization of the tasks is equal to or less than the schedulable utilization of the algorithm Schedulable utilization is necessarily <= 1 While dynamic priority algorithms have better average performance, they are less predictable during overload. In fact their worst case behavior is more difficult to predict –consider how RM with fixed priorities will perform during overload: the highest priority tasks will generally complete on time which the lowest will not. Contrast this with EDF which uses dynamic priorities.

6
6 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Example Dynamic Algorithms Earliest Deadline First –Assigns priorities to jobs according to absolute deadline. The sooner the deadline the higher the priority –Priority assigned when job released. For example, job arrives and is placed in a queue using EDF algorithm. –Dynamic task priority, static job priority Least Slack Time First (LST) –Job with the least amount of slack time is scheduled next. –Dynamic task priority, Dynamic job priority

7
7 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Schedulable Utilizations of EDF A system of independent, preemptable tasks with relative deadlines equal to their respective periods can be feasibly scheduled on one processor if and only if the total utilization is equal to or less than 1. Schedulability of the EDF algorithm. –if D k p k then density = Δ = U, utilization test is both necessary and sufficient. –if D k < p k for some k then the test is only a sufficient condition.

8
8 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Schedulable Utilization: Case 1 r i,c r i,c +p i 1 i k n … … … J i,c misses a deadline T1T1 TiTi TkTk TnTn We know that if the utulization is > 1 then the tasks are not schedulable. But if the tasks are not schedulable does that imply the utilization is > 1? Case 1: The Interval I is the current period of task T i. All jobs released before r i,c complete by time r i,c + p i. Solve for the total required time and compare to the total utilization. Show that if a deadline is missed then the utilization is > 1. I t

9
9 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Schedulable Utilization: Case 2 t r i,c r i,c +p i 1 i k n … … … J i,c misses a deadline T1T1 TiTi TkTk TnTn I Case 2:Let t -1 be the last time a job runs which has a deadline after (r i,c +p i ). Define T to be the set of tasks with jobs released before r i,c and with deadlines after t. Then it suffices to only consider the jobs in tasks T-T. Proceed as before using t -1 as the origin. t -1 1 i

10 10 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Fixed Priority Algorithms Rate Monotonic (RM) –Priorities based on Task period: smaller periods have higher priority. –if p i rate of T k ), then i > k Deadline Monotonic (DM) –Priority based on task deadline: smaller relative deadline, higher priority. –if D i k No fixed priority algorithm is optimal Under special cases can achieve a utilization of 1: –a set of tasks are simply periodic if for every pair of tasks T i and T k with p i

11
11 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Sufficient utilization bounds for RM, let D k = p k Utilization check: –This is a sufficient condition, that is, it is possible for a set of tasks to fail this test but still be schedulable. Time-demand analysis ( D k <= p k ) –assumes worst case task interactions: evaluates computational requirements at task critical instants Simulation can be used –it is sufficient to perform simulation over largest period when all tasks are in phase Schedulability of Fixed Priority Algorithms

12
12 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Critical Instant Central concept for fixed priority systems A critical instant of a task is the "instant" in time when a job (in T i ) has its maximum response time. If a task can be scheduled in its critical instant then it will not miss a deadline. Occurs when a job in T i is released concurrently with all higher priority jobs. –T = {T 1, T 2,..., T n }, ordered by priority ( i < j, i < j) –T i = {T 1, T 2,..., T i-1 }, All higher priority jobs –r i,c = r k,l for some l for every k in 1, 2,..., i-1. At critical instant: –Lower priority task is preempted by higher priority tasks, delaying completion. –Maximum interference when all phases are equal

13
13 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems advancing release time increases interference e i + 3e j advancing release time increases interference e i + 4e j Critical Instant

14
14 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Time Demand Analysis Computes total demand for processor time by a job released at a critical instant of the task and all higher priority tasks. If this worst case response time is less than or equal to the jobs deadline, then it is schedulable. w(t) t w i (t) = e i + k = 1 i - 1 t pkpk ekek for 0 < t p i

15
15 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Critical Instant for Fixed Priority Systems WkWk 1 i k n … … … T1T1 TiTi TkTk TnTn I Response time for job J k,1 is w k,1. Perform a time demand analysis. Let W be the required total processor time, then at time W = t = w k,1 + k :

16
16 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Critical Instant: Time demand analysis t W Decreasing the phase k shifts the graph up thus increasing the response time. Likewise, decreasing the phases of higher priority jobs ( j ) will also increase the jobs response time. Therefore, the maximum response time of a job occurs when all jobs are in phase. w k,1 = t j k

17
17 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Practical Considerations Preemptive versus Non-Preemptive Self Suspension Context Switches Limited Priority Levels Tick scheduling Variable priority

18
18 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Blocking and Nonpreemptivity Higher priority job is blocked by a lower priority job during a nonpreemptive interval resulting in a priority inversion. Must adjust schedulability tests –let q i = maximum nonpreemptable execution time –q i <= e i –let b i (nb) = max(q k ), i+1 k n Fixed priority systems, change time demand analysis as follows Change utilization equation as follows:

19
19 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Nonpreemptivity EDF: In a system where jobs are scheduled on the EDF basis, a job J k with relative deadline D k can block a job J i with relative deadline D i only if D k is larger then D i. In other words for a job to be blocked we need r k d i. For deadline driven systems

20
20 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Blocking Time Continued Self-suspension or self-block –We can treat as another blocking factor, b i (ss). –If higher priority job self-suspends then its computation time may be deferred until the feasible interval for some other job If a job J i can self-suspend at most K i times then the total possible blocking time is given by ( K+1 represents the K self-suspensions and scheduling on release)

21
21 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Putting it together with system overhead Context Switch, assume fixed job priorities. –let CS = context switch time: time to place or remove a job to/from the processor. So 2·CS is the total context switch overhead for a given job. –we can account for this by increasing a jobs execution time by 2*CS or 2(K+1)CS if self-suspend K times. Updating our tests (must be true for every i):

22
22 Fred Kuhns (6/2/2014)CSE522– Advanced Operating Systems Limited Priorities and Tick scheduling Limited priorities –N task priorities, S system priorities and N != S, then must provide a mapping. When N > S then nondistinct priorities result (different task priorities map to same system priority) worst case a job is delayed by other jobs with the same priority –Uniform mapping –Constant Ratio mapping and grid ratio Tick Scheduling –tick period = p 0 –the "tick" task has period p and an execution time that is a function of the queue lengths –A job may wait on scheduling queue when runnable

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google