Distributed Systems, Edition 3 - Christopher Newport University

Christopher Newport University
CPSC 450/550 Operating Systems
Home Work (Solutions)
Distributed Concurrency Control
(for lecture 12_2)
Question 1
A server manages the objects a1, a2, ... an. The server provides two operations for its clients:
read (i) returns the value of ai
write(i, Value) assigns Value to ai
The transactions T and U are defined as follows:
T: x= read (i); write(j, 44);
U: write(i, 55);write(j, 66);
Describe an interleaving of the transactions T and U in which locks are released early with the effect that the
interleaving is not serially equivalent.
Question 2
The transactions T and U at the server are defined as follows:
T: x= read (i); write(j, 44);
U: write(i, 55);write(j, 66);
Initial values of ai and aj are 10 and 20. Which of the following interleavings are serially equivalent and
which could occur with two-phase locking?
Exercise/Homework 12_2 Question 2 (2)
(a)
T
T’s locks
x:= read(i);
U
U’s locks
write(i, 55);
write(j, 44);
write(j, 66);
Initial values:
ai = 10, aj = 20
Final result:
x= 10 ai = 55, aj = 66
Correct Result (T then U): x= 10 ai = 55, aj = 66
Exercise/Homework 12_2 Question
Question 22 (5)
(3)
Exercise/Homework
(b)
Exercise/Homework 12_2
12_2
Question
2
(3)
(d)
T
T’s locks
T’s
T
T
T’s locks
locks
x:= read(i);
x:= read(i);
write(j, 44);
read(i);
x:=
write(j,
44);
(b)
U
U
U
U’s locks
U’s
U’s locks
locks
write(i, 55);
write(i, 55);
write(j,
write(i,
55);66);
write(j, 66);
write(j, 44);
write(j, 66);
Initial values:
a = 10, aj = 20
10, aj = 20
aai i=
Initial
Initial values:
values:
i = 10, aj = 20
Final result:
x= 10 ai = 55, aj = 66
44
55, aaj =
55 aai =
x=
result:
Final
Final
Correctresult:
Result (T then U):x=
x=10
10 ai i==55,
55, aj j==66
66
44
=
a
55,
=
a
55
x=
T):
then
(U
Result
Correct
j
i
Correct Result (T then U): x= 10 ai = 55, aj = 66
Exercise/Homework 12_2 Question 2 (4)
(c)
T
T’s locks
U
U’s locks
write(i, 55);
write(j, 66);
x:= read(i);
write(j, 44);
Initial values:
ai = 10, aj = 20
Final result:
x= 55 ai = 55, aj = 44
Correct Result (U then T): x= 55 ai = 55, aj = 44
Exercise/Homework 12_2 Question 2 (5)
(d)
T
T’s locks
U
U’s locks
write(i, 55);
x:= read(i);
write(j, 66);
write(j, 44);
Initial values:
ai = 10, aj = 20
Final result:
x= 55 ai = 55, aj = 44
Correct Result (U then T): x= 55 ai = 55, aj = 44
Question 3
Consider a relaxation of two-phase locks in which read only transactions can release read locks
early. Would a read only transaction have consistent retrievals? Would the objects become
inconsistent? Illustrate your answer with the following transactions T and U :
T: x = read (i); y= read(j);
U: write(i, 55);write(j, 66);
in which initial values of ai and aj are 10 and 20.
Question 4
The executions of transactions are strict if read and write operations on an object are delayed until
all transactions that previously wrote that object have either committed or aborted. Explain how
the locking rules in Figure 12.16 ensure strict executions.
Question 5
Describe how a non-recoverable situation could arise if write locks are released after the last
operation of a transaction but before its commitment.