29.01.2014 Views

Distributed Systems – Mock Exam –

Distributed Systems – Mock Exam –

Distributed Systems – Mock Exam –

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Distributed</strong> <strong>Systems</strong><br />

– <strong>Mock</strong> <strong>Exam</strong> –<br />

Werner Nutt<br />

January 17, 2011<br />

• The exam comprises 5 questions, which consist of several subquestions.<br />

There is a total of 120 points that can be achieved in this exam. You will<br />

have 2 hours time to answer the questions.<br />

• Please, write down the answers to your questions in the exam booklet handed<br />

out to you.<br />

• For drafts use the blank paper provided by the university.<br />

• If the space in the booklet turns out to be insufficient, please use the university<br />

paper for additional answers and return them with the booklet.<br />

• For students who did not submit assignments the final mark will be the same<br />

as the exam mark. For those who submitted assignments for the labs there<br />

is the possibility to improve the mark:<br />

– For students who submitted all assignments, the final mark will be the<br />

weighted average of<br />

70% exam mark + 30% lab mark<br />

if this is higher than the exam mark.<br />

– For students who submitted all assignments but the last, the final mark<br />

will be the weighted average of<br />

80% exam mark + 20% lab mark<br />

if this is higher than the exam mark.<br />

1


1 Protocols<br />

(i) If you had to implement a protocol for remote method invocation, on which<br />

transport level protocol would you base it, UDP or TCP? Explain your answer.<br />

(5 points)<br />

(ii) Suppose you have to implement a request-reply protocol. For each of the<br />

three, UDP, TCP, and HTTP, discuss whether one could use it as the basis<br />

for the new implementation. Which one would be the most suitable and<br />

which one the least? Why?<br />

(15 points)<br />

2 Java RMI<br />

Suppose a server is to be implemented for a book shop where customers can place<br />

orders and managers can check how many copies of each book have been ordered.<br />

There are two methods to access the server,<br />

1. order, which takes four strings, name, cardNo, bookCode, and address<br />

as arguments, and stores that the customer with that name and the credit<br />

card number cardNo has ordered a copy of the book identified by bookCode<br />

to be sent to address;<br />

2. copiesOrdered, which takes a string bookCode as argument and returns<br />

an integer, representing the number of copies ordered of the book with<br />

code bookCode<br />

(i) Write down the declarations of the interfaces and the classes (including the<br />

method declarations) that have to be implemented on the server side.<br />

(12 points)<br />

(ii) Describe how you would implement a small client program that can be<br />

started from a command shell, with the book code as argument, and returns<br />

the number of copies that have been ordered.<br />

(8 points)<br />

(iii) Which compilation steps have to be made in which order before the client<br />

can be started?<br />

2<br />

(4 points)


3 Lamport’s Logical Clocks<br />

Consider three distributed processes P 1 , P 2 , and P 3 . The processes are involved in<br />

the events a, b, . . . , k listed below, which happen at spefic points in time, specified<br />

as “wall-clock time” (WCT) and measured in ms:<br />

At 0ms WCT:<br />

a: P 2 sends message m 1 to P 1<br />

b: P 3 reads a startup file<br />

At 100ms WCT:<br />

c: P 1 opens a file containing a user profile<br />

d: P 3 sends message m 2 to P 2<br />

At 200ms WCT:<br />

e: P 1 receives message m 1<br />

f: P 2 receives message m 2<br />

At 300ms WCT:<br />

g: P 1 sends message m 3 to P 2 and P 3<br />

At 400ms WCT:<br />

h: P 2 receives message m 3<br />

At 500ms WCT:<br />

i: P 2 sends message m 4 to P 1<br />

At 600ms WCT:<br />

j: P 1 receives message m 4<br />

At 600ms WCT:<br />

k: P 3 receives message m 3<br />

(i) Which of these events are related by Lamport’s “happened before” relation<br />

(in the lecture denoted as “E 1 → E 2 ” if event E 1 happened before<br />

event E 2 )? Draw a directed graph where the events are vertices and where<br />

there is an edge from E 1 to E 2 if E 1 happened before E 2 .<br />

(10 points)<br />

(ii) Associate to each event a logical timestamp according to the logical clock<br />

algorithm. What is the linear order of events induced by these timestamps?<br />

(10 points)<br />

3


4 Invocation Semantics<br />

Three different semantics have been defined for remote method invocation, “maybe”,<br />

“at-least-once”, and “at-most-once” semantics.<br />

(i) Briefly explain what each of the three means.<br />

(6 points)<br />

(ii) How can one implement at-most-once semantics? Which are the problems<br />

that need to be addressed?<br />

(5 points)<br />

In the context of invocation semantics, on distinguishes between idempotent and<br />

non-idempotent invocations.<br />

(iii) When is a method invocation idempotent? Give an example of an invocation<br />

that is idempotent and of one that is not!<br />

(4 points)<br />

(iv) How can the implementation of at-most-once semantics be simplified if the<br />

methods invoked are idempotent?<br />

(3 points)<br />

As part of the implementation of at-most-once semantics, a site executing remote<br />

method invocations will store results of previous invocations.<br />

(v) When is the earliest point in time that such a stored result can be safely<br />

removed? Explain your answer.<br />

(3 points)<br />

On some networks it may happen that an earlier message be a sender to a recipient<br />

is overtaken by a later message of the same sender to the same recipient. For this<br />

reason it may be the case that a message with a method invocation is overtaken by<br />

another message with the same method invocation.<br />

(vi) How can one extend the basic implementation of at-most-once semantics so<br />

that no reply needs to be sent out for an invocation message that has been<br />

overtaken by another invocation message?<br />

(5 points)<br />

4


5 Mutual Exclusion<br />

<strong>Distributed</strong> algorithms for solving coordination problems are required to have the<br />

properties of safeness and liveness.<br />

(i) Briefly explain each of the two properties. What does it mean for a leader<br />

election algorithm to have these properties?<br />

(8 points)<br />

In addition to leader election, organising exclusive access to shared resources is<br />

another problem requiring distributed coordination. This problem is often specified<br />

as the problem of Mutual Exclusion.<br />

(ii) Briefly explain what is the problem of mutual exclusion.<br />

(4 points)<br />

A classical solution to mutual exclusion uses a central server and tokens, which<br />

can be requested by clients.<br />

(iii) Briefly explain how the basic algorithm for that approach works.<br />

(4 points)<br />

In addition to the two properties of safeness and liveness, an algorithm for mutual<br />

exclusion is sometimes required to have the ordering property.<br />

(iv) Briefly explain what it means for a mutual exclusion algorithm to guarantee<br />

ordering.<br />

(3 points)<br />

(v) Does the algorithm you described above guarantee safeness, liveness, and<br />

ordering? Give a brief explanation.<br />

(9 points)<br />

The basic algorithm cannot deal with failure. Suppose that clients may fail, but<br />

the central server cannot fail. Moreover, suppose the central server uses a failure<br />

detection service that eventually detects any failed client.<br />

(vi) What would be a simple modification of the central server algorithm so that<br />

it can handle the crash of a client?<br />

(4 points)<br />

5


Suppose that the error detection algorithm is sometimes wrong in its judgement,<br />

that is, it may assume a client has crashed although the client is still working.<br />

(vii) How may the server detect that a client thought to have crashed is still working?<br />

(3 points)<br />

(viii) How can the algorithm be extended so that it is able to deal also with situations<br />

where a client is falsely thought to have crashed?<br />

(5 points)<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!