TDDD82 System software, exam 2016-03-04 Example solutions

advertisement

TDDD82 System software, exam

2016-03-04

Example solutions

Please note that there are sometimes several ways to answer a question. These solutions are not intended to provide the only way, but one way in which to answer them. Answers to pure theory questions that can be looked up in the literature are not included.

Q1: a) In each process there are 4 statements, and each process runs exactly once. Thus there are in total 8 statements resulting in nchoosek(8,4) = 70 possible interleavings . Note that this does not consider the semantics of the if-statement.

(To account for the semantics (which is not expected/required) the answer is more complicated:

• Number of interleavings where 1.2 runs first: nchoosek(7,3)=35

• Number of interleavings where 2.2 runs first, and where 2.5 will still run (but not 1.5): 4

• Number of interleavings where 2.2 runs first and neither 2.5 nor 1.5 will run: nchoosek(5,2)=10

In total 49 runs.) b) We consider each of the cases ””, ”1”, ”12”, ”2”, ”21”

◦ ””, can happen if 1.2 runs after 2.2 but before both ”if” statements

◦ ”1”, requires 1.4 to be true but 2.4 to be false, but this cannot happen

◦ ”12”, can happen if 2.2 runs after 1.2

◦ ”2”, can happen if process p2 runs before process P1

◦ ”21”, can happen if 2.2 runs after 1.2

So the answer is ””, ”12”, ”2”, and ”21” c) In order for the output of the program to be ”21”, the following facts must hold:

(1) 1.2 must run first

(2) 1.5 must run last

(3) The above two facts give 2 remaining statements from P1 that can be interleaved with 4 statements in P2. Thus, there is a total of nchoosek(6,2)=15 such statements.

(4) In all those 15 interleavings the output will be ”21” except in one case which is when 1.4

runs before 2.2.

(5) Thus a total of 14 interleavings result in the output ”21”.

From a) we know that there are 70 possibleinterleavings in total, and since they are all equally likely, the probability of getting the output ”21” is 14/70 = 20% (if we consider the semantics of the if-statements, 14/49 ~= 29%)

Note that several answered that the likelihood was 25%, since the probability of 2.2 running after

1.2 is 50% and the likelihood of 2.5 running before 1.5 is also 50%. The first of these arguments is true, but the second is not.

a) d) Example solution

Semaphore waitfor1 := 0

Semaphore waitfor2 := 0

1.1: Process P1 {

1.2: X := 1

1.3: waitfor1.signal()

1.4: Y := 2

1.5: waitfor2.wait()

1.6: if (X == Y) {

1.7:

1.8: print(“1”)

1.9: waitfor1.signal()

1.9: }

1.10: }

2.1: Process P2 {

2.2: waitfor1.wait()

2.2: X := 2

2.3: waitfor2.signal()

2.3: Y := 2

2.4: if (Y == X) {

2.4: waitfor1.wait()

2.5: print(“2”)

2.6: }

2.7: }

Note that in some student solutions, the same wait and signal pattern was used but with only one semaphore.

This can result in process P1 running to completion before P2 begins.

e) See book (Silberschatz et al.) f) See book (Silberschatz et al.) g)

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

Problem instance:

Max: [[3, 3, 1], [1, 2, 0], [1, 2, 1], [4, 1, 1]]

Available: [0, 2, 1]

Allocation: [[2, 2, 0], [1, 0, 0], [1, 2, 0], [0, 1, 0]]

Request: [0, 2, 0]

Process (i): 1

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

Running Banker's algorithm

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

Step 1

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

Need: [[1 1 1]

[0 2 0]

[0 0 1]

[4 0 1]]

Step 2:

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

Request <= Available

Step 3

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

Allocation:

[[2 2 0]

[1 2 0]

[1 2 0]

[0 1 0]]

Need:

[[1 1 1]

[0 0 0]

[0 0 1]

[4 0 1]]

Available: [0 0 1]

Step 4

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

Checking if state is safe

Initial Work vector: [0 0 1]

Initial Finish vector: [False, False, False, False]

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

Could finish process: 1

Work vector: [1 2 1]

Finish vector: [False, True, False, False]

Could finish process: 2

Work vector: [2 4 1]

Finish vector: [False, True, True, False]

Could finish process: 0

Work vector: [4 6 1]

Finish vector: [True, True, True, False]

Could finish process: 3

Work vector: [4 7 1]

Finish vector: [True, True, True, True]

The result of running bankers algorithm is: True

Q2 a) The architecture makes use of horizontal distribution since the figure shows that the edge services, mid-tier services and Cassandra service exists as multiple copies, meaning that there are several equivalent replicas that can handle requests.

Vertical distribution is shown by the fact that a service is divided in an edge service, a mid-tier service and in some cases a storage layer (cassandra). Also the fact that there are several service types (indicated by service 0,1, etc) provides vertical distribution since they provide different functionality to the clients.

b) The synchronous system model requires clocks to be synchronized within a known bound, which can be non-trivial to achieve. Moreover, in synchronous systems there is a bound on message delay.

If the system is spread out geographically, and communication should be performed across the

Internet, them such delay guarantees cannot easily be provided. Even in a closed setting, guarantees on delay requires a predictable network.

c) According to the problem all nodes start at clock 0 b d e

B

C a f g c a: 0+1 = 1 b: max(a,0)+1 = 2 c: 0+1 = 1 d: b+1 = 3 e: d+1 = 4 f: max(a,c)+1=2 g: max(e,f)+1 = 5

Q3) a) See El-Gendy et al. 2003 (course litterature), that provides three ways.

b) The three system requirements are:

• Functional since the requirement clearly refers to what the system is supposed to do in a given context

• Extra-functional since the requirement relates to the relability of the service.

• Extra-functional since the requirement relates to confidentiality of sensitive information.

Note that this can in some cases be treated and considered as a functional requirement in the process of creating a security layer for the application.

Q4)

Before identifying the chain of events, we must decide on the system boundary in this case. Possible options include: ”the Google car”, ”Google car + driver”, ”Google car + driver + bus (with driver)”.

In the following we analyse the first of these options, the Google car.

The fault is defined as the cause of an error. The text does not specify a clear cause, but there are two clear alternatives: ”The car did not see the bus” and ”The car saw the bus and incorrectly assumed that it would let the car go first”. We proceed with analysing the former of these alternatives.

The error is the part of the total state of the system that may lead to its subsequent service failure. In this case the bad state is the cars internal representation of other nearby vehicles (it is missing one of them).

The failure which is when the delivered service deviates from correct service occurs when the two vehicles make contact. An autonomous vehicle should not contribute to any collissions.

The probable fault that we chose to analyse ”The car did not see the bus” can in turn be caused by a number of factors. However, most likely this is due to a design fault of the car. Thus it should be classified as a permanent fault.

Download