Professional Documents
Culture Documents
Frame f
hyperperiod H
© R. Bettati
2 f − (t '−t ) ≤ Di
t '−t ≥ gcd( pi , f )
(3) 2 f − gcd( pi , f ) ≤ Di
© R. Bettati
1
CPSC-663: Real-Time Systems Clock-Driven Scheduling
(1) ∀i : f ≥ ei ⇒ f ≥3
( 2) f H ⇒ f = 2,3,4,5,6,10,..
(3) ∀i : 2 f − gcd( pi, f ) ≤ Di ⇒ f = 2,3,4,5,6
© R. Bettati
slice T1 = ( 4, 1, 4 )
T3
T2 = ( 5, 2, 5 )
(1) ⇒ f ≥ 3 ⎫
T31 = ( 20, 1, 20 ) ⎬ f = 4
(3) ⇒ f ≤ 4 ⎭
T32 = ( 20, 3, 20 )
T33 = ( 20, 1, 20 )
scheduling block
1 2 31 1 2 1 32 1 2 1 2 33 …..
0 4 8 12 16 20
H
© R. Bettati
2
CPSC-663: Real-Time Systems Clock-Driven Scheduling
Cyclic Executive
Input: "Stored schedule: L(k) for k = 0,1,…,F-1;
" "Aperiodic job queue.
TASK CYCLIC_EXECUTIVE:
t = 0; /* current time */ k = 0; /* current frame */
CurrentBlock := empty;
BEGIN LOOP
IF <any slice in CurrentBlock is not completed> take action;
CurrentBlock := L(k);
k := k+1 mod F; t := t+1;
set timer to expire at time tF;
IF <any slice in CurrentBlock is not released> take action;
wake up periodic task server to handle slices in CurrentBlock;
sleep until periodic task server completes or timer expires;
IF <timer expired> CONTINUE;
WHILE <the aperiodic job queue is not empty>
wake up the first job in the queue;
sleep until the aperiodic job completes;
remove the just completed job from the queue;
END WHILE;
sleep until next clock interrupt;
END LOOP;
END CYCLIC_EXECUTIVE;
© R. Bettati
• But:
– Aperiodic jobs are typically results of external events.
• Therefore:
– The sooner the completion time, the more responsive the system
– Minimizing response time of aperiodic jobs becomes a design issue.
• Approach:
– Execute aperiodic jobs ahead of periodic jobs whenever possible.
– This is called Slack Stealing.
© R. Bettati
3
CPSC-663: Real-Time Systems Clock-Driven Scheduling
4 9.5 10.5
© R. Bettati
Sporadic Jobs
• Reminder: "Sporadic jobs have hard deadlines; the release time and
"the execution time are not known a priori.
"Worst-case execution time known when job is released.
• Need acceptance test:
J(d,e) sc sc+1 sl d
l
S (c, l ) = ∑ si : Total amount of slack in Frames Fc, …, Fl.
i =c
© R. Bettati
4
CPSC-663: Real-Time Systems Clock-Driven Scheduling
• Alternatives:
– Rescheduling upon arrival.
– Priority-driven scheduling of sporadic jobs.
© R. Bettati
T1
T2
periodic
tasks T3
...
TN
acceptance
test priority
queue processor
reject
aperiodic
© R. Bettati
5
CPSC-663: Real-Time Systems Clock-Driven Scheduling
© R. Bettati
• Define
Si,k : slack in Frames Fi, ..., Fk
• Compute current slack of job with release time in Fc-1 and deadline
in Fl+1:
" "Snewc,l = Sc,l – Σ(dk<d)ek(c)
• Implementation:
– Initially compute Sc,l for newly arriving job. If negative, reject.
– Whenever job with earlier deadline arrives, decrease this value.
If negative, reject new job.
© R. Bettati
6
CPSC-663: Real-Time Systems Clock-Driven Scheduling
J1
F1
J2
F2
...
...
ei Ji Fj f
Source Sink
...
...
Jn-1 Fm-1
Jn Fm
© R. Bettati
• Pros:
– Conceptual simplicity
– Timing constraints can be checked and enforced at frame
boundaries.
– Preemption cost can be kept small by having appropriate frame
sizes.
– Easy to validate: Execution times of slices known a priori.
• Cons:
– Difficult to maintain.
– Does not allow to integrate hard and soft deadlines.
© R. Bettati
7
CPSC-663: Real-Time Systems Clock-Driven Scheduling
© R. Bettati
Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”
© R. Bettati
8
CPSC-663: Real-Time Systems Clock-Driven Scheduling
Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”
© R. Bettati
Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”
© R. Bettati
9
CPSC-663: Real-Time Systems Clock-Driven Scheduling
ABORTION:
Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”
© R. Bettati
EXCEPTIONS:
Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”
© R. Bettati
10