Académique Documents
Professionnel Documents
Culture Documents
Department of CIT
Instructor information
Name: Berhe G.
Office Location: CRD
Phone NO.: +251-967-261091
Email : berheg21@gmail.com
Week 3
Chapter Four and Five
Fixed and dynamic priority Scheduling
Outline:
Introduction
– Typical metrics:
– Task characteristics
• Periodicity
• Timing constraints
– Resource requirements
– Inter-task interactions
Conti…
• Release time: the time which all the data that are required to begin
executing the task are available.
• Deadline: The time by which the task must complete its execution.
It may be hard or soft depending on the nature of the
corresponding task.
• Relative deadline: (Absolute deadline - the release time) i.e if task
Ti has a relative deadline di and is released at time “t” , it must be
executed by time t + di.
• Absolute deadline: The time by which the task must be completed,
that is t+di.
• Feasible assignment/schedule: we say feasible if all the tasks start
after their release and complete before their deadline.
Deadline Scheduling
• Real-time applications are not concerned with speed but with
completing tasks
• In this approach, scheduler is provided with information about task
deadlines.
• Information used
– Ready time
– Starting deadline
– Completion deadline
– Processing time
– Resource requirements
– Priority
– Subtask scheduler
The deadline scheduler gets the tasks to run before they miss their
deadlines, by preemptively “borrowing” running time from tasks
that normally have higher priorities.
Classification of Scheduling Algorithms
All scheduling algorithms
Static-priority Dynamic-priority
scheduling scheduling
Classification of scheduling algorithms
• A schedule is feasible iff
All the tasks/processes start after their release time
and complete before their deadlines
• Scheduling Policy may be determined
– Pre-run-time
• Schedule created offline
• Not unlike Cyclic Executive approach
– Run-time
• Schedule determined online as tasks arrive
– Needs to be done quickly!
– Can have static or dynamic process priority
Fixed vs Dynamic Priority Algorithms
• Fixed/static-priority algorithm
– Assign the same priority to all the jobs in each task.
– Scheduler can preempt the current process to start a new
process. Priorities are set pre-execution
Examples: Rate-monotonic scheduling (RMS), Deadline
Monotonic scheduling (DM)
a. Rate-monotonic (RM) algorithm: It assigns priorities to tasks
based on their periods: the shorter the period, the higher the
priority. Hence, the higher the rate, the higher the priority.
b. Deadline-monotonic (DM) algorithm: It assigns priorities to
jobs according to their relative deadlines: the shorter the
relative deadline, the higher the priority.
• Dynamic-priority algorithm:
– It can assign different priorities to the individual jobs in each
task. By dynamic, we mean task-level dynamic and job level
fixed.
– The scheduler can assign, and possibly also redefine, process
priorities at run-time
Conti…..
• Most real-time scheduling algorithms of practical interests assign
job-level fixed priorities.
• Jobs are assigned different priority-level in different tasks.
• Once a job is placed in the ready job queue according to the priority
assigned to it, its order with respect to other jobs in the queue
remains fixed.
Example:
a. Earliest Deadline First (EDF),
b. Least Completion Time (LCT),
c. Least Slack Time (LST)
EDF Algorithm
• Earliest-Deadline-First (EDF) algorithm assigns priorities to jobs
according to their deadlines. The earlier the deadline, the higher
the priority.
• This algorithm is optimal when used to schedule jobs on a
processor as long as preemption is allowed and jobs do not contend
for resources.
Conti….
• Schedulability Test: Test to determine whether a feasible
schedule exists
– Sufficient Test
• If test is passed, then tasks are definitely schedulable
• If test is not passed, tasks may be schedulable, but not
necessarily
– Necessary Test
• If test is passed, tasks may be schedulable, but not
necessarily
• If test is not passed, tasks are definitely not schedulable
– Exact Test (= Necessary + Sufficient)
• The task set is schedulable if and only if it passes the test.
Conti….
• Preemptive Scheduling
– Task execution is preempted and resumed later
– Preemption occurs to execute higher priority task.
– Offers higher schedulability
– Involves higher scheduling overhead due to context
switching
• Non-preemptive Scheduling
– Once a task starts executing, it completes its full
execution
– Offers lower schedulability
– Less overhead due to less context switching
Uniprocessor Task Scheduling
• Initial Assumptions:
– No critical sections
– Preemption costs are negligible
– Tasks must be completed for output to have any value
Conti….
• Terminology: Temporal Scope of a Task
– C - Worst-case execution time of the task
– D - Deadline of tasks, latest time by which the task
should be complete
– R - Release time
– n - Number of tasks in the system
– - Priority of the task
– P - Minimum inter-arrival time (period) of the task
• Periodic: inter-arrival time is fixed
• Sporadic: minimum inter-arrival time
• Aperiodic: random distribution of inter-arrival
times
Conti…
Common assumptions for both RM and EDF algorithms:
1. All tasks are preemptable and the cost of preemption is negligible.
Exercise:
– Check for p2 = (10,30,30), does it met the deadline if
utilization reduced to 83%?
Conti….
Example 2: Tasks t1=(1,4) , t2=(2,5) , t3=(5,20)
• 1st instant Task 1 runs to completion
• 1st inst Task 2 runs to completion
• 1st inst Task 3 runs for 1 unit
..at Eu=4, Task 1 released -- preempts Task 3
• 2nd inst Task 1 runs to completion .... At Eu =5, Task 2
released
• 2nd inst Task 2 runs to completion
• 1st inst Task 3 runs for 1 unit .... At Eu = 8, Task 1
released---- preempts Task3
• 3rd inst Task 1 runs to completion
• 1st inst Task 3 runs for 1 unit .... At Eu = 10, 3rd inst of Task
2 released --preempts 3
• At Eu = 15, 1st inst Task 3 completes…. CPU idle Eu 18-20
• At Eu = 20, all 3 tasks released ……Cycle repeats
–Total utilization(U) = 0.25+0.4+0.25= 0.9
122312231322133213 1
RMS Schedulability Test
• Key metric is
– Processor utilization: Sum of compute time divided by period for
each process:
U = ci / pi
• No schedule can possibly exist if U > 1
– No processor can be running 110% of the time
• Fundamental result:
– RMS schedule always exists if U < n (2 1/n – 1) , where n =# of tasks
• For RMS feasible schedulability:
• Task 1
– Highest priority.. never preempted
– Will run immediately once released
– For Task 1 to be feasibly scheduled…Only condition to
check is that e1<=p1
• Include Task 2 in task set
Ra =3 wc 0 = 5 + 3 + 3=11 ,
wc 1 = 5 + [11/7]x 3=10
wb 0 = 3 +3=6
wc 2= 5 + [10/7] x 3 + [10/12]x3=13
wb 1 = 3 + [6/7]x 3=6
wc 3= 5 + [13/7] x 3 + [13/12]x3=15
wb 2= 3 + [6/7] x 3=6
wc 4= 5 + [15/7] x 3 + [15/12]x3=16
wc 5= 5 + [16/7] x 3 + [16/12]x3=16
Rb=6
Rc=16
Example: task 1 (40,100), task 2(40, 150), task 3(100,350)
• Total utilization=0.4+0.267+0.286= 0.953>B(3)=0.779!
• UB test is inclusive: we need Precise test
• but we do have U(T1)+U(T2)= 0.4+0.267= 0.667<U(2)=0.828
• so we need to calculate R3 only!
• Calculate response time for task 3
• R30 = C1+C2+C3= 180
• R31 = C3+[R30/T1]*C1+[R30/T2]*C2
=100+ [180/100]*40+[180/150]*40
=100+2*40+2*40=260
• R32 =C3+[R31/T1]*C1+[R31/T2]*C2
=100+ [260/100]*40+[260/150]*40=300
• R33 =C3+[R32/T1]*C1+[R32/T2]*C2
=100+ [300/100]*40+[300/150]*40=300 (done)
1
Utilization is 100%
2
• If D!=T
– If D< T
1. The task set is just checked for the feasible solution.
2. Feasible solution is found by using the processor
Demand Analysis.
Example:
Example: T1(1,4) , T2(2,5) , T(5,20) all tasks released at time 0
Total utilization(U) = 0.25+0.4+0.25= 0.9
• 1st inst Task 1 runs 1st as earliest deadline of 4
• 1st inst Task 2 runs to completion
• 1st inst Task 3 runs for 1 unit.. Note that deadline is 20
..at Eu=4, Task 1 released -- preempts Task 3 as deadline is 8
• 2nd inst Task 1 runs to completion ..At Eu =5, Task 2 released
• 2nd inst Task 2 runs to completion as deadline is 10
• 1st inst Task 3 runs for 1 unit
.. At Eu = 8, Task 1 released---- preempts Task3
• 3rd inst Task 1 runs to completion
• 1st inst Task 3 runs for 1 unit
.. At Eu = 10, Task 2 released … preempts task 3 as deadline is 15
• At Eu = 12, Task 1 runs as deadline 16<20
• At Eu = 15, task 2 released and runs with deadline 20
• At Eu = 16, task 1 released with deadline 20…no preemption
122312231322133221 1
Exercise
Task Computation time Time Period (D=T)
A 1 3
B 1 6
C 1 5
D 3 10
a. T1 = {(8,4),(12,4),(20,4)}
b. T2 ={(8,4),(10,2),(12,3)}
c. T3 ={(3,1),(4,2),(6,1)}
7. Assume the periodic processors P1=(1,4,4), P2=(1,3,3) and
P3=(2,6,6) which shall be scheduled on a single processor
a. Give the processor utilization
b. Can the RMA produce a feasible schedule? In such a case give
a schedule.
c. Can the EDF algorithm produce a feasible schedule? In such a
case, give a schedule.
d. Compare RM and EDF scheduling. What is the advantage
and disadvantage of each method?
Exercise:
8. Construct a set of periodic tasks (with release times, execution
times and periods) which can be scheduled feasibly by the EDF
algorithm, but not by the RM algorithm.
9. A schedule can be constructed using methods like EDF and
Indicate whether the following statements are true and explain
your answer briefly
a. With EDF a higher utilization is possible than with RMS
b. RMS is more efficient than EDF
c. RMS is more general than EDF (i.e., applicable in more
situations).
d. Explain the difference between deadline monotonic scheduling
and Earliest Deadline First.
10. Determine whether the following set of periodic real time tasks are
schedulable on a uniprocessor using RMA. (Start time, Processing
Time, Period, deadline).
T1(20,25,150,100), T2(40,7,40,40),T3(60,10,60,50),T4(25,10,30,20).