Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
1. Consider a system of three processes, A, B, and C, which are communicating using the totally-ordered multicast algorithm described in class. The time for a message to go from A to B is 1 unit, from A to C is 2 units, and from B to C is 1.5 units. The time to respond to a message is ε . Process A multicasts a message a time 0, and process C multicasts a message at time 0.5.
Totally Ordered Multicast
Messages are processed in the same order at all nodes.
• Messages carry Lamport timestamps• Messages are acknowledged• All communication is multicast• Reliable, FIFO order• Message processed when at head of queue,
and has received all acknowledgements
TOM: Do not want this!
1. a) Draw a process-time diagram illustrating the sequence of messages transmitted.
1.(a) Totally Ordered MulticastTime 0: A: (0, 0) B: (0, 0) C: (0, 0)
1.(a) Totally Ordered MulticastTime 0.5: A: (0, 0) B: (0, 0) C: (0, 0)
1.(a) Totally Ordered MulticastTime 1+ε : A: (0, 0) B: (1, 0) C: (0, 0)
1.(a) Totally Ordered MulticastTime 2+ε : A: (1, 0) B: (1, 1) C: (1, 0)
1.(a) Totally Ordered MulticastTime 2.5+ε : A: (1, 1) B: (1, 1) C: (1, 0)
1.(a) Totally Ordered MulticastTime 3+ε : A: (1, 2) B: (1, 1) C: (1, 0)
1.(a) Totally Ordered MulticastTime 3.5+ε : A: (1, 2) B: (2, 2) C: (2, 1)
1.(a) Totally Ordered MulticastTime 3.5+ε : A: (2, 2) B: (2, 2) C: (2, 1)
1.(a) Totally Ordered MulticastTime 3.5+ε : A: (2, 2) B: (2, 2) C: (2, 2)
2. Given the following transactions:
Begin_Trans 1
A = A + B
End_Trans
Begin_Trans 2
A = A - B
End_Trans
2. Define the operation Ri(x) as transaction i reads variable x. Likewise, define Wi(x) as transaction i writes variable x. Which of the following execution histories is serializable and why:
Serializability
• A schedule or history is serializable if the result is identical to running the transactions in some sequential order
• Systems want to execute transactions concurrently, where possible
• We need to be able to find serializable orderings of operations
Conflicting Operations
• Read - Write• Write - Write
• Read - Read: Order does not matter
2. (a)Transaction 1 Transaction 2
R1(A)
R2(A)
R1(B)
R2(B)
W1(A)
W2(A)
2. (a)Transaction 1 Transaction 2
R1(A)
R2(A)
R1(B)
R2(B)
W1(A)
W2(A)
Not Serializable
2. (b)Transaction 1 Transaction 2
R1(B)
R2(B)
R1(A)
W1(A)
R2(A)
W2(A)
2. (b)Transaction 1 Transaction 2
R1(B)
R2(B)
R1(A)
W1(A)
R2(A)
W2(A)
Serializable: 1, 2
2. (c)Transaction 1 Transaction 2
R1(B)
R2(B)
R1(A)
R2(A)
W2(A)
W1(A)
2. (c)Transaction 1 Transaction 2
R1(B)
R2(B)
R1(A)
R2(A)
W2(A)
W1(A)
Not Serializable
2. (d)Transaction 1 Transaction 2
R2(A)
R1(B)
R2(B)
W2(A)
R1(A)
W1(A)
2. (d)Transaction 1 Transaction 2
R2(A)
R1(B)
R2(B)
W2(A)
R1(A)
W1(A)
Serializable: 2, 1
2. (e)Transaction 1 Transaction 2
R1(A)
R1(B)
R2(B)
W1(A)
R2(A)
W2(A)
2. (e)Transaction 1 Transaction 2
R1(A)
R1(B)
R2(B)
W1(A)
R2(A)
W2(A)
Serializable: 1, 2
3. Suppose you have three transactions, A, B and C, that you wish to perform. The time for each of these transactions to execute is 10µs if there is no resource conflict. They each reserve resources according to the following diagram. All resources are released immediately upon terminating the transaction, whether the transaction is completed or aborted.
3.
3. a) If we assume that all three transactions start at time 0, when will each of the transactions terminate if we use wait-die deadlock prevention?
It takes 1µs to restart a killed transaction.
If events happen simultaneously, A is first, then B, then C
Wait-Die Deadlock Prevention
• If a resource is currently being used by an older transaction, restart (die)
• If it is being used by a younger transaction, wait
3. a) Wait-Die
3. b) When will each of the transactions terminate if we use wound-wait deadlock prevention?
It takes 1µs to restart a killed transaction.
If events happen simultaneously, A is first, then B, then C
Wound-Wait Prevention
• If a resource is being used by an older transaction, wait
• If it is being used by a younger transaction, restart it (wound it)
3. b) Wound-Wait
3. c) When will each of the transactions terminate if we use deadlock detection?
Each transaction will inform the deadlock detector immediately after requesting, receiving or releasing a resource. The deadlock detector will receive this information and determine within 2 µs whether or not a deadlock has occurred. If one has occurred it will select the youngest transaction in the deadlock cycle for termination.
Deadlock Detection
• Allow all transactions to wait for resources
• If a cycle is detected in the wait-for graph, kill one of the transactions
3. c) Deadlock Detection
Random Project 2 Stuff
• I know nothing!• Contact Sean Lau <slau@engmail>
with any questions
Please keep me company during my office hours!
Mondays 4:30 - 5:30 in EIT 4131
• Newsgroup: uw.ece.ece454 (preferred)• Email: [email protected]