Real Real- -Time Systems Time Systems Example: scheduling using - - PowerPoint PPT Presentation

real real time systems time systems example scheduling
SMART_READER_LITE
LIVE PREVIEW

Real Real- -Time Systems Time Systems Example: scheduling using - - PowerPoint PPT Presentation

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01 Real Real- -Time Systems Time Systems Example: scheduling using EDF Example: scheduling using EDF Problem: Assume a system with tasks according to the


slide-1
SLIDE 1

EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01

Real Real-

  • Time Systems

Time Systems

Verification Implementation Specification

  • Dynamic scheduling
  • - Earliest-deadline-first

scheduling

  • Processor-demand analysis

Example: scheduling using EDF Example: scheduling using EDF

Problem: Problem: Assume a system with tasks according to the figure

  • below. The timing properties of the tasks are given in the table.

Investigate the schedulability of the tasks when EDF is used. (Note that Di < Ti for all tasks)

1

τ

2

τ

3

τ

Task Ci Di Ti 1

1

τ

2

τ

3

τ

1 1 1 2 3 2 4 8

Example: scheduling using EDF Example: scheduling using EDF

Simulate an execution of the tasks: The tasks are not schedulable even though U = 1 2 + 1 4 + 1 8 = 7 8 = 0.875 < 1

misses its deadline!

3

τ

t

6 8 4 2

1

τ

2

τ

3

τ

Feasibility analysis for EDF Feasibility analysis for EDF

What analysis methods are suitable for general EDF: What analysis methods are suitable for general EDF:

  • Utilization-based analysis?

Not suitable! Not general enough or exact enough

– Does not work well for the case of Di < T

  • Response-time analysis?

Not suitable! Analysis much more complex than for DM

– Critical instant does not necessarily occur when all tasks arrive at the same time for the first time – Instead, response time of a task is maximized at some scenario where all other tasks arrive at the same time; the worst such scenario has to be identified for each task before the response time of that task can be calculated

slide-2
SLIDE 2

EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01

Processor Processor-

  • demand analysis

demand analysis

Processor demand: Processor demand:

  • The processor demand for a task in a given time

interval is the amount of processor time that the task needs in the interval in order to meet the deadlines that fall within the interval.

i

τ [ ]

0, L

  • Let represent the number of instances of that must

complete execution before .

L i

N

i

τ L

  • The total processor demand up to is

L CP(0, L) = Ni

LCi i=1 n

∑ Processor Processor-

  • demand analysis

demand analysis

Processor demand: Processor demand:

  • We can calculate by counting how many times task

has arrived during the interval .

i

τ

0, L − Di ⎡ ⎣ ⎤ ⎦

L i

N

  • We can ignore instances of the task that arrived during

the interval since for these instances.

Di > L

L − Di, L ⎡ ⎣ ⎤ ⎦

1

2

L

N =

2

3

L

N =

t

L 1

τ

2

τ

Instance with

Di > L

Processor Processor-

  • demand analysis

demand analysis

Processor Processor-

  • demand analysis:

demand analysis:

  • We can express as
  • The total processor demand is thus

L i

N Ni

L =

L − Di Ti ⎢ ⎣ ⎢ ⎥ ⎦ ⎥ + 1 CP(0,L) = L − Di Ti ⎢ ⎣ ⎢ ⎥ ⎦ ⎥ + 1 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ Ci

i=1 n

∑ Exact feasibility test for EDF Exact feasibility test for EDF

(Sufficient and necessary condition) (Sufficient and necessary condition)

A A sufficient and necessary sufficient and necessary condition for earliest condition for earliest-

  • deadline

deadline-

  • first scheduling, for which , is

first scheduling, for which , is Di ≤ Ti ∀L : CP(0, L) ≤ L where is the total processor demand in . where is the total processor demand in . CP(0, L)

[ ]

0, L

The processor The processor-

  • demand analysis and associated feasibility test

demand analysis and associated feasibility test was presented by S. was presented by S. Baruah Baruah, L. Rosier and R. Howell in 1990. , L. Rosier and R. Howell in 1990.

slide-3
SLIDE 3

EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01

Exact feasibility test for EDF Exact feasibility test for EDF

(Sufficient and necessary condition) (Sufficient and necessary condition)

How large interval must be examined? How large interval must be examined?

  • Largest interval is LCM of the task

Largest interval is LCM of the task’ ’s periods s periods

How many time points must be examined? How many time points must be examined?

  • Only absolute deadlines need to be examined

Only absolute deadlines need to be examined

The test can consequently be improved as follows: The test can consequently be improved as follows: ∀L ∈ K : CP(0,L) ≤ L

{ }

{ }

1

| , LCM , , ,1 ,

k k k i i i i i n

K D D kT D D T T i n k = = + ≤ ≤ ≤ ≥ …

Example: scheduling using EDF Example: scheduling using EDF

Problem: Problem: Assume a system with tasks according to the figure below.

The timing properties of the tasks are given in the table. a) Determine, by analyzing the processor demand, whether the tasks are schedulable or not using EDF. b) Determine, by using simulation, whether the tasks are schedulable or not using EDF.

1

τ

2

τ

3

τ

Task Ci Di Ti 2

1

τ

2

τ

3

τ

2 3 3 7 12 4 8 16

We solve this on the whiteboard! We solve this on the whiteboard!

The test can be extended to handle: The test can be extended to handle:

  • Blocking
  • Start-time variations (”release jitter”)
  • Time offsets

In this course, we only study blocking. In this course, we only study blocking.

Extended Extended processor processor-

  • demand analysis

demand analysis Deadline inversion Deadline inversion

t1

H blocked

t2

t t

H

t

M normal execution critical region L

H and L share resource R H misses its deadline

slide-4
SLIDE 4

EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01

Stack Resource Policy (SRP) Stack Resource Policy (SRP)

The tasks are assigned The tasks are assigned preemption levels preemption levels, the properties of , the properties of which are: which are:

– – The preemption level of task is denoted The preemption level of task is denoted – – Task is not allowed to preempt another task unless Task is not allowed to preempt another task unless – – If has higher priority than and arrives later, then If has higher priority than and arrives later, then must must have a higher preemption level than . have a higher preemption level than .

τ i πi τ i τ j πi > π j τi τ j τ i τ j π i > π j ⇔ Di < Dj Note: Note:

  • The preemption levels are static values, even though the tasks

The preemption levels are static values, even though the tasks priorities may be dynamic. priorities may be dynamic.

  • For EDF scheduling, suitable levels can be derived if tasks with

For EDF scheduling, suitable levels can be derived if tasks with shorter relative deadlines get higher preemption levels, that is shorter relative deadlines get higher preemption levels, that is: :

Stack Resource Policy (SRP) Stack Resource Policy (SRP)

Deadline inversion can be reduced with Deadline inversion can be reduced with resource ceilings resource ceilings: :

1. 1. Each shared resource is assigned a ceiling that is always Each shared resource is assigned a ceiling that is always equal to the maximum preemption level among all tasks that equal to the maximum preemption level among all tasks that may be blocked when requesting the resource. may be blocked when requesting the resource. 2. 2. The protocol keeps a The protocol keeps a system system-

  • wide ceiling

wide ceiling that is equal to the that is equal to the maximum of the current ceilings of all resources. maximum of the current ceilings of all resources. 3. 3. A task with the earliest deadline is allowed to preempt only if A task with the earliest deadline is allowed to preempt only if its preemption level is higher than the system its preemption level is higher than the system-

  • wide ceiling.

wide ceiling.

Note: Note:

– – The original priority of the task is not changed at run The original priority of the task is not changed at run-

  • time.

time. – – The resource ceiling is a dynamic value calculated at run The resource ceiling is a dynamic value calculated at run-

  • time

time as a function of current resource availability. as a function of current resource availability. – – Otherwise, the behavior of the protocol is very similar to the Otherwise, the behavior of the protocol is very similar to the ICPP, and SRP also exhibits identical properties regarding ICPP, and SRP also exhibits identical properties regarding maximum blocking time and freedom from deadlock. maximum blocking time and freedom from deadlock.

system-wide ceiling is set to R’s resource ceiling (= H’s preemption level) system-wide ceiling is restored H blocked

H M normal execution critical region

preemption level (H) > preemption level (M) > preemption level (L)

L

H and L share resource R

t t t

Again: note the similarity to the behavior of ICPP

Stack Resource Policy (SRP) Stack Resource Policy (SRP)

Blocking can be accounted for in the following Blocking can be accounted for in the following way: way:

  • Blocking factor represents the length of critical / non-

preemptive regions that are executed by processes with lower preemption levels than

  • Tasks are indexed in the order of increasing preemption

levels, that is:

Extended Extended processor processor-

  • demand analysis

demand analysis

i

B

i

τ CP

i =

L − Dk Tk ⎢ ⎣ ⎢ ⎥ ⎦ ⎥ + 1 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ Ck

k =1 i

+ L − Di Ti ⎢ ⎣ ⎢ ⎥ ⎦ ⎥ + 1 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ Bi

πi > π j ⇔ i < j

∀L ∈ K,∀i ∈ 1,n

[ ]: CP

i (0,L) ≤ L

slide-5
SLIDE 5

EDA222/DIT160 – Real-Time Systems, Chalmers/GU, 2008/2009 Lecture #14 Updated 2009-03-01

Determining the blocking factor for task : Determining the blocking factor for task :

τ i

  • 1. Determine the worst-case resource ceiling for each critical

region, that is, assume the run-time situation where the corresponding resource is unavailable.

  • 2. Identify the tasks that have a preemption level lower than

and that calls critical regions with a worst-case resource ceiling equal to or higher than the preemption level of . τ i τ i

i

B

  • 3. Consider the times that these tasks lock the actual critical
  • regions. The longest of those times constitutes the blocking

factor .

Extended Extended processor processor-

  • demand analysis

demand analysis Example: scheduling using Example: scheduling using EDF EDF

Problem: Problem: Assume a system with tasks according to the figure below.

The timing properties of the tasks are given in the table. Three resources R1, R2 and R3 have three, one, and three units available, respectively. The parameters HR1, HR2 and HR3 represent the longest time a task may use the corresponding resource. The parameters μR1, μR2 and μR3 represent the number of units a task requests from the corresponding resource.

S1 S2

1

τ

2

τ

3

τ

Task Ci Di Ti 6 10 50 7 17 50 10 25 50 HR1 HR2

  • 2

3 2 1 2

1

τ

2

τ

3

τ

HR3 2 2 2

  • 1

1 3 2 1 1 3 1

μR1 μR2 μR3

Task Ci Di Ti

S3

Example: scheduling using Example: scheduling using EDF EDF

Problem: (cont Problem: (cont’ ’d d) )

Task first requests R3 and then, while using R3, requests R1 Task first requests R3 and then, while using R3, requests R2; then, after releasing the two resources, requests R1 Task first requests R2 and then, while using R2, requests R1; then, after releasing the two resources, requests R3 Examine the schedulability of the tasks when the SRP (Stack Resource Policy) protocol is used. a) Derive the ceilings (dynamic and worst-case) of the resources. b) Derive the blocking factors for the tasks. c) Show whether the tasks are schedulable or not.

We solve this on the whiteboard! We solve this on the whiteboard!

1

τ

τ2 τ 2

2

τ

2

τ

3

τ

3

τ

Summary Summary

U ≤ n(21/ n − 1) U ≤ 1 ∀i : Ri = Ci + Ri Tj ⎡ ⎢ ⎢ ⎤ ⎥ ⎥ C j ≤ Di

∀j∈hp(i)

∀L : L − Di Ti ⎢ ⎣ ⎢ ⎥ ⎦ ⎥ + 1 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟

i=1 n

Ci ≤ L Static Static priority priority (RM/DM) (RM/DM) Dynamic Dynamic priority priority (EDF) (EDF) Di = Ti Di ≤ Ti

Feasibility tests Feasibility tests