Sunteți pe pagina 1din 18

© Adeel Pasha, LUMS, Spring’19

EE-522: Lecture 3

Basics of Real-Time Scheduling-II


Clock-Driven Schedulers

1 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Tasks Classification

2 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Periodic Task (Ti) = (φi, ei, pi, di)


φ = Phase or First Activation Date p = Period
e = Worst Case Execution Time (WCET) d = Relative Deadline

Example: track correction task in a rocket Ti = (2000ms, 8ms, 80ms, 50ms)

Di (1)=2050
di=50 ei=8

pi=80
Ti Ti
Φi=2000
(1) (2)
0
Arrival or activation of Ti (1)
3 EE-522: Embedded Systems 1/28/2019
© Adeel Pasha, LUMS, Spring’19

Sporadic Task (Ti) = (ei, gi, di)


 No fixed period
 Random arrival
 E.g. SOS call from an aircraft
 e = WCET
 d = deadline
 g = minimum separation between two instances
 Two instances of a same task can’t overlap

Aperiodic Task (Ti) = (ei, gi=0, di)


 Similar to sporadic but g can be 0
 i.e. occurrences can overlap

4 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Real-Time Task Scheduling

Uniprocessor

5 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Task Scheduling: Notions


 Valid Schedule
 Conditions to be met
 No overlapping among different tasks’ instances
 No task scheduled before its arrival
 Resource constraints and task precedence is observed
 No task misses its deadline
 Proficient Schedule
 Sh2 can schedule N tasks {T1, T2, …, TN}
 Sh1 will be called better/proficient than Sh1 if:
 Sh1 schedules N+1 task => {T1, T2, …, TN} + TN+1
 Optimal Schedule
 Sh3 is an optimal schedule if there exist no proficient schedule
than Sh3
6 EE-522: Embedded Systems 1/28/2019
© Adeel Pasha, LUMS, Spring’19

Task Scheduling: Notions


 Scheduling Points

 Preemptive Scheduling

 Processor Utilization
 ui = avg. time for which a task Ti executes on processor
 “U” can be at most 1 for uniprocessor system
n
ei
U=
ei
ui =
pi i =1 pi

7 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Task Scheduling: Notions


 Task Jitter
 Arrival Jitter
 Completion Jitter

 Sources of Jitter
 In arrival?
 Imprecise clocks, network congestion or signal delays
 In completion?
 Scheduling delays after arrival

8 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Classification of RT-Task Scheduling


 Clock-Driven
 Table-Driven
 Cyclic

 Event-Driven
 Simple Priority Based
 Rate Monotonic Analysis (RMA)
 Earliest Deadline First (EDF)

 Hybrid
 Round Robin

9 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Classification of RT-Task Scheduling


 Planning-based
 Best Effort

10 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Clock-Driven Schedulers

11 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Clock-Driven Schedulers
 Offline or Static Schedulers
 Table-Driven
 Cyclic
 Pros:
 Very Little Timing Overhead
 Cons:
 Cannot handle sporadic or aperiodic tasks satisfactorily

12 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Table-Driven Scheduler

13 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Table-Driven Schedulers
 Schedule Table
 Pre-computed schedule is stored in a table
 Programmer can choose his/her own task schedule,
store it and use it
 Size of the table?
 Answer is Major Cycle
 Major Cycle = LCM*(p1, p2, p3, … ,pn) (also called hyperperiod)
 Example:
 T1 (e1=5ms, p1=20ms)
 T2 (e2=20ms, p2=50ms)
 T3 (e3=30ms, p3=100ms)
* LCM: Least Common Multiple
 Major Cycle=?

14 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Table-Driven: Major Cycle

Task-1
Major Cycle (M)/ Task-2
Hyperperiod (H) Task-3
Task-4

15 EE-522: Embedded Systems 1/28/2019


© Adeel Pasha, LUMS, Spring’19

Table-Driven: Major Cycle


Task-1 (ϕ1=2ms, e1= 0.5ms, p1=12ms)
Task-2 (ϕ2=6ms, e2= 1.0ms, p2=24ms)
Task-3 (ϕ3=8ms e3= 1.5ms, p3=12ms)
Task-4 (ϕ4=18ms, e4= 0.5ms, p4 = 48ms)
Arrival Time
H or M = 48 Task No.
(ms)
1 2
2 6
3 8
1 14
4 18
… …
3 44
16 EE-522: Embedded Systems 1/28/2019
k LUMS,
© Adeel Pasha, tk Spring’19
T(tk)

Table-Driven: Table Construction


0 0 I
1 2 T1

Task-1 (ϕ1=2ms, e1= 0.5ms, p1=12ms) 2 2.5 I

Task-2 (ϕ2=6ms, e2= 1.0ms, p2=24ms) 3 6 T2

Task-3 (ϕ3=8ms e3= 1.5ms, p3=12ms) 4 7 I

Task-4 (ϕ4=18ms, e4= 0.5ms, p4 = 48ms) 5 8 T3


6 9.5 I
 Store pre-computed schedule as a table 7 14 T1

 Carries every task instance’s arrival and completion stamps 8 14.5 I

 The OS creates all the tasks that are to be executed:


9 18 T4
10 18.5 I
 Allocates sufficient memory for the code and data of every task 11 20 T3
 Brings the code executed by the task into memory 12 21.5 I

 Scheduler sets the hardware timer to interrupt at the 13 26 T1

first decision time, tk=0 14 26.5 I


15 30 T2
 On receipt of an interrupt at tk: 16 31 I
 Scheduler sets the timer interrupt to expire at tk+1 17 32 T3
 Interrupt the aperiodic job if running; 18 33.5 I

 If T(tk) = I and aperiodic job waiting, start aperiodic job 19 38 T1


20 38.5 I
 Else, let T(tk) execute
21 44 T3
 Go to sleep and give control to T(tk) 22 45.5 I
17 EE-522: Embedded Systems
23 1/28/2019
48 T4
© Adeel Pasha, LUMS, Spring’19

Table-Driven: Implementation

H = Hyperperiod or Major Cycle

N = number of entries in the


schedule of each hyperperiod

gives the absolute time value of


18 EE-522: Embedded Systems kth entry in future major cycles 1/28/2019

S-ar putea să vă placă și