Вы находитесь на странице: 1из 22

Real-Time Scheduling

Deadline based algorithms

Aug 01, 2011

Overview
Parameters DMA EDF LST

Aug 01, 2011

Parameters
Release time (or ready time): Time at which the task is ready for processing. Deadline: Time by which execution of the task should be completed, after the task is released. Minimum delay: Minimum amount of time that must elapse before the execution of the task is started, after the task is released. Maximum delay: Maximum permitted amount of time that elapses before the execution of the task is started, after the task is released. Laxity- (deadline execution time)
Aug 01, 2011 3

Contd..
Worst case execution time: Maximum time taken to complete the task, after the task is released. The worst case execution time is also referred to as the worst case response time. Run time: Time taken without interruption to complete the task, after the task is released. Weight (or priority): Relative urgency of the task. Schedulability- property indicating whether real time system will meet its deadline.

Aug 01, 2011

Optimal
Both the RM and EDF algorithms are optimal real time scheduling algorithms. An optimal real-time scheduling algorithm is one which may fail to meet a deadline only if no other scheduling algorithm can meet the deadline. The following assumptions are made for both the RM and EDF algorithms.
(a) No task has any non-preemptable section and the cost of pre-emption is negligible. (b) Only processing requirements are significant; memory, I/O, and other resource requirements are negligible. (c) All tasks are independent; there are no precedence constraints. Aug 01, 2011

Deadline based algorithm


Simultaneous- n independent tasks with same arrival times.
any algorithm that executes that task in order of non decreasing deadlines is optimal with respect to minimizing lateness. Static Eg DMA

Asynchronus- n independent tasks with arbitrary arrival times.


Any algorithm that at any instant executes the task with earliest absolute deadline among all ready task is optimal w.r.t minimizing the lateness. Dynamic EDF
Aug 01, 2011 6

DMA
RMA is not optimal when task deadlines & periods differ for some tasks in the task set to be scheduled. DMA is more proficient in such conditions. It assigns priority to tasks based on their deadlines. Shorter deadlines means higher priority. When relative deadlines are proportional to period RMA & DMA produce identical solutions. DMA produces feasible schedule even if RMA fails. RMA always fails when DMA fails.

Aug 01, 2011

EDF Algorithm
Each time a new ready task arrives It is inserted into a queue of ready tasks sorted by their deadlines. If a newly arrived task is inserted at the head of the queue the currently executing task is prempted. Processes to be sorted according to deadline at each instant. Sorted list maintained as a heap. Each update requires O(log n) steps.

Aug 01, 2011

EDF scheduling does not require any priority value to be computed for any task at any time. Tasks are scheduled solely based on proximity of their deadline. Longer a task waits in a ready queue, the higher is the probability of being taken up for scheduling. A virtual priority value associated with a task keeps increasing with time until the task is taken up for scheduling. Scheduler does not perform any priority computation at run time or compile time.
Aug 01, 2011 9

Example
Task arrival Execution time deadline

T1
T2 T3

0
4 5

10
3 10

33
28 29

Aug 01, 2011

10

EDF Properties
EDF is optimal for a uniprocessor with pre-emption task being allowed. If a feasible schedule exist then EDF will schedule the tasks. EDF can achieve 100% processor utilisation with periodic preocesses having deadlines equal to periods.

Aug 01, 2011

11

EDF- utilization bound


Real-time system is schedulable under EDF if and only if ei/pi 1 for i=1 to n In simple feasibility test we assumed that period of each task is same as its deadlin However in practical
a) pi>di in this case each task needs ei amount of computing every min(pi,di) duration of time. (ei/min(pi,di)) 1

Aug 01, 2011

12

Implementation of EDF
Simple queue- Insertion O(1) Selection O(n) where n is number of tasks Maintain all ready tasks in a sorted priority queue using heap data structure.
Tasks kept in queue sorted by their deadlines. When tasks arrives it can be inserted in heap in O(log2 n) time. At every scheduling point the next task to be run can be found at the top of the heap. Removal from queue O(1) time.

Aug 01, 2011

13

Shortcomings in practical Applications


Transient overload when some tasks take more time to complete than what was originally planned during design time . Eg. It enters infinite loop
This can cause other tasks to miss their deadlines. Even most critical task might miss its deadline due to low priority task overshooting its planned completion time. Not suitable for industrial real time applications.

Resource sharing problem

Aug 01, 2011

14

RM vs. EDF
Rate Monotonic
Simpler implementation, even in systems without explicit support for timing constraints (periods, deadlines) Predictability for the highest priority tasks

EDF

Full processor utilization Misbehavior during overload conditions

Aug 01, 2011

15

Least slack time


Properties are decreasing function of laxity. Requires calling the scheduler periodically and to recompute the laxity. Overhead for many calls of the scheduler and many context switches. Detects missed deadlines early. Requires the knowledge of execution time.

Aug 01, 2011

16

LST Algo
A job Ji has deadline di, execution time ei, and was released at time ri At time t < di: Remaining execution time trem = ei - (t - ri) Slack time tslack = di - t - trem Assign priority to jobs based on slack time, tslack
The smaller the slack time, the higher the priority More complex, requires knowledge of execution times and deadlines

Knowing the actual execution time is often difficult a priori, since it depends on the data, need to use worst case estimates ( poor performance)
Aug 01, 2011 17

Optimality of EDF and LST


Theorem : When pre-emption is allowed and jobs do not contend for resources, the EDF algorithm can produce a feasible schedule of a set o jobs with arbitrary release times and deadlines on a processor if and only if J has feasible schedules. Proof: The proof is based on the following fact: Any feasible schedule of J can be systematically transformed into an EDF schedule.

Aug 01, 2011

18

Optimality of EDF and LST: Proof


1. Any feasible schedule can be transformed into an EDF schedule Suppose in a schedule parts of Ji and Jk, are scheduled in intervals I1 and I2 resp. The deadline of Ji is later than Jks but I1 is earlier to I2. In first case The release time of Jk later than end of I1. Jk cannot be scheduled in

I1; the two jobs are already scheduled on the EDF basis in these intervals.

In second case The release time rk of Jk is before the end of the interval I1 in which Ji executes; we assume that rk is no later than beginning of I1.

I1
Ji Jk

I2
dk di
19

rk
Aug 01, 2011

To transform the given schedule we Swap Ji and Jk (this is always possible, since Jis deadline is later than Jks) specifically if the interval I1 is shorter than I2
I1 Jk Jk I2 Ji

We move the portion of Jk that fits in I1 forward and

move the entire portion of Ji scheduled in I1 backwards to I2 the result is an EDF schedule

Aug 01, 2011

20

Contd..
2. So, if EDF fails to produce a feasible schedule, no feasible schedule exists If a feasible schedule existed it could be transformed into an EDF schedule, contradicting the statement that EDF failed to produce a feasible schedule [Proof for LST is similar]

Aug 01, 2011

21

Thank You
Aug 01, 2011 22

Вам также может понравиться