advertisement

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

TENTAMEN TDDC47 Realtids- och processprogrammering

Datum: 2008-08-15

Tid:

Lokal:

14-18

G35

Jourhavande-lärare:

• Simin Nadjm-Tehrani (Tel: 070-228 24 12 )

Hjälpmedel: Engelsk lexikon/English dictionary

Miniräknare/Minicalculator

Poängantal: 40p

Betyg: F, 3, 4 and 5:

U:

3:

4:

5:

- 19 p

20 - 26 p

27 - 33 p

34 - 40 p

INSTRUCTIONS:

Write your name, class and personal number (sv. personnummer) on each sheet of paper that you hand in. Further, pages should only contain one answer per page (answers to subquestions can be on the same page). You are asked to only answer on the front page of the paper. Sort all the sheets that you hand in with respect to the number of the question.

Make sure your answers are presented clearly and precisely. Points will not be given to answers that cannot be read due to bad handwriting. Your answers can be presented in

Swedish or English.

Your answers shall clearly show the method for the solution. A correct answer without any explanation will not be given any credits (figures can be of help when describing but should be accompanied by a text description). In those cases where you are in doubt about the question, write down your interpretation and your assumptions and answer the question based on the interpretation. Note that a correct answer embedded in errors may give reduction in points, so make sure your answers are to the point.

Results are reported no later than August 29th, 2008.

Good luck!!!

Simin Nadjm-Tehrani

Examiner TDDC47

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

Q1: Processes, synchronization and inter-process communication (15 points)

(a) Consider two processes P1 and P2 that execute concurrently (assume that each process executes only once):

Process P1 {

X = 3;

Y = 0;

If Y > 1 then

Else

X = X - 1;

X = X + 2

Endif

}

Process P2 {

X = 3;

Y = 2;

If Y < 1 then

Else

X = X + 1

X = X - 2

Endif

}

1) Using semaphores, modify the code so that the if..then..else

instructions (together with the code inside them) are executed atomically.

(2 points)

2) Assume that each process executes only once. Given that the if..then..else instructions are atomic, how many different interleavings of the executions of the two processes are possible? (1 point)

3) Provide 5 possible values for the variable X after 5 different executions of the two processes. Motivate the provided values by presenting the interleavings leading to each answer. (5 points)

(b) Consider the following snapshot of a system:

P1

P2

P3

A

2

0

0

Allocated resources

B

1

3

1

C

2

1

0

Max. requested resources

A B C

2

4

4

3

6

3

2

2

2

Available resources

A

2

B

2

C

1

1) Is the system in a safe state or not?

(3 points)

2) Draw a resource allocation graph that describes the scenario (2 points)

3) Process P3 requests the following resources: (2,1,0). Should the request be granted? (2 points)

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

Q2: Scheduling and handling of shared resources (10 points)

(a) A system has four non-periodic processes (P1, P2, P3, and P4). These processes are sharing four common resources (a, b, c, and d). The characteristics of the processes are the following::

ProcessExecution sequence

P1

P2

P3

P4 cddE

EddcccaE

EbbbE

EaabE

Priority Release time

4 (Highest)

3

2

1 (Lowest)

7

4

1

0

‘E‘ denotes empty step, i.e. execution but with no access to a common resource while ”a”,

”b” etc. denotes execution with a resource. Once a process locks a resource, the lock is kept until the resource is no longer needed.

Assume that tasks are scheduled according to priorities and that the immediate ceiling priority protocol (ICPP) is used. Show the actual execution sequence of statements for the four processes (use the diagram attached at the end of the exam) and motivate your answer.

(4 points)

(b) Motivate the following statements (true or false?) assuming OCPP or ICCP is used.

(1) A process can be blocked more than once during its execution. points)

(2

(2 (2) Starvation can occur.

points)

(3) Mutual exclusion to a resource is guaranteed.

(2 points)

Q3: Scheduling of control processes (5 points)

Assume that we have a system consisting of four controllers denoted F

1 figure below).

, F

2

, F

3

, and F

4

(see y i

(t) y r,i

(t)

+

-

F i

(s) u i

(t)

G i

(s)

Each controller is implemented as a periodic process, i.e. F

1 implemented as process P

2

P

4

.

, F

3

is implemented as process P

3

is as process P

1

and F

4

, F

2

is

is implemented as process

The period and worst case execution time of each process is given in the table below.

Process Period T (ms)

P

1

P

2

P

3

P

4

16

32

4

8

WCET C (ms)

5

4

1

2

The controlled variable y i

(t) and the reference variable y r,i

(t) is sampled when process P executing and the manipulated variable u i

(t) is actuated at the end of process P i i starts

:s execution

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

(time-triggered input and output is not used). Assume that the delay of A(D)/D(A)-conversion is zero, that the processes cannot be divided into subprocesses and that rate monotonic scheduling (RMS) is used to schedule the processes.

Answer the following questions:

1.

What is the maximum control delay for each controller in respective closed system?

(3 points)

2.

Derive the transfer function G c,i

(s) that relates signal Y r,i

(s) and signal Y i

(s) in the closed system according to:

Y i

( s ) = G c , i

( s ) Y r , i

( s )

where the maximum control delay (from subquestion a). above) is included. (2 points)

Q4: Real-time communication (10 points) a) Assume a CAN bus that interconnects four processing nodes n

1

– n

4

. Each node n i sends periodically a frame embedding a data message m i properties for each message are given in the table below:

, i = 1..4., where the

Message m

1 m

2 m

3 m

4

CAN Identifier Message period

T (ms)

1 0.5

5

3

7

0.6

0.6

1.0

Message length

(bytes)

10

6

4

2

J (ms)

0

0

0

0

The system is configured to use the standard CAN frame format, with 11-bit identifiers.

The CAN bus uses 0 as the dominant bit value in the conflict resolution. The time

τ bit needed for the transmission of one bit over the bus is 1 x 10 -6 s. All jitters are ignored ( J i

=

0).

1.

Compute the times C i

needed to transmit all the bits in each of the four frames

2.

that carry messages m

1

m

4

.

Assume C

1

= 175, C blocking time B i

2

= 150, C

3

= 100, and C

(2 points)

4

= 75 respectively. Compute the

for each message in the system.

(2 points)

3.

Compute the worst-case response time

C i

and blocking times B i

R

2

for message m

from subquestion 2. above).

2

(use transmission times

(3 points) b) The behavior of a distributed real-time system is strongly influenced by both the scheduling policy of the CPU in the nodes and also the bandwith allocation in the communication channel. Take a position on the following statements and decide if they are true or false. Don’t forget to motivate your answer!

1. The CAN bus enables a receiving node to know the exact arrival time of a message and therefore treat the dependency relationship between the processes that generate messages in a deterministic way.

2. If a node that is connected to a TTP bus crashes, this can be detected easily, in contrast to the case when the system uses a CAN bus.

3. If a process overruns (exceeds it worst case execution time) at some invocation, the TTP bus stops it from sending its result.

P1

P2

P3

P4

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

(3 points)

________________________

Namn

Tabell för fråga Q2. Lämna in denna kopia.

__________________

Personnummer

Följande beteckning används: yx Betyder att processen exekverar med prioritet x och att processen har tilldelats resurs y . Till exempel, betyder a2 att processen har fått resurs a och att processen exekverar med prioriteten 2.

P Preemption av en process med högre prioritet.

Blockeras av en process med lägre prioritet.

P3

P4

P1

P2

P3

P4

P1

P2

Tentamen vid Institutionen för Datavetenskap, Linköpings universitet

Tabell för fråga Q2. Använd denna kopia för anteckningar.

Följande beteckning används: yx Betyder att processen exekverar med prioritet x och att processen har tilldelats resurs y . Till exempel, betyder a2 att processen har fått resurs a och att processen exekverar med prioriteten 2.

P Preemption av en process med högre prioritet.

Blockeras av en process med lägre prioritet.

******************

Download