Cpr E 458558 RealTime Systems Combined Scheduling of

  • Slides: 21
Download presentation
Cpr. E 458/558: Real-Time Systems Combined Scheduling of Periodic and Aperiodic Tasks Cpr. E

Cpr. E 458/558: Real-Time Systems Combined Scheduling of Periodic and Aperiodic Tasks Cpr. E 458/558: Real-Time Systems (G. Manimaran) 1

Assumptions & Issues • RMS scheduling algorithm used • All periodic tasks start at

Assumptions & Issues • RMS scheduling algorithm used • All periodic tasks start at time t=0 (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 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 2

Background Scheduling Algorithm • No server is created. • Aperiodic tasks are executed when

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 High priority Queue Aperiodic tasks CPU FIFO/EDF… Low priority Queue Cpr. E 458/558: Real-Time Systems (G. Manimaran) 3

Normal RMS schedule: Notice the holes Task set: Ti = (ci, pi) T 1

Normal RMS schedule: Notice the holes Task set: Ti = (ci, pi) T 1 = (2, 6) and T 2 = (4, 10) Schedulability check: 2/6 + 4/10 = 0. 33 + 0. 40 = 0. 73 ≤ 2(√ 2 -1) = 0. 82 T 11 0 Background scheduling: basic idea -Scheduling aperiodic tasks in holes like this T 12 2 6 8 10 Hole T 2 1 0 2 T 2 2 6 10 Schedule continues Cpr. E 458/558: Real-Time Systems (G. Manimaran) 4

Background Scheduling: Example T 11 2 6 T 2 0 2 Aperiodic tasks 0

Background Scheduling: Example T 11 2 6 T 2 0 2 Aperiodic tasks 0 T 2 1 T 2 2 6 1 2 Hole 218 2 units 8 Hole 1 10 2 units 1 unit 0 T 13 T 12 6 10 High priority Queue Aperiodic tasks 16 2 A 1 Periodic tasks 14 12 T 2 2 10 12 14 16 T 14 18 A 2 18 RMS FIFO CPU Low priority Queue Cpr. E 458/558: Real-Time Systems (G. Manimaran) 5

Combined Scheduling • Creating a periodic server Ts=(Cs, Ps) for processing aperiodic workload. Create

Combined 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 server’s 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) Cpr. E 458/558: Real-Time Systems (G. Manimaran) 6

Polling Server • A periodic server is created. • If there are no aperiodic

Polling 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 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 7

Ts should beserver: scheduled This aperiodic task here Polling Example ascannot per RMS. However,

Ts should beserver: scheduled This aperiodic task here Polling Example ascannot per RMS. However, as be scheduled therenow is no task to as aperiodic there is no Task set: Ti = Task (ci, piset: ) Ti = (ci, pi) schedule, suspends server. Ts available tillitself T 1 = at (1, 4) , T 2 T 1 = (2, 6) = (1, 4) and , T 2 Ts==(2, 6) (2, 5)and Ts = (2, 5) and is again available only time =5 time = 5 T 1 0 8 4 T 2 Aperiodic 1 3 tasks 0 6 2 2 16 Server becomes available and can schedulesschedule for 2 units. aperiodic task However, aperiodic 7 A 1 for 10 2 units 12 A 2 13 needs 15 only till Waits tilltask Waits time = 10 1 time = 15 1 A 1 5 12 8 2 A 2 10 13 A 3 20 24 18 20 Preempted by T 1 24 A 3 15 16 17 18 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 24 8

Polling server: Example (no animations) Task set: Ti = (ci, pi) T 1 =

Polling server: Example (no animations) Task set: Ti = (ci, pi) T 1 = (1, 4) , T 2 = (2, 6) and Ts = (2, 5) T 1 0 8 4 12 16 20 24 T 2 Aperiodic 1 3 tasks 0 6 2 2 7 10 1 A 1 5 8 12 13 2 A 2 10 15 13 A 3 18 A 3 15 16 17 18 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 24 9

Polling server: Schedulability Analysis • Schedulability analysis involves – Schedulability of periodic tasks –

Polling 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: ∑i=1 to n (Ci / Pi) + (Cs / Ps) ≤ (n+1)[2 1/(n+1) -1] Cpr. E 458/558: Real-Time Systems (G. Manimaran) 10

Polling server: Schedulability Analysis • Aperiodic task guarantees: – Consider a single aperiodic task

Polling 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 2 Ps ≤ Da Ca Cs 0 ra Ps Ps da Da > Ps Cpr. E 458/558: Real-Time Systems (G. Manimaran) 11

Polling server: Schedulability Analysis • Aperiodic task guarantees: – For arbitrary computation times, the

Polling 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 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 12

Deferrable Server • A periodic server task is created. • When the server is

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. Cpr. E 458/558: Real-Time Systems (G. Manimaran) 13

Deferrable Server (Contd. ) • The computation time allowance for the server is replenished

Deferrable 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 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 14

Deferrable Server: Example Server defers its capacity to handle any future aperiodic task T

Deferrable Server: Example Server defers its capacity to handle any future aperiodic task T 1 0 4 Task set: Ti = (ci, pi) T 1 = (1, 4) , T 2 = (2, 6) and Ts = (2, 5) 8 12 16 T 2 Aperiodic 1 tasks 0 2 2 3 Don’t need 6 to wait till time = 5 A 1 Don’t need to wait 10 till 12 time = 10 8 1 4 A 2 8 9 13 Why is A 2 not scheduled at time = 8 itself? ? ? 15 18 20 24 T 1 runs from 8 to 9 and hence Ts a lower priority task cannot run till 9 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 24 15

Priority Exchange Server • A periodic server task is created. • When the server

Priority Exchange Server • A periodic server task is created. • When the server invoked, the server runs if there 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. Cpr. E 458/558: Real-Time Systems (G. Manimaran) 16

Priority Exchange Server (Contd. ) • In this way, the priority of the server

Priority 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. Cpr. E 458/558: Real-Time Systems (G. Manimaran) 17

Priority Exchange server: example Aperiodic task exists to utilize the server capacity TH TS

Priority Exchange server: example Aperiodic task exists to utilize the server capacity TH TS Cs Tf TL No more Aperiodic tasks Server to executing at TL’s utilize the server capacity priority when there aperiodic tasks to serve TH TS TL e Tf Cs - e TL executing at the server’s priority TL executing at its own priority Cpr. E 458/558: Real-Time Systems (G. Manimaran) 18

Sporadic Server • This algorithm allows to enhance the average response time for aperiodic

Sporadic 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. Cpr. E 458/558: Real-Time Systems (G. Manimaran) 19

Since no Sporadic server: example aperiodic task is there, the server defers its capacity

Since no Sporadic server: example aperiodic task is there, the server defers its capacity T 1 0 2 T 2 tasks 0 Task set: Ti = (ci, pi) T 1 = (3, 10) , T 2 = (4, 15) and Ts = (2, 8) And, replenishes its capacity at time = current_time + period 10 4 9 2 2 4 15 16 Server has no capacity to handle 1 A 1 12 Server has capacity to schedule A 2 Server schedules the aperiodic task right away with its capacity 5 Aperiodic Server has the highest priority 7 15 18 20 24 A 2 10 12 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 24 20

Priority-driven preemptive scheduling- summary • Scheduling algorithms – RMS & EDF utilization test –

Priority-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 Cpr. E 458/558: Real-Time Systems (G. Manimaran) 21