of 5

# Clock Driven

374 views

## Content

CPSC-663: Real-Time Systems

Clock-Driven Scheduling

Cyclic Schedules: General Structure • Scheduling decision is made periodically: Frame f

• Scheduling decision is made ma de perio dically: dically: – choose which job to execute – perform monitoring monitoring and enforcement enforcement oper ope rations •

decision points

: Frames in a hyperperiod. major cycle

Frame Size Constraints • Frames must be sufﬁciently long so that every job can start and complete within a single frame: (1)

f   ! max(ei )

• The hyperperiod hyperper iod must mu st have an integer integer number nu mber of frames: (2)

f   H

(  f  " divides" H )

• For monitoring purposes, frames must be sufﬁciently small that between release time and deadline of every job there is at least one frame: t

t’

t+f

t+2f t’+Di

t’+pi t+3f

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

Frame Sizes: Example • Task set:  pi T 1

=

T 2

=

T 3

=

ei

Di

( 15,

1,

14

)

(

20,

2,

26

)

(

22,

3,

22

)

(1)

\$i :  f   %

( 2) (3)

H

=

660

!

f   % 3

f   H

!

f   2,3,4,5,6,10,..

\$i : 2 f   # gcd( pi,  f  ) "  Di

!

f   2,3,4,5,6

ei

=

=

! possible values for  f   : 3,4,5,6

Slicing and Scheduling Blocks • Slicing

slice T 3

T 1

=

T 2

=

T 3

=

pi ( 4,

ei  Di 1, 4 )

(

5,

2,

5

)

(

20,

5,

20

)

T 1

=

(

4,

1,

4

)

T 2

=

(

5,

2,

5

)

T 31

=

(

20,

1,

20

)

T 32

=

(

20,

3,

20

)

T 33

=

(

20,

1,

20

)

%  f   & 5 # " ?! (3) %  f   \$ 4 ! (1)

%  f   & 3 # " f   4 (3) %  f   \$ 4 ! (1)

=

scheduling block

1 0

2

31 1 4

2

1

32

8

1 12

2

1 16

2

33

…..

20

2

CPSC-663: Real-Time Systems

Clock-Driven Scheduling

Cyclic Executive Stored schedule: L(k) for k = 0,1,…,F-1; Aperiodic job queue. TASK CYCLIC_EXECUTIVE:

t = 0; /* current time */ CurrentBlock := empty;

k = 0; /* current frame */

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;

What About Aperiodic Jobs? • Typically: – Scheduled in the background. – Their execution may be delayed. • 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 .

3

CPSC-663: Real-Time Systems

Clock-Driven Scheduling

Slack Stealing

(Lehoczky et al., RTSS’87)

x k  Amount of time allocated to slices executed during frame F k .

during frame F k :

s k

s k  := f - x k .

• The cyclic executive can execute aperiodic jobs for s k  amount of time without causing jobs to miss deadlines. • Example:

0

4 1.5

8

4

0.5

9.5

2.0 12

16

20

10.5

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 :  J(d,e)

sc

F c-1

F c

sc+1 F c+1

sl  F l

F l+1

S (c, l )

=

! s

i

: Total amount of slack in Frames F c , …, F l .

i c =

• Acceptance Test:

IF S(c,l) < e THEN reject job; ELSE accept job; schedule execution; END;

how?!

4

CPSC-663: Real-Time Systems

Clock-Driven Scheduling

Handling Frame Overruns (I) ABORTION:

Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”

Handling Frame Overruns (II) EXCEPTIONS:

Source: T. P. Baker, Alan Shaw, “The Cyclic Executive Model and Ada”

10

## Recommended

No recommend documents

Or use your account on DocShare.tips

Hide