Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Distributed System
CS-7001
Experiment List
12 Study of RMI.
Lab 1: Partial Ordering (Lamport’s algorithm)
Introduction:
Assign sequence numbers to messages
All cooperating processes can agree on order of events vs. physical
clocks: time of day
Assume no central time source
Each system maintains its own local clock
No total ordering of events
No concept of happened-when
Lamport’s “happened-before” notation
a bevent a happened before event b
e.g.:a: message being sent, b: message receipt
Transitive:
if a b and b c then a c
Algorithm/Technique Used:
Pseudo Code:
Each processor has a local logical clock: my_TS
Each event e has a timestamp e.TS
Each message m carries the timestamp m.TS of the sending event
Implementing
the logical clocks: Lamport’s algorithm (pseudo-code)
---------------------------------------------------------------------
Initially,
my_TS = 0
on
event e do
if
e is the receipt of message m then
my_TS := max(m.TS,my_TS)+1;
e.TS := my_TS
elseif
e is an internal event then
my_TS := my_TS+1; e.TS := my_TS
elseif
e is the sending of message m then
my_TS := my_TS+1;
e.TS := my_TS;
m.TS = my_TS;
end
Lab 2: Total Ordering (Lamport’s algorithm)
Introduction:
ab, bc, …: local events sequenced
ic, fd , dg, … : Lamport imposes a sendreceive relationship
Algorithm/Technique Used:
Introduction:
Exclusive access to such a shared resource by a process must
be ensured. This exclusive access is called Mutual Exclusion
between processes.
The sections of a program that need exclusive access to
shared resources are referred to as critical sections.
Algorithm/Technique Used:
Pseudo Code:
start:
X := i
if Y <> free
goto start
Y := i
if X <> i
{ delay }
if Y <> i
goto start {
critical section }
Y := free
{ non-critical section
} goto start
start:
B[i] := true
X := i
if Y <> free
B[i] := false
repeat until Y = free
goto start
Y := i
if X <> i
B[i] := false
for j := 1 to N
repeat while B[j]
if Y <> i
repeat until Y = free
goto start
{ critical section
} Y := free
B[i] := false
{ non-critical section
} goto start
Lab 4: Election Algorithm (Bully)
1. Introduction:
If each process has a unique identity, and the identities are ordered
Elect the non-crashed node with minimum/maximum identity
Formally, an algorithm is an election algorithm iff:
Each process has the same local algorithm
The algorithm is decentralized
It can be initiated by any number of processes in the system
It reaches a terminal configuration, and in each reachable terminal
configuration one process is in state leader and the rest are in the
state lost
2. Algorithm/Technique Used:
2. Introduction:
Deadlock prevention is possible because of the presence of atomic
transactions.
Deadlock avoidance is never used in distributed system; in fact, it
is not even used in single processor systems.
The problem is that the banker’s algorithm needs to know (in
advance) how much of each resource every process will
eventually need. This information is rarely, if ever, available.
3. Algorithm/Technique Used:
5. Pseudo Code: