real time operating systems schedulability - part 3 course originally developed by maj ron smith...

21
Real Time Operating Systems Schedulability - Part 3 Course originally developed by Maj Ron Smith 03/23/22 Dr Alain Beaulieu 1

Upload: lora-summers

Post on 03-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Real Time Operating Systems

Schedulability - Part 3

Course originally developed by

Maj Ron Smith

04/20/23 Dr Alain Beaulieu 1

Outline

Review of Task Model Assumptions Removing Task Independence Review Priority Inversion & Priority

Inheritance Time-Demand Analysis & Blocking Time-Demand Analysis & Priority-Ceiling

Protocols

04/20/23 Dr Alain Beaulieu

Review of Task Model Assumptions

single processor fixed number of tasks all tasks are periodic context switch times are negligible all tasks are preemptable all tasks are independent task priorities are fixed

XX

X

X - Our schedulability analysis can not handle deviation from the assumption.

- Our schedulability analysis (to date) can handle deviation from the assumption.

04/20/23 Dr Alain Beaulieu

Removing Task Independence

The assumption that tasks are independent is unreasonable for any meaningful system tasks typically share common resources (Rk) through

the use of semaphores and monitors tasks often must synchronize

This implies that a task(s) may suspend pending some future event which is dependent upon one or more other tasks

How will this dependence affect schedulability?

04/20/23 Dr Alain Beaulieu

Recall : Priority Inversion

Priority inversion can occur when a high and a low priority task share a

common resource the low priority task gets exclusive access to the shared

resource the higher priority task preempts the lower priority task but

is blocked pending release of the shared resource meanwhile a medium priority task preempts the lower

priority task, thus further delaying the execution of the high priority task

since the medium task is guaranteed priority service over the blocked higher priority task => priority inversion

04/20/23 Dr Alain Beaulieu

Recall: Priority Inheritance & Scheduling

Simple priority inheritance is a technique for avoiding priority inversion each task has a dynamic priority, equal to the maximum

of its own static priority and any it inherits due to blocking higher priority tasks

this effectively blocks any “medium” priority tasks

Theorem : if priority inheritance is employed, the number of times a task can be blocked by lower priority tasks is limited by the lessor of: K - the number of blocking critical sections; or n - the number of lower priority tasks

04/20/23 Dr Alain Beaulieu

Blocking Time Defined

From the previous theorem, the block time of task i is defined to be ->

bi = usage(k, i ) eCS(k) (1)

where usage(k, i) = 1 if resource k is used by at leastone task with priority < i

and at least one task (including i)with priority ≥ i

= 0 otherwise

and eCS(k) = execution time of the kth critical section

k=1

K

04/20/23 Dr Alain Beaulieu

Blocking Time Example

Given the 4 task, 2 resource system described below, determine the blocking time of each task using equation (1)

Ti i

1 2

2 1

3 4

4 3

kj ecs(kj) used by tasks

1 0.5 1,4

2 0.25 1,2,3

Tasks Resource Utilization

exercise to be completed in classexercise to be completed in class

04/20/23 Dr Alain Beaulieu

Time-Demand Analysis with Blocking

Yielding a more general response time for task i:

wi* = ei + bi + Ii

*Note: this equation is now pessimistic (sufficient but not necessary)

Why?

Although employing simple priority inheritance will bound the number of blocks a task may experience, recall that it does not prevent transitive blocking nor deadlock

04/20/23 Dr Alain Beaulieu

Blocking Exercise

Tasks ResourcesTask ei pi Di k eCS(k) used by

1 3 25 7 1 21,3,4

2 2 12 - 2 42,4

3 5 17 - 4 6 24 -

assume DM priority scheduling simple priority inheritance is employed determine the schedulability of the tasks04/20/23 Dr Alain Beaulieu

Blocking Exercise - Solution (1)

Task i ei pi Di k eCS(k) used by

1 1 3 25 7 1 2 1,3,4 2 2 2 12 - 2 4

2,4 3 3 5 17 - 4 4 6 24 -

use DMPO simple priority inheritance is employed determine the schedulability of the tasks

04/20/23 Dr Alain Beaulieu

Blocking Exercise - Solution (2)

w1 = e1 + b1 + I1

where b1 = usage(1,1) eCS(1) + usage(2,1) eCS(2)

= (1)(2) + (0)(4) = 2

and I1 = 0 (there are no higher priorities)

therefore w1 = 3 + 2 + 0 = 5

and w1 D1 04/20/23 Dr Alain Beaulieu

Blocking Exercise - Solution (3)

w2 = e2 + b2 + I2

where b2 = usage(1,2) eCS(1) + usage(2,2) eCS(2)

= (1)(2) + (1)(4) = 6

and w2 = 2 + 6 + Σ w2 / pj ej

using recursion w20 = 2

w21 = 8 + w2

0 /25 3 = 11

w22 = 8 + w2

1 /25 3 = 11

therefore w2 = 11 and w2 D2

04/20/23 Dr Alain Beaulieu

Blocking Exercise - Solution (4)

w3 = e3 + b3 + I3

where b3 = usage(1,3) eCS(1) + usage(2,3) eCS(2)

= (1)(2) + (1)(4) = 6

and w3 = 5 + 6 + Σ w3 / pj ej

again w30 = 5

w31 = 11 + w3

0 /25 3 + w30 /12 2 = 16

w32 = 11 + w3

1 /25 3 + w31 /12 2 = 18

w33 = 11 + w3

2 /25 3 + w32 /12 2 = 18

therefore w3 = 18 (> 17) - the system is not scheduleable!

04/20/23 Dr Alain Beaulieu

Now Recall: Ceiling Priority Protocols

A class of resource sharing algorithms entitled Ceiling Priority Protocols are introduced as an alternative to simple priority inheritance to: eliminate transitive blocking

for any given task only a single blocking event may occur eliminate deadlock

a task holding one resource may not claim another resource that could lead to circular lock/requests

04/20/23 Dr Alain Beaulieu

Blocking & Ceiling Priority Protocols

Given that the ceiling priority protocols guarantee that only a single instance of blocking can occur (with respect to task i’s execution),

We can use the modified blocking time equation:

bi = max {usage(k, i ) eCS(k) }k=1

K

04/20/23 Dr Alain Beaulieu

CPP Exercise - Same system as before

Tasks ResourcesTask ei pi Di k eCS(k) used by

1 3 25 7 1 2 1,3,4 2 2 12 - 2 4 2,4 3 5 17 - 4 6 24 -

** This is the exact same system as previously in the lecture, except the system uses a ceiling priority protocol

Determine if the system is schedulable

04/20/23 Dr Alain Beaulieu

CPP Exercise – Solution (1)

The following changes must be accounted for with the use of a ceiling priority protocol

first b2 = max { usage(1,2) eCS(1), usage(2,2) eCS(2) } = 4

and b3 = max { usage(1,3) eCS(1), usage(2,3) eCS(2) } = 4

then w1 = 5 (no change)

and w2 = 9 (less response time)

but check out w3

04/20/23 Dr Alain Beaulieu

CPP Exercise – Solution (2)

w3 = e3 + b3 + I3

with new b3 = 4

and w3 = 5 + 4 + Σ w3 / pj ej

again w30 = 5

w31 = 9 + w3

0 /25 3 + w30 /12 2 = 14

w32 = 9 + w3

1 /25 3 + w31 /12 2 = 16

w33 = 9 + w3

2 /25 3 + w32 /12 2 = 16

therefore w3 = 16 17 and the system may now be

scheduleable! But now you must check w4

04/20/23 Dr Alain Beaulieu

CPP Exercise – Solution (3)

w4 = e4 + b4 + I4

where b4 = max{ usage(1,4) eCS(1), usage(2,4) eCS(2)}

= max{ (0)(2), (0)(4) } = 0 (lowest priority task)

and w4 = 6 + 0 + Σ w4 / pj ej

again w40 = 6

w41 = 6 + w4

0 /253 + w40 /122 + w4

0 /175 = 16

w42 = 6 + w4

1 /253 + w41 /122 + w4

1 /175 = 18

w43 = 6 + w4

2 /253 + w42 /122 + w4

2 /175 = 23

w44 = 6 + w4

3 /253 + w43 /122 + w4

3 /175 = 23

therefore w4 = 23 24 & the system is now scheduleable!

04/20/23 Dr Alain Beaulieu

References

[1] Liu, J.W.S., “Real-Time Systems”, Prentice-Hall, 2000.

[2] Burns, A. and Wellings, A., “Real-Time Systems and Programming Languages”, Chapter 13, Addison Wesley, 1997

[3] TimeSys Corp, “The Concise Handbook of Real-Time Systems”, Version 1.0, 1999

04/20/23 Dr Alain Beaulieu