Sie sind auf Seite 1von 4

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009

Updated 2009-03-03

Example: scheduling using EDF


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

Solutions to examples, Lecture #14

Example: scheduling using EDF


a) Determine the LCM for the tasks:

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.

LCM {T1,T2 ,T3 }= LCM {4,8,16}= 16

Determine the control points K:

{
{
= {D

}{

K1 = D1k | D1k = kT1 + D1 , D1k 16, k = 0,1,2,3 = 3,7,11,15


1

Task

1
2
3

Ci

Di

Ti

2
2
3

3
7
12

4
8
16

}{ }
}{}

K 2 = D2k | D2k = kT2 + D2 , D2k 16, k = 0,1 = 7,15


K3

k
3

| D3k = kT3 + D3 , D3k 16, k = 0 = 12

The processor demand must be checked at the following


time points:

K = K1 K 2 K 3 = 3,7,11,12,15

Example: scheduling using EDF

b) Simulate the execution of the tasks:

We define a table and examine every control point:

( )

( )

N C1

N C2

N C3

C P 0, L

CP 0, L L

3 3
4 + 1 2 = 2

3 7
8 + 1 2 = 0

3 12
16 + 1 3 = 0

OK!

7 3
7 7
7 12
4 + 1 2 = 4 8 + 1 2 = 2 16 + 1 3 = 0

OK!

11

11 3
11 7
11 12
+ 1 2 = 6
+ 1 2 = 2
+ 1 3 = 0

4
8
16

OK!

11

OK!

15

OK!

12
15

L
1

L
2

L
3

12 3
12 7
12 12
4 + 1 2 = 6
+ 1 2 = 2
+ 1 3 = 3

8

16
15 3
15 12
15 7
+ 1 2 = 4 16 + 1 3 = 3
4 + 1 2 = 8

Example: scheduling using EDF

2
3
0

12

16

The tasks meet their deadlines also in this case!

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009


Updated 2009-03-03

Solutions to examples, Lecture #14

Example: scheduling using EDF

Example: scheduling using EDF

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

Task
Task

1
2
3

S3

Cii

Di

Ti

6
7
10

10

50

17
25

50
50

HR1 HR2 HR3


2
2
2
1
2
2
2
3

Problem: (cont
(contd)
Task 1 first requests R3 and then, while using R3, requests R1
Task 2 first requests R3 and then, while using R3, requests R2;
then, after releasing the two resources, 2 requests R1
Task 3 first requests R2 and then, while using R2, requests R1;
then, after releasing the two resources, 3 requests R3
2

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.

R1 R2 R3
1
2
3

1
3

Example: scheduling using EDF

Example: scheduling using EDF


Resource ceiling C R (a) as a function of available units a :

a) Preemptions levels of the tasks:

( CR (0) is the worst-case ceiling used for calculating blocking factors)


L

S1

S2

S3

1 = H (
2 = M
3 = L (

C R (3)

R1

C R (2)

L
1 uses

3 may block

C R (1)

L
2 uses
3 may block

R2
1

R3

H
3 uses
1 may block

M
3 uses
2 may block

has the shortest relative deadline)

has the longest relative deadline)

C R (0)

M
1 or 3 use
2 may block

M
1 and 3 use
2 may block

H
2 uses

1 may block

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009


Updated 2009-03-03

Example: scheduling using EDF


b) Observe that nested blocking is used by all tasks. This could
lead to accumulated critical region blocking times in the final
blocking factor.

Wait( R3 ,1) H

Signal( R1 )

Wait( R1 ,3)

Signal( R2 )

Signal( R1 )

Signal( R3 ) H

Signal( R3 ) H

Wait( R3 ,1) H

Signal( R1 ) H

Signal( R3 ) H

Wait( R1 ,2) H

c) Determine the LCM for the tasks:


LCM {T1,T2 ,T3 }= LCM {50,50,50}= 50

Determine the control points K:

}{}
}{}
50, k = 0}= {25}

K1 = D1k | D1k = kT1 + D1 , D1k 50, k = 0 = 10

K 2 = D2k | D2k = kT2 + D2 , D2k 50, k = 0 = 17


K3

k
3

| D3k = kT3 + D3 , D3k

The processor demand must be checked at the following


time points:

B2 = max{2,5} = 5

3 uses R3

3 uses R1

3 uses R1

2 uses R3 incl. nested use of R2

3 uses R2 incl. nested use of R1

Signal( R2 ) M

Example: scheduling using EDF

{
{
= {D

Blocking factors for the tasks:

2 uses R1

Wait( R2 ,1) M

Wait( R2 ,1)

Example: scheduling using EDF

B1 = max{1,4,2,2} = 4

Wait( R3 ,3) H

Wait( R1 ,1)

Solutions to examples, Lecture #14

K = K1 K 2 K 3 = 10,17,25

B3 = 0

3 has lowest preemption level, and cannot be blocked

Example: scheduling using EDF


Processor demand calculations for each task:
L D1

L D1

+ 1 C1 +
+ 1 B1
C 1P =
T1

T1

L D1
L D2
+ 1 C1 +
C P2 =

T1
T2

L D2

+ 1 C2 + T

+ 1 B2

L D1

L D2

L D3

L D2

C P3 =
+ 1 C1 +
+ 1 C2 +
+ 1 C3 +
+ 1 B3 =
T1

T2

T3

T2

L D1
L D2
L D3

= {B3 = 0 } =
+
1
+
1
+
1
+
+
C
C
C
T1
1 T2
2 T3
3

EDA222/DIT160 Real-Time Systems, Chalmers/GU, 2008/2009


Updated 2009-03-03

Example: scheduling using EDF


We define a table and examine every control point:
L

( )

C 1P 0, L

10

10 10
10 10
50 + 1 6 + 50 + 1 4 =



= 6 + 4 = 10

17

17 10
17 10
50 + 1 6 + 50 + 1 4 =



= 6 + 4 = 10

25

25 10
25 10
50 + 1 6 + 50 + 1 4 =



= 6 + 4 = 10

( )

C P2 0, L

10 10
10 17
50 + 1 6 + 50 + 1 7 +



10 17
+
+ 1 5 = 6 + 0 + 0 = 6
50
17 10
17 17
50 + 1 6 + 50 + 1 7 +



17 17
+
+ 1 5 = 6 + 7 + 5 = 18
50

( )

C P2 0,17 > 17 (FAIL!)

( )

C P3 0, L

10 10
10 17
50 + 1 6 + 50 + 1 7 +



10 25
+
+ 1 10 = 6 + 0 + 0 = 6
50
17 10
17 17
50 + 1 6 + 50 + 1 7 +



17 25
+
+ 1 10 = 6 + 7 + 0 = 13
50

25 10
25 17
+ 1 6 +
+ 1 7 +

50
50

25 10
25 17
+ 1 6 +
+ 1 7 +

50
50

25 17
+
+ 1 5 = 6 + 7 + 5 = 18
50

25 25
+
+ 1 10 = 6 + 7 + 10 = 23
50

Solutions to examples, Lecture #14

Das könnte Ihnen auch gefallen