lecture note #5: task scheduling (2) eecs 571 principles of real … · 2010-10-06 · lecture note...

42
1 Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems Kang G. Shin EECS Department University of Michigan

Upload: others

Post on 02-Apr-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

1

Lecture Note #5: Task Scheduling (2)EECS 571

Principles of Real-Time Embedded Systems

Kang G. ShinEECS Department

University of Michigan

Page 2: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

2

Priority-Driven Scheduling of Periodic Tasks

Why priority-driven scheduling?use priority to represent urgency/importance easy implementation of scheduler (compare task priorities and dispatch tasks accordingly)tasks can be added or removed easilyno direct control of execution instant

How can we analyze the schedulability if we don’t know when a task is to be executed?Let’s begin a deterministic case in a single processor

Independent periodic tasks Relative deadline = periodPreemptable without any limit no overhead for context switch

Page 3: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

3

Priority-Driven SchedulesAssign priority when jobs arrive

static -- all jobs of a periodic task have the same fixed prioritydynamic -- different priorities to individual jobs of a periodic taskrelative priorities don’t change while jobs are waiting for execution

Static priority schedulesRate-monotonic (RM) -- the higher the task frequency, the higher its priorityDeadline-monotonic (DM) – the shorter relative deadline, the higher priority

Dynamic priority schedulesEDF -- earliest deadline firstLSTF (MLF)-- least slack time (laxity) first

Schedulable utilization: a scheduling algorithm can feasibly schedule any set of priority tasks if the total utilization is equal to or less than its schedulable utilization

Page 4: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

4

EDF Schedule Optimal for uniprocessor systems and preemptable tasksHow do we know if a set of periodic tasks are schedulable under EDF?If we know the schedulable utilization SU of EDF, then any set of tasks is schedulable as long as U ≤ SU

Theorem: A set of n periodic tasks can be scheduled by EDF iff

Proof the only-if part is obvious the if part --- show if there is a job misses its deadline, then U > 1

11

≤= ∑=

n

i i

i

peU

Page 5: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

5

Extension of EDF Schedulable Utilization

If Di ≥ pi, EDF is schedulable iff U ≤ 1What can we do if Di < pi

density of task k : δk = ek / min(pk,Dk)EDF is schedulable if the total density is equal to or less than 1proof: if there is a job missing its deadline, then the total density > 1there is no “only-if” part ---- if the total density > 1, EDF may or may not be schedulable

If Di ≥ pi, LSTF is schedulable iff U ≤ 1Predictable for uniprocessor preemptive scheduling of independent tasksRobust

independent of phasesperiods are lower bound ⇒ applicable to sporadic tasks with minimum separations

Page 6: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

6

A digital robot with EDF schedulecontrol loop: ec ≤ 8ms at 100HzBIST (Built-In-Self-Testing): eb ≤ 50msgiven

BIST can be done every 250ms

Add a telemetry task to send and receive messages with et ≤ 15ms if BIST is done every 1000msgiven

the telemetry task can have a relative deadline of 100ms⇒ sending or receiving must be separated by at least 100ms

150108

≤+=+b

bc puu

115100050

108

≤++=++t

bc Dutuu

Example of EDF Schedule

Page 7: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

7

Rate-Monotonic Scheduling AlgorithmLiu and Layland 1973

A base case: no additional overhead, simple periodic tasks with pi =DiAssign priorities according to their periods

Ti has a higher priority than Tk if i < k ( pi < pk )Is RM optimal? ⇒ if there is a feasible fixed-priority schedule, then so is RMHow do we know RM is feasible ⇒ schedulability test

Results:RM is optimal if pi ≥ Disufficient condition ⇒ utilization test

a complete test ⇒ what is the worst-case response time given all possible arrivals and preemptions

)12( /1

1−≤=∑

=

nn

i i

i npeU

Page 8: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

8

T1 T2 T1, T2 T2 T1

Critical InstantCritical instant of Ti: a job of Ti arriving at the critical instant x* has a maximum response time, i.e., Ri (x*) ≥ Ri(x), ∀ x where Ri(x) is response time of task Ti that arrived at time xIf we can find the critical instant of Ti, then

check whether all jobs of Ti meet their deadlineslet’s increase ei until the maximum response time = Di

⇒ schedulable utilizationIn-phase instant is critical: all higher priority tasks are released at the same instant of Ji,c (assume all jobs are completed before the next job is released.)

which T2 has the maximum response time?

Page 9: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

9

Schedulability Test: Time-Demand Analysis

Consider in-phase instant onlyIf Ji is done at t, then the total work must be done in [0,t] is (from Ji and all higher priority tasks): time demand function

Can we find a t ≤ Di such thatwi(t) ≤ t

cannot check all t ∈ [0, Di]check all arrival instants and Di

The completion time of Ji satisfies

k

i

k kii e

ptetw )(

1

1∑−

=⎥⎥

⎤⎢⎢

⎡+=

k

i

k ki e

ptet

1

1∑−

=⎥⎥

⎤⎢⎢

⎡+=

t

w(t)

time Di

Page 10: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

10

Schedulability TestEDF has a schedulable utilization of 1, how about RMS?If Di=pi, the schedulable utilization exists

if U ≤ n ( 21/n - 1 ), doneelse do time-demand analysis

if Di < pi, do time-demand analysis

if Di > pi, there may be more than one job of task i in the systemexamine all jobs of task i in a level-i busy interval (in-phase)the following equations represent this case:

)()1( for )( ,

1

1, twtpje

ptejtw jiik

i

k kiji ≤<−⎥

⎤⎢⎢

⎡+= ∑

=

iiji pjpjtwt )1())1((, −−−−=

Page 11: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

11

Schedulable Utilization of RMS

Must be less than 1Let’s consider two tasks and relative deadline=period

T2 can only be executed when T1 is not in the system

Let p2 < 2p1. Determine the maximum schedulable e2 If p2 < p1+e1, max(e2)=p1-e1 ⇒ U=e1/p1+(p1-e1)/p2

Else, max(e2)=p2-2e1 ⇒ U=e1/p1+(p2-2e1)/p2

T1 T1 T1

0 p1 2p1

p2

p2maximal e2

Page 12: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

12

Schedulable Utilization of RMS

Given e1, p1, and p2, plot UThe minimum U occurs when

p2=p1+e1

where U= e1/p1+(p1-e1)/(p1+e1)

What is the minimum U ?take the derivative wrt to p1 and set dU/dp1=0we will get e1=(21/2-1)p1 and U=0.828…

p2=p1 2p1

U

1

Page 13: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

13

T1

T2

T3

T4

T5p5

Schedulable Utilization of RMAU ≤ n ( 21/n - 1 )Is there a case that is feasible and gives the minimum schedulable utilizationWhen pn ≤ 2 p1

processor must be busy in [0,pn]become unscheduable if we increase any ei

processor will be idle if we increase pi

Page 14: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

14

What do we have from the timeline diagram?ek = pk+1 - pk for k=1,2,..,n-1en = p1 - 2(e1 + e2 + . . . . + en-1) =2p1 - pn

Can we increase e1 and decrease ek by the same amount still schedulable for the 1st arrival of all tasksutilization is higher

Can we decrease e1 and increase ek

When will U be minimum ? ----- when q2,1=q3,2= . . . = 2/n

nqqq

qqq

pp

pp

pp

ppU

nnnn

nn

n

−++++=

−+−++−+−=

−−

1,2,31,21,2,31,2

1

12

3

1

2

.....2.....

)12()1(....)1()1(

Schedulable Utilization of RMA

Page 15: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

15

Tk

Tn

Tk

Tn pn

lpk

Schedulable Utilization of RMAWhen pn > 2pk and schedulable

construct a new task set that is schedulable and pn ≤ 2 pk

the original set has a higher utilization

Page 16: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

16

Schedulability: Response time test

Theorem: for a set of independent, periodic tasks, if each task meets its first deadline, with worst-case task phasing, the deadline will always be met.Response Time (RT) test: let an = response time of task i. an may be computed by the following iterative formula:

Test terminates when an+1 = an

Task i is schedulable if its response time is before its deadline: an ≤ pi

∑∑=

=+ =⎥

⎤⎢⎢

⎡+=

i

1jj0j

1i

1j j

ni1n ea where e

paea

Page 17: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

17

Necessary and Sufficent RM-Schedulability

Theorem 3.4. Given a set of n periodic tasks with P1≤ P2≤L ≤ Pn, task Ti can be feasibly scheduled using RM iff Li = min0<t ≤ Pi

Wi(t)/t ≤ 1, where Wi(t)= ∑j=1i ej dt/Pje.

Practical Question: How to check for Wi(t) ≤ t easily?Only need to compute Wi(t) at τi = kPj, j=1,2,L, i; k= 1,L, b Pi/Pj c

Two RM-schedulability conditions:If mint ∈ τi

Wi(t) ≤ t, then Ti is RM-schedulable.If maxi∈ {1,L,n} mint ∈ τi

Wi(t)/t ≤ 1, then the entire task set is RM-schedulable.

Page 18: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

18

Example: UB Test

e p U

Task τ1 20 100 0.200

Task τ2 40 150 0.267

Task τ3 100 350 0.286

Total utilization is .200 + .267 + .286 = .753 < U(3) =.779

The periodic tasks in the example are schedulable according to the UB test.

Page 19: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

19

Example: Applying RT Test (1)

If we increase the compute time of 1ז from 20 to 40; is the task set still schedulable?Utilization for the first task : 40/100=0.4 < U(1)Utilization of first two tasks: 0.667 < U(2) = 0.828

First two tasks are schedulable by UB test

Utilization of all three tasks: 0.953 > U(3) = 0.779UB test is inconclusiveNeed to apply RT test

Page 20: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

20

Example: Applying RT Test (2)

Use RT test to determine if 3ז meets its first deadline: i = 3

2608080100)40(150180)40(

100180100

epaee

paea

1801004040eeeea

j

2

1j j

03j

1i

1j j

0i1

321

3

1jj0

=++=⎥⎥⎤

⎢⎢⎡+⎥⎥

⎤⎢⎢⎡+=

⎥⎥

⎤⎢⎢

⎡+=⎥

⎤⎢⎢

⎡+=

=++=++==

∑∑

=

=

=

Page 21: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

21

Example: Applying RT Test (3)

a3 = a2 = 300 Done!

Task is schedulable using RT test.a3 = 300 < p3 = 350

300)40(150300)40(

100300100e

paea

300)40(150260)40(

100260100e

paea

j

1i

1j j

2i3

j

1i

1j j

1i2

=⎥⎥⎤

⎢⎢⎡+⎥⎥

⎤⎢⎢⎡+=⎥

⎤⎢⎢

⎡+=

=⎥⎥⎤

⎢⎢⎡+⎥⎥

⎤⎢⎢⎡+=⎥

⎤⎢⎢

⎡+=

∑−

=

=

Page 22: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

22

(Another) Example 3.6Task set: {T1, T2, T3, T4} = { (20, 100), (30, 150), (80, 210), (100,400)}.Sets of time points of interest:τ1 = {100}τ2 = {100, 150}τ3 = {100, 150, 200, 210}τ4 = {100, 150, 200, 210, 300, 400}

Schedulability conditions:T1 is RM-schedulable iff e1 ≤ 100T2 is RM-schedulable iff

e1 + e2 ≤ 100 OR2e1 + e2 ≤ 150

T3 is RM-schedulable iffe1 + e2 + e3 ≤ 100 OR2e1 + e2 + e3 ≤ 150 OR2e1 + 2 e2 + e3 ≤ 200 OR3e1 + 2 e2 + e3 ≤ 210

T4 is RM-schedulable iff L

Page 23: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

23

Modeling Task-Switching

C1

S

C1

C2

C1

C2

τ1

τ2

τ3

C1

40 40

0 100 200

C1C1 C1

e1 S

C2C1 C1

C1

S e2 S S

timep1 p2 2p1

i

ii p

S2eU +=

Two scheduling actions per task(start of period and end of period)

Page 24: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

24

Sporadic Tasks

Sporadic tasks have a min interarrival intervalFor purpose of schedulability analysis:

Consider them periodic, orUse a periodic polling server (PPS) to ``serve'' sporadic tasks, orUse a deferred server (DS): Schedulability conditionU ≤ 1-Us if Us ≤ 0.5U ≤ Us if Us > 0.5What shall we do if there are no sporadics to execute?

PPS: Keep CPU idle DS: Execute other tasks.

Page 25: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

25

Transient Overload

Question: What if the task with a smaller period is not important to the underlying application?Answer: Consider period transformation, period aggregation or period splittingExample: Consider the following unschedulable task set:

Page 26: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

26

Transient Load, cont’d

Solution 1: reduce T3’s priority by lengthening its period, possible only if T3's relative deadline can be greater than its original period. In such a case, replace T3 by two tasks T3

0 and T3’’, each with period 420, WC exec times e30 = e3’’

= 80, avg exec times a30 =a3’’ =40. T3

0 and T3’’ must be phased to be released 210 time units apart. If the set {T1, T2, T3

0, T3’’, T4} is RM-schedulable, done.

Solution 2: increase T4's priority by splitting each invocation into two: T4

0: e40 = e4/2, a4

0 = a4/2, P40 = P4/2

{T1, T2, T4} or {T1, T2, T40} are schedulable

Page 27: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

27

Period Transformation

When the task set T is RM-unscheduable, PT decomposes T = C U NC, whereC = {all critical tasks} U {some non-criticals}NC = {remaining non-criticals}

Pc,max ≤ Pn,min

C is RM-schedulable under worst-case execution times.

Page 28: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

28

Summary of discussion so far

System model parameters: task and processor sets, task precedence constraints, task release and execution times, deadlines, periods, L

Problem: Find a feasible schedule

Rate monotonic scheduling of periodic tasks without precedence constraints or resource requirements

Sufficient RM-schedulability condition:\U= ∑i=1

n ei/Pi ≤ n (21/n - 1) → 0.69 as n→∞.

Necessary and sufficient RM-schedulability condition: Ti is schedulable iff the equation t = ∑j=1

i ej d t/Pje has a solution for t < Pi.

Handling sporadic tasks: periodic polling server, deferred serverTransient overload and period transformation.

Page 29: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

29

Schedulability with Interrupts

Interrupt processing can be inconsistent with RM priority assignment.

interrupt handler executes with higher priority irrespective of its periodinterrupt processing may delay execution of tasks with shorter periods

Effects of interrupt processing must be accounted for in schedulability model.

Task(i) Period(p) WCET(e) Priority Deadline(D)

τ3 200 60 HW 200

τ1 100 20 High 100

τ2 150 40 Medium 150

τ4 350 40 Low 350

Page 30: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

30

UB Test with Interrupt Priority

Test is applied to each taskDetermine effective utilization (fi) of each task i using

fi =

Compare effective utilization against bound, U(n).n = num(Hn) + 1

num(Hn) = the number of tasks in the set Hn

∑∑∈∈

++1n Hk

kii

i

Hj j

j ep1

pe

pe

Preemption from the tasks that can hit more than once(with period less than Di)

Execution of a task under test

Preemption from tasks that can hit only once(with period greater than Di )

Page 31: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

31

UB Test with Interrupt Priority: τ3

For τ3, no tasks have higher priority: H = Hn =H1 = { }.

f3 =

Note that utilization bound is U(1): num(Hn) = 0.

)1(U0pe0

3

3 ≤++

f3 = 0.13.020060

pe

3

3 <==

Page 32: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

32

UB Test with Interrupt Priority: τ1

For τ1, τ3 has priority over τ1 : H = {τ3}; Hn = {}; H1 = {τ3}.

f1 = )1(Uep1

pe0

3kk

11

1 ≤++ ∑=

Utilization bound is U(1) since num(Hn) = 0.

f1 = 0.1800.010060

10020

pe

pe

1

3

1

1 <=+=+

Page 33: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

33

UB Test with Interrupt Priority: τ2

For τ2 : H={τ1, τ3}; Hn={τ1 }; H1={τ3 };

Note that utilization bound is U(2): num(Hn) = 1.

)2(Uep1

pe

pe

f3k

k22

2

1j j

j2 ≤++= ∑∑

==

828.0867.020060

15040

10020f

3

3

2

2

1

12 >=++=++=

pe

pe

pe

Page 34: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

34

UB Test with Interrupt Priority: τ4

H={τ1, τ2, τ3}; Hn={τ1 , τ2, τ3 }; H1={};

Note that utilization bound is U(4): num(Hn) = 3.

)4(U0pe

pe

f4

4

3,2,1j j

j4 ≤++= ∑

=

756.0882.035060

20060

15040

10020

pe

pe

pe

pef

4

4

3

3

2

2

1

14

>=+++=

+++=

Page 35: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

35

Priority Inversion in Synchronization

τ1(H)Blocked

τ2(M)

τ3(L)

Time

τ1 :{…P(S1)…V(S1)…}

τ3 :{…P(S1)…V(S1)…} S1 unlockedAttempt to lock S1 (blocked) S1 locked

S1 unlockedS1 locked

Page 36: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

36

Priority Inversion

Delay to a task’s execution caused by interference from, or blocking by, lower priority tasks is known as priority inversionPriority inversion is modeled by blocking timeIdentifying and evaluating the effect of sources of priority inversion is important in schedulability analysisSources of priority Inversion

Synchronization and mutual exclusionNon-preemtable regions of codeFIFO (first-in-first-out) queues, e.g., Windows DPC

Page 37: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

37

Accounting for Priority Inversion

Recall that task schedulability is affected bypreemption: two types of preemption

can occur several times per task periodcan occur once per period

execution: once per periodblocking: at most once per period for each source

The schedulability formulas are modified to add a “blocking” or “priority inversion” term to account for inversion effects

Page 38: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

38

UB Test with Blocking

Include blocking time in calculation of effective utilization for each task:

Hn Preemption(can hit n times)

Execution

Blocking H1 Preemption(can hit once)

∑∑∈∈

+++=1n Hk

kii

i

i

i

Hj j

ji e

p1

pB

pe

pe

f

Page 39: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

39

Blocking is also included in the RT test

Perform test as before, including blocking effect

Response Time Test with Blocking

=

=+

+=

⎥⎥

⎤⎢⎢

⎡++=

i

1jji0

j

1i

1j j

nii1n

eBa where

epaeBa

Page 40: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

40

Consider the following examplePeriodic tasks

What is the worst case blocking effect (priority inversion) experienced by each task ?

Example: Considering Blocking

25 msec

100 msec

50 msec

200 msec

100 msec

300 msec

10 msec30 msec

Data Structure

τ1

τ2

τ3

Page 41: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

41

Example: Adding Blocking

Task τ2 does not use the data structure. Task τ2 experiences no priority inversionTask τ1 shares the data structure with τ3 . Task τ1 may have to wait for τ3 to complete its critical section. But worse, if τ2 preempts while τ1 is waiting for the data structure, τ1 may have to wait for τ2’s entire computation.This is the resulting table

task Period Execution Time

Priority Blocking delay

Deadline

τ1100 25 High 30+50 100

τ2200 50 Medium 0 200

τ3300 100 Low 0 300

Page 42: Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real … · 2010-10-06 · Lecture Note #5: Task Scheduling (2) EECS 571 Principles of Real-Time Embedded Systems. Kang

42

UB Test for Example

UB test with blocking:

∑∑∈∈

+++=1n Hk

kii

i

i

i

Hj j

ji e

p1

pB

pe

pe

f

00.105.110080

10025

pB

pef

1

1

1

11 >=+=+=

)2(U5.020050

10025

pe

pef

2

2

1

12 <=+=+=

)3(U84.0300100

20050

10025

pe

pe

pef

3

3

2

2

1

13 >=++=++=

Not schedulable

with additional RT test, τ3 is shown to be schedulable