Title: CprE 458/558: Real-Time Systems
1CprE 458/558 Real-Time Systems
-
- Combined Scheduling of
- Periodic and Aperiodic Tasks
2Assumptions Issues
- RMS scheduling algorithm used
- All periodic tasks start at time t0 (same as
before) - Periodic tasks relative deadlines are equal to
end of period - Arrival times of aperiodic tasks unknown
- Schedulability of periodic tasks
- Response time for aperiodic tasks
- Implementation considerations
3 Background Scheduling Algorithm
- No server is created.
- Aperiodic tasks are executed when there is no
periodic task to execute. - Simple, but no guarantee on aperiodic
schedulability
Periodic tasks
RMS
CPU
High priority Queue
Aperiodic tasks
FIFO/EDF
Low priority Queue
4 Normal RMS schedule Notice the holes
Task set Ti (ci, pi) T1 (2,6) and T2 (4,10)
Schedulability check 2/6 4/10 0.33 0.40
0.73 2(v2 -1) 0. 82
Background scheduling basic idea -- Scheduling
aperiodic tasks in holes like this
T1
T11
T12
Hole
0
2
6
8
10
T2
T21
T22
6
0
2
10
Schedule continues
5Background Scheduling Example
T1
Hole1 2 units
Hole2 2 units
T13
T14
T11
T12
18
0
2
6
8
10
T2
T21
T22
T22
6
14
16
18
0
2
10
12
Aperiodic tasks
A1
A2
6
14
16
18
0
2
10
12
RMS
Periodic tasks
CPU
High priority Queue
FIFO
Aperiodic tasks
Low priority Queue
6Combined Scheduling
- Creating a periodic server Ts(Cs, Ps) for
processing aperiodic workload. Create one or more
server tasks. - Aperiodic tasks are scheduled in the periodic
servers time slots. This policy could be based
on deadline, arrival time, or computation time. - Algorithms all algorithms behave the same
manner when there are enough aperiodic tasks to
execute - - Polling Server (bandwidth non-preserving)
- - Deferrable Server (bandwidth preserving)
- - Priority Exchange Server (bandwidth
preserving) - - Sporadic Server (bandwidth preserving)
7Polling Server
- A periodic server is created.
- If there are no aperiodic tasks at an invocation
of the server (as per RMS), the server suspends
itself during its current period and gets invoked
again at its next period. - If there are enough aperiodic tasks in an
invocation, it serves up to Cs capacity. - The computation time allowance for the server is
replenished at the start of its period - Include Ts in the task set and do schedulability
test - Poor response time for aperiodic tasks
8Polling server Example
This aperiodic task cannot be scheduled now as
there is no server available till time 5
Task set Ti (ci, pi) T1 (1,4) , T2 (2,6)
and Ts (2,5)
Task set Ti (ci, pi) T1 (1,4) , T2 (2,6)
and Ts (2,5)
T1
8
12
16
24
0
4
20
Server becomes available and schedules aperiodic
task A1 for 2 units
Server becomes available and can schedule for 2
units. However, aperiodic task A2 needs only 1
T2
24
1
3
6
7
10
12
13
15
18
20
Waits till time 10
Waits till time 15
Preempted by T1
Aperiodic tasks
A1
A2
A3
A3
2
8
10
13
15
16
17
18
24
5
0
9Polling server Example (no animations)
Task set Ti (ci, pi) T1 (1,4) , T2 (2,6)
and Ts (2,5)
T1
8
12
16
24
0
4
20
T2
24
1
3
6
7
10
12
13
15
18
20
Aperiodic tasks
A1
A2
A3
A3
2
8
10
13
15
16
17
18
24
5
0
10Polling server Schedulability Analysis
- Schedulability analysis involves
- Schedulability of periodic tasks
- Schedulability of Aperiodic tasks
- Schedulability of periodic tasks can be evaluated
by introducing a periodic task equivalent to the
server. Therefore, the schedulability test is
?i1 to n (Ci / Pi) (Cs / Ps) (n1)2 1/(n1)
-1
11Polling server Schedulability Analysis
- Aperiodic task guarantees
- Consider a single aperiodic task Ai, arrived at
ra, with computation time Ca and deadline Da.
Since an aperiodic task can wait at most for one
period before receiving service, if Ca Cs the
request is certainly completed within two server
periods. Thus it is guaranteed if 2Ps Da
Ca
Cs
Ps
Ps
da
0
ra
Da gt Ps
12Polling server Schedulability Analysis
- Aperiodic task guarantees
- For arbitrary computation times, the aperiodic
task is certainly completed in ceil(Ca/Cs) server
periods hence it is guaranteed if - Ps ceil(Ca/Cs) Ps Da
13 Deferrable Server
- A periodic server task is created.
- When the server is invoked with no outstanding
aperiodic tasks, the server does not execute but
defers its assigned time slot. - When an aperiodic task arrives, the server is
invoked (as per RMS) to execute aperiodic tasks
and maintains its priority.
14Deferrable Server (Contd.)
- The computation time allowance for the server is
replenished at the start of its period. - Provides better response time for aperiodic tasks
than Polling server - Under overload, deadlines are missed predictably.
- Similar schedulability test like polling server
15Deferrable Server Example
Task set Ti (ci, pi) T1 (1,4) , T2 (2,6)
and Ts (2,5)
T1
8
12
16
24
0
4
20
Why is A2 not scheduled at time 8 itself???
T2
Dont need to wait till time 10
Dont need to wait till time 5
24
1
3
6
8
10
12
13
15
18
20
T1 runs from 8 to 9 and hence Ts a lower priority
task cannot run till 9
Aperiodic tasks
A1
A2
4
9
2
8
24
0
16Priority Exchange Server
- A periodic server task is created.
- When the server invoked, the server runs if there
are any outstanding aperiodic tasks. - If no aperiodic task exists, the high priority
server exchanges its priority with a lower
priority periodic task for a duration of Cs,
where Cs is the remaining computation time of
the server.
17Priority Exchange Server (Contd.)
- In this way, the priority of the server
decreases, but its computation time is
maintained. - The computation time allowance for the server is
replenished at the start of its period. - As a consequence, the aperiodic tasks get low
preference for execution. Offers worse response
time compared to Deferrable Server. - Better schedulability bound for periodic task set
compared to Deferrable Server.
18Priority Exchange server example
Aperiodic task exists to utilize the server
capacity
TH
Cs
TS
Tf
TL
No more Aperiodic tasks to utilize the server
capacity
Server executing at TLs priority when there are
aperiodic tasks to serve
TL executing at the servers priority
TL executing at its own priority
19Sporadic Server
- This algorithm allows to enhance the average
response time for aperiodic tasks without
degrading the utilization bound for periodic task
set - This is achieved by varying the points at which
the computation time of the server is
replenished, rather than merely at the start of
each server period. - In other words, any spare capacity (i.e., not
being used by periodic tasks) is available for an
aperiodic task on its arrival.
20Sporadic server example
Server has the highest priority
Task set Ti (ci, pi) T1 (3,10) , T2 (4,15)
and Ts (2,8)
And, replenishes its capacity at time
current_time period
T1
10
12
16
24
15
2
0
4
20
Server has capacity to schedule A2
T2
Server schedules the aperiodic task right away
with its capacity
Server has no capacity to handle
24
5
9
15
18
20
Aperiodic tasks
A2
A1
7
12
2
10
24
0
4
21Priority-driven preemptive scheduling- summary
- Scheduling algorithms
- RMS EDF utilization test
- RMS DMS Exact analysis
- Combined Scheduling
- Polling, Deferrable, PE, Sporadic servers
- Resource Access Control
- Priority Inversion
- Priority Inheritance Pri. Ceiling Protocols
- Schedulability tests accounting Blocking