q2s05a

CS 6378, Spring 2005
Quiz 2. March 24, 2005
Student Name:
ID #:
Important:
a. Examination is for 5 marks. Duration: 20 minutes.
b. Talk to me during the exam if you want to make any assumptions and
write the assumptions explicitly.
c. You may use the blank page on the left hand side as well as at the end.
d. Do not exceed allowed number of sentences for explanations.
Questions:
1. The initial status vectors of sites in Singhal’s algorithm is as below. How will this table look
like after the following request patterns:
 S1 receives requests from S5 and S6 simultaneously.
 S2 sends token request and gets the token
Write the table contents after S2 finishes critical section.
(2 Marks)
N
N
N
N
N
N
N
N
R
N
R
N
N
N
R
N
H
N
N
R
N
N
N
4
3
R
R
R
2
1
R
R
R
R
6
N
5
R
R
R
R
S6
S2
S5
S4 S3
Status Vector SV in each site Si
N
S1
Answer:
R
R
N
N
N
N
N
N
R
N
R
N
N
H
N
R
N
R
R
N
R
N
R
4
N
N
3
N
2
1
R
N
N
R
6
N
5
N
R
R
R
S6
S2
S5
S4 S3
Status Vector SV in each site Si
R
S1
Assumptions: S2’s request reaches S1 after S5 gets the token. S2 receives S5 and S6’s request
after it sent its 1st request to S1. Then, S2 sends its request to both S5 and S2. After S5, token
visits S6. S6 sends the token to S2. Token remains at S2 (as there are no more requests). Note
that the stair-case pattern is preserved after the token stays at S2.
(Other answers with appropriate assumptions will be given due credit).
1
2. What is the concurrency set of a1 in the 3-phase commit protocol?
(Concurrency set: Let Si denote the state of the site i. The set of all the states that may be
concurrent with it is concurrency set (C(si)).)
(1 Mark)
Coordinator
Cohort i
q1
C_R received/
Agreed msg sent
Commit_Request
message sent to
all cohorts
One or more abort
reply/ Abort msg
sent to all cohorts
a1
w1
wi
All agreed/
Prepare msg
to all
Prep msg
received/
send Ack
P1
qi
C_R received/
Abort msg sent
Abort from
coordinator
Pi
All cohorts
Ack/ Send Commit
msg to all
c1
Commit
received from
coordinator
ci
Answer:
C(a1) = {qi,wi,ai}
2
ai
3. The static voting algorithm has the read quorum (r) and write quorum (w) as follows: w + r >
v; w > v/2. What is the minimum number of site failures that can be tolerated for a read operation
to succeed? Assume each replica has a vote of 1.
(1 Mark)
Answer:
(Since each replica has a vote of 1, number of sites = v).
Minimum value of r should be v/2. So v/2 site failures can be tolerated.
As some of you pointed out, the above solution is a particular solution. Other logical solutions
will be given due credit. General solution of the form (v-r) failures will be tolerated will also be
give credit.
4. If the deadlock persistence time is low, does that mean there is no deadlock? Why? (1 sentence
reason is a must to get credit).
(1 Mark)
Answer:
No, the deadlock could have been resolved during that short time.
3
Brief Descriptions of Algorithms
1. Singhal’s Algorithm:
 Data Structures:
 Si maintains SVi[1..N] and SNi[1..N] for storing information on other sites: state and
highest sequence number.
 Token contains 2 arrays: TSV[1..N] and TSN[1..N].
 States of a site
 R : requesting CS
 E : executing CS
 H : Holding token, idle
 N : None of the above
 Initialization:
 SVi[j] := N, for j = N .. i; SVi[j] := R, for j = i-1 .. 1; SNi[j] := 0, j = 1..N. S1 (Site 1) is
in state H.
 Token: TSV[j] := N & TSN[j] := 0, j = 1 .. N.

 Requesting CS
 If Si has no token and requests CS:
 SVi[i] := R. SNi[i] := SNi[i] + 1.
 Send REQUEST(i,sn) to sites Sj for which SVi[j] = R. (sn: sequence
number, updated value of SNi[i]).
 Receiving REQUEST(i,sn): if sn <= SNj[i], ignore. Otherwise, update SNj[i] and
do:
 SVj[j] = N -> SVj[i] := R.
 SVj[j] = R -> If SVj[i] != R, set it to R & send REQUEST(j,SNj[j]) to Si.
Else do nothing.
 SVj[j] = E -> SVj[i] := R.
 SVj[j] = H -> SVj[i] := R, TSV[i] := R, TSN[i] := sn, SVj[j] = N. Send
token to Si.
 Executing CS: after getting token. Set SVi[i] := E.
 Releasing CS
 SVi[i] := N, TSV[i] := N. Then, do:
 For other Sj: if (SNi[j] > TSN[j]), then {TSV[j] := SVi[j]; TSN[j] :=
SNi[j]}
 else {SVi[j] := TSV[j]; SNi[j] := TSN[j]}
 If SVi[j] = N, for all j, then set SVi[i] := H. Else send token to a site Sj provided
SVi[j] = R.
4