Scheduling
Scheduling
Introduction
Real-time computing objective :
Execute, by appropriate deadlines its control tasks
Objective of Chapter:
Techniques for allocating & scheduling tasks on processors to
ensure that deadlines are met.
Real-Time Systems
Scheduling
Scheduling
research
growth
1970
Real-Time Systems
Years
task characteristics
periodicity
timing constraints
Precedence Graph
T1
T2
T3
T5
T4
T6
T7
T8
Real-Time Systems
Precedence Graph
Real-Time Systems
<(1) =
<(2) = {1}
<(3) = {1}
<(4) = {1}
<(5) = {1,2,3} or {2,3}
<(6) = {1,3,4} T2
<(7) = {1,3,4,6}
<(8) = {1,3,4,6,7}
T1
T3
T5
T4
T6
T7
T8
Real-Time Systems
Real-Time Systems
Real-Time Systems
Real-Time Systems
10
Precedence constraints
inter-task relationship
precedence graph
(T) : precedent-task set of task T
i j : task Ti precedes task Tj
T1
T4
T2
Resource requirements
exclusive
nonexclusive
T3
T5
T6
T7
T8
Real-Time Systems
11
task assignment
in case of multiple processors
Inter-task interactions
inter-task communication
synchronous
asynchronous
Real-Time Systems
13
Real-Time Systems
14
Change Allocation
Check stopping
criterion
Continue
Stop
Declare Failure
Real-Time Systems
15
Overview
Uniprocessor scheduling algorithms
mode changes
Real-Time Systems
16
Multiprocessor scheduling
Critical sections
Fault-tolerant scheduling
Real-Time Systems
17
Notation
nnumber of tasks in task set
ci
execution time of task i
Ti
period of periodic task i
Ii
di
Di
absolute deadline of task i
ri release time of task i
Real-Time Systems
18
Real-Time Systems
19
Priority-driven approach
never leaves any resource idle intentionally
greedy scheduling, list scheduling, work-conserving
scheduling
most scheduling algorithms used in nonreal-time
systems are priority-driven
preemptive vs. nonpreemptive
Real-Time Systems
20
Clock-driven(time-driven) approach
tasks and their timing constraints are known a priori
except for aperiodic tasks
relies on hardware timers
a static schedule
constructed off-line
cyclic schedule: periodic static schedule
clock-driven schedule: cyclic schedule for hard real-time
tasks
foreground/background approach
foreground: interrupt-driven scheduling
background: cyclic executive (Big loop)
Real-Time Systems
21
Foreground/Background Systems
Background
code block
code block
Loop
Foreground
interrupt
ISR
..
.
ISR
interrupt
ISR
Real-Time Systems
22
A clock-driven scheduler
Input: Stored schedule (tk, (tk)) for k = 0, 1, , N-1
Task SCHEDULER:
set the next decision point i and table entry k to 0;
set the timer to expire at tk;
do forever:
accept timer interrupt;
if an aperiodic job is executing, preempt the job;
current task = (tk);
increment i by 1;
compute the next table entry k = i mod N;
set the timer to expire at f(i/N)H + tk
Real-Time Systems
23
Real-Time Systems
24
Rate-Monotonic Scheduling(RMS)
Overview
rate monotonic priority
the higher rate, the higher priority
c f
i 1
Real-Time Systems
25
Dynamic scheduling
earliest deadline first scheduling
least laxity first scheduling
Real-Time Systems
26
Period Transformation
Real-Time Systems
27
(continued)
solution: boost priority of T2 by reducing its period
replace T2 by T2:
T2 = T2 /2, C2 = C2 /2, C2+ = C2 +/2
an alternative: lower the priority of T1 by lengthening its
period
in this case, double the value of parameters
the new deadline must be ok
Real-Time Systems
28
Properties
EDF is optimal for uniprocessors
for periodic tasks with their relative deadline equal to
periods: if the total utilization of the task set is no
greater than 1, the task set can be feasibly scheduled
on a single processor by EDF.
Allows preemptions.
Real-Time Systems
29
Procedure
1. Sort task instances that require execution in time
interval [0, L] in reverse topological order.
2. Initialize the deadline of the kth instance of task Ti
to (k-1)Ti + di, if necessary
3. Revise the deadlines in reverse topological order.
4. Select the task with earliest deadline to execute
Real-Time Systems
30
R( x) r ( x)
r (o m)
if x m
if m x o m
if x o m
Real-Time Systems
31
Real-Time Systems
32
Utilization-balancing algorithm
Objective to balance processor utilization, and proceeds by
allocating the tasks one by one and selecting the least utilized
processor.
Considers running multiple copies for fault-tolerance systems.
for each task Ti, do
allocate one copy of Ti to each of the ri least utilized
processors
update the processor allocation to account for the
allocation of Ti
end do
Real-Time Systems
33
objectives:
to partition a task set so that each partition is scheduled later
for execution on a processor by RM scheduling
to use as few processors as possible
task characteristics
each task has constant period and deadline constraints
independent, no precedence constraints
Real-Time Systems
34
allocation algorithm
n tasks
ui : utilization factor of Ti
Pi,j : set of tasks assigned to a processor
Nk : number of class-k processors used so far
tasks are divided into M classes such that
task Ti class- k if 2
1
k+1
1
k
1 u 2 1
1
M
task Ti class- M if 0 u 2 1
where 1 k < M , M >3
Real-Time Systems
35
Algorithm Next-Fit-M
for k = 1 to M do set Nk = 1;
set i = 1;
while i <= n do
if Ti is a task from class-k, 1 <= k < M, then
assign Ti to Pk,Nk;
if Pk,Nk has currently k tasks assigned to it then
set Nk = Nk +1
endif
else (Ti is a task from class-M)
if the total utilization factors of all the tasks
assigned to PM,NM is greater than ln2-ui then
set NM = NM + 1
endif
assign Ti to PM,NM
endif
set i = i +1
endwhile
if Pk,Nk has not task assigned to it then set Nk = Nk -1
Real-Time Systems
36
Real-Time Systems
L- sorted list of
task so their
utilization are in
non-increasing
37
Schedule Tree
MOS proceeds by building up a schedule tree.
Each node represents an assignment and scheduling of a
subset of the tasks.
The root of the schedule tree is an empty schedule.
Each child of a node consists of a schedule of its parent node,
extended by one task.
A leaf of this tree consist of the schedule of the entire task set.
Real-Time Systems
38
Real-Time Systems
39
online
distributed environment, loosely coupled
both critical and noncritical tasks
local scheduler: handles (critical) tasks arriving at a
given node
global scheduler: schedules noncritical tasks
across processor boundary
global state
Real-Time Systems
41
FAB cont.
algorithms for global scheduling
to which node the task should be sent
Real-Time Systems
42
Real-Time Systems
43
bidding algorithm
Real-Time Systems
44
symbols
pi: a processor node with a newly arriving task that is not
locally guaranteed
ps: a node that is selected by FA algorithm
pt: a node that receives RFB message
Real-Time Systems
45
(continued)
Real-Time Systems
46
ps (focused node)
(original node)
pi
network
bidding
Real-Time Systems
47
Real-Time Systems
48
Real-Time Systems
49
Fault-tolerant schedule
should be able to run one or more copies of each
version (or iteration) of a task despite the failure of up
to nsust processor
Output of each fault-tolerant processor
has a ghost schedule + 1+ primary schedules
makes room for ghosts by shifting primary copies.
Real-Time Systems
50
Ghosts
each version of a task must have ghost copies
scheduled on nsust distinct processors
ghosts are conditionally transparent, only if
two ghost copies may overlap in the schedule of a processor
if no other processor carries the copies of both tasks (that is,
if the primary copies of both tasks are not assigned to the
same processor)
primary copies may overlap the ghosts only if there is
sufficient slack time in the schedule to continue to meet all
the deadlines
Real-Time Systems
51
Algorithm FA1
Ha: assignment procedure, Hs: EDF scheduling procedure
Real-Time Systems
52
Algorithm FA2
1. Run Ha to obtain a candidate allocation of copies to
processors.
2. Run Hs for ghost and primary copies on a processor i.
if the resulting schedule is found infeasible, return to step 1
otherwise, record the position of the ghost copies in ghost
schedule Gi. Assign static priorities to the primary tasks in
the order in which they finish executing.
Real-Time Systems
53
Example
ghosts: g4, g5, g6
release time
execution time
deadline
h1 h2 h3 g4 g5 g6
2 5 3 0 0 9
2 2 4 2 2 2
6 8 15 5 6 12
Real-Time Systems
54
g4
g5
g6
10
15
g6
10
15
h3
h2
h3
10
15
Real-Time Systems
55