Академический Документы
Профессиональный Документы
Культура Документы
OUTLINE
• Notations and assumptions • Practical Considerations
• Static, timer-driven scheduler - Handling frame overruns
• Cyclic scheduling - Mode changes
- Job slices - General workloads
• Cyclic executive algorithm - Multiprocessor scheduling
• Improving the average response • Constructing static schedules
time of aperiodic jobs - Network-flow graph
- Slack stealing
• Scheduling sporadic jobs
- Acceptance test
- Optimality of the EDF algorithm
Ref: [Liu]
• Ch. 5 (pg. 85 – 114)
1
(Φi,pi,ei,Di) 0 1 4 7 11 14 17 21 …
Static schedules
- T1=(4,1); T2=(5,1.8); T3=(20,1); T4=(20,2); Hyperperiod = 20;
- Different static schedules are possible:
T1 T2 T3 T1 T2 T1 T2 T1 T4 T1 T2
0 4 5 8 10 12 15 16 20
T2 T1 T4 T1 T2 T1 T2 T1 T3 T2 T1
0 4 5 8 10 12 15 16 20
T1 T3 T2 T1 T4 T2 T1 T2 T1 T1 T2
0 4 5 8 10 12 15 16 20
• to have at least one complete frame between the release time t’ and the
deadline t’ + Di of a job;
- in the special case (t’ = t ): it suffices to have f ≤ Di;
- in the general case (t < t’ < t + f ): the job’s deadline (t’ + Di) should occure
not earlier than t + 2f ; that is: 2f - Di ≤ (t’- t) (f ≤ Di /2 + (t’ – t)/2);
- if this last constraint is satisfied, then, since t’- t < f, it is also f ≤ Di ; so the
condition for the special case (t’ = t ) is also satisfied;
• we may then consider t’ > t and choose f such that:
2f - Di ≤ (t’- t) (for 1 ≤ i ≤ n)
9
This is not the only solution: jobs could be fit into frames in other ways.
11
13
14
Periodic-task server
• Assumption: job slices in each scheduling block L(k) correspond to
precisely defined code segments, such as procedures (job slicing
has been performed by reviewing jobs’ design in order to meet frame
size constraints);
• then the periodic-task server executes all the job slices in L(k) by
calling them one after the other (no context switches take place).
3 aperiodic jobs
no slack stealing
σc 19
d3 d2
d4
• what if S2 was scheduled to use up the slack available in the time intervals
(10,12), (15,16), and (19,20)?
- S2 would complete earlier (at t =20),
- but S3 would have been rejected!
• problem: early commit.
20
Scheduling of accepted jobs
• Static scheduling of sporadic jobs:
– schedule as large a slice as possible of the accepted sporadic job in
the current frame;
– schedule remaining portions as late as possible;
– append slices of accepted job to list of periodic-task slices in frames
where they are scheduled.
• Problem (early commit):
– leaving unused slacks in frames may prevent acceptance of sporadic
jobs that are released later (in the previous example: what if S3 was
released at t = 14 (with the same e3 = 1.5 and D3 = 11: d3 = 25), and
S4 at t = 17 (with e4 = 5 and D4 = 30: d4 = 47)? Both would be
rejected.
• Alternative 1: rescheduling upon arrival:
– more sporadic jobs may be accepted (S1 in the previous example);
– however, unpredictable number of context switches and acceptance
tests may cause periodic jobs to complete late.
• Alternative 2: dynamic scheduling of sporadic jobs: EDF 21
T1
T2
periodic
tasks T3
...
TN
acceptance
test
sporadic EDF priority
jobs queue processor
reject
aperiodic Aperiodic
jobs job queue
22
EDF scheduling of accepted jobs
rejected rejected
d1
d3 d2
d4
Acceptance test
• The acceptance test at the beginning of frame t for a sporadic job S(d,e)
(with deadline d and execution time e) is performed in 2 steps:
1. compute σ(t,l ): the total slack time available in frames t to l before d;
if σ(t,l ) < e, then S is rejected;
2. else if the acceptance of S will not cause any sporadic job already
accepted to complete late, then S is accepted; otherwise S is rejected
• Sk(dk,ek) ∈ {S0,S1,...,Sns} - sporadic jobs already accepted
• for the first step of the acceptance test, the scheduler needs:
- σ(i,h) - total (initial) amount of slack time in frames i to h, for i,h = 1, .., F;
all values of these slack times σ(i,h), leftover by periodic jobs from any
frame i to any frame h (i ≤ h) in the first (and in any) major cycle, can be
pre-computed and stored in a slack table with (F + 1)*F/2 elements;
- from σ(i,h) in the first major cycle, initial slack from frame i in any major
cycle j to frame h in any major cycle j’ (> j) is computed when required:
σ((j – 1)F + i, (j’ – 1)F + h) = σ(i,F) + σ(1,h) + (j’ – j – 1)σ(1,F)
(see example in next slide) 24
Acceptance test (2)
Example (F = 5):
d1
• values stored in slack table:
σ(1,1),σ(1,2),σ(1,3),σ(1,4),σ(1,5),
σ(2,2),σ(2,3),σ(2,4),σ(2,5), d3 d2
σ(3,3),σ(3,4),σ(3,5),
σ(4,4),σ(4,5),
d4
σ(5,5)
• (5+4+3+2+1 = (5+1)*5/2
= 15 values stored)
0.5, 1.5, 3.5, 4.5, 5.5
1, 3, 4, 5
Initial slack from i-th frame of j-th major cycle 2, 3, 4
to h-th frame of j’-th major cycle: 1, 2
1
σ((j - 1)F + i, (j’ - 1)F + h) = σ(i,F) + σ(1,h) + (j’ - j - 1)σ(1,F)
• To compute σ(5,11):
- frame 5 is in major cycle j = 1 (i = 5);
- frame 11 is in major cycle j’ = 3 (h = 1):
σ(5,11) = σ(5,5) + σ(1,1) + (3-1-1)*σ(1,5) = 1 + 0.5 +1*5.5 = 7 25
• for the second step of the acceptance test of a new sporadic job S(d,e), the
scheduler needs to compute, for every sporadic job Sk already accepted:
- ξk – the execution time of the portion of Sk that has been completed at the
beginning of the current frame t;
- the current slack σc(t,l ) available for S in frames t to l (before d):
Mode changes
General workloads
• Clock-driven approach is applicable also to other types of
workload:
- jobs not executed on a CPU (e. g. bus arbitrator),
- jobs not characterized by the periodic task model.
• Whenever jobs parameters are known a priori a static
schedule can be computed off-line (taking into account also
other types of constraints, besides release times and
deadlines, such as precedence and resource contention);
• The static schedule can be stored as a table and used by the
same static scheduler used for periodic tasks.
36
Multiprocessor scheduling
38
INF algorithm
• The INF algorithm is performed in 2 steps:
- step 1: find all the possible frame sizes of the system that
meet the frame size constraints 2 and 3 (slide 6) but not
necessarily constraint 1;
- step 2: apply INF algorithm starting with the largest possible
frame.
• Example (slide 11):
- T1 = (4,1); T2 = (5,2,7) and T3 = (20,5)
- frame sizes 2 and 4 meet constraints 2 and 3, but not 1.
• The INF algorithm iteratively tries to find a feasible cyclic
schedule of the system for a possible frame size at a time,
starting with the largest value.
39
Network-flow graph
• The algorithm used in each iteration is based on the network-flow
formulation of the preemptive scheduling problem. In this formulation:
- we ignore the tasks to which the jobs belong;
- we name the jobs in a major cycle of F frames as J1, J2, ..., JN;
- the constraints are represented by graph.
• The graph contains the following vertices and edges:
- Job vertex Ji, I = 1, ..., N
- Frame vertex j, j = 1, ..., F
- 2 additional vertices: source and sink.
- Edges from job v. to frame v. (Ji,j ) if job Ji can be scheduled in frame j
edge capacity = f (amount of time available in frame j ).
- Edges from source to every job vertex Ji
edge capacity = ei (amount of time required by job Ji ).
- Edges from every frame vertex to the sink
edge capacity = f (amount of time available in a frame).
• Edges are labeled with 2 numbers {(c),f }; c = capacity, f = flow. 40
Network-flow graph (2)
• Place jobs in frames that contain their feasible interval (table above).
• Draw network flow graph and find maximum flow (next slide).
44
Network-flow graph example 2
J11 F1
(4),3
(4),4
(3),3 (4),1
J12
(3),3
(4),3 F2
J13
(4),3
(3),3
(4),3
J22 F3
(1.5),1.5 (4),1 (4),4
(2),1.5 F2
J12 (2),2
(2),0.5
(3),3
(2),1.5 F3
(2),2
(2),0.5
J13
(3),3
J21
(2),1.5
(1.5),1.5 F5 (2),2
(2),0.5
(2),1.5 (2),2
(1.5),1.5
J22 F6
(2),0.5
(2),1.5 F2
J12 (2),2
(2),0.5
(3),3
(2),1.5 F3
(2),2
(2),0.5
(3),3
J13
source (2),1.5 sink
F4 (2),2
(2),0.5
J21
(2),1.5
(1.5),1.5 F5 (2),2
(2),0.5
(2),1.5 (2),2
(1.5),1.5 J22 F6
(2),0.5
d2,2
J1,1A J2,1A J1,1B J2,1B J1,2A J2,1C J1,2B J2,2A J1,3A J2,2B J1,3B J2,2B
0 1 2 3 4 5 6 7 8 9 10 11 12
48
Clock-driven scheduling: pros
• The clock-driven approach has many advantages:
- conceptual simplicity;
- we can take into account complex dependencies, communication delays,
and resource contentions among jobs in the choice and construction of the
static schedule;
- static schedule stored in a table; change table to change operation mode;
- no need for concurrency control and synchronization mechanisms;
- context switch overhead can be kept low with large frame sizes.
• It is possible to further simplify clock-driven scheduling:
- sporadic and aperiodic jobs may also be time-triggered (interrupts in
response to external events are queued and polled periodically);
- the periods may be chosen to be multiples of the frame size.
• Easy to validate, test and certify (by exhaustive simulation and testing).
• Many traditional real-time applications use clock-driven schedules.
• This approach is suited for systems (e.g. small embedded controllers) which
are rarely modified once built.
49
50