+ All Categories
Home > Documents > ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock...

ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock...

Date post: 12-Sep-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
41
ECE454: Assignment 7 Ordering and Deadlocks Evan Jones [email protected]
Transcript
Page 1: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

ECE454: Assignment 7Ordering and Deadlocks

Evan Jones

[email protected]

Page 2: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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.

Page 3: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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

Page 4: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

TOM: Do not want this!

Page 5: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1. a) Draw a process-time diagram illustrating the sequence of messages transmitted.

Page 6: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 0: A: (0, 0) B: (0, 0) C: (0, 0)

Page 7: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 0.5: A: (0, 0) B: (0, 0) C: (0, 0)

Page 8: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 1+ε : A: (0, 0) B: (1, 0) C: (0, 0)

Page 9: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 2+ε : A: (1, 0) B: (1, 1) C: (1, 0)

Page 10: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 2.5+ε : A: (1, 1) B: (1, 1) C: (1, 0)

Page 11: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 3+ε : A: (1, 2) B: (1, 1) C: (1, 0)

Page 12: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 3.5+ε : A: (1, 2) B: (2, 2) C: (2, 1)

Page 13: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 3.5+ε : A: (2, 2) B: (2, 2) C: (2, 1)

Page 14: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

1.(a) Totally Ordered MulticastTime 3.5+ε : A: (2, 2) B: (2, 2) C: (2, 2)

Page 15: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. Given the following transactions:

Begin_Trans 1

A = A + B

End_Trans

Begin_Trans 2

A = A - B

End_Trans

Page 16: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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:

Page 17: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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

Page 18: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

Conflicting Operations

• Read - Write• Write - Write

• Read - Read: Order does not matter

Page 19: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (a)Transaction 1 Transaction 2

R1(A)

R2(A)

R1(B)

R2(B)

W1(A)

W2(A)

Page 20: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (a)Transaction 1 Transaction 2

R1(A)

R2(A)

R1(B)

R2(B)

W1(A)

W2(A)

Not Serializable

Page 21: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (b)Transaction 1 Transaction 2

R1(B)

R2(B)

R1(A)

W1(A)

R2(A)

W2(A)

Page 22: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (b)Transaction 1 Transaction 2

R1(B)

R2(B)

R1(A)

W1(A)

R2(A)

W2(A)

Serializable: 1, 2

Page 23: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (c)Transaction 1 Transaction 2

R1(B)

R2(B)

R1(A)

R2(A)

W2(A)

W1(A)

Page 24: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (c)Transaction 1 Transaction 2

R1(B)

R2(B)

R1(A)

R2(A)

W2(A)

W1(A)

Not Serializable

Page 25: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (d)Transaction 1 Transaction 2

R2(A)

R1(B)

R2(B)

W2(A)

R1(A)

W1(A)

Page 26: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (d)Transaction 1 Transaction 2

R2(A)

R1(B)

R2(B)

W2(A)

R1(A)

W1(A)

Serializable: 2, 1

Page 27: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (e)Transaction 1 Transaction 2

R1(A)

R1(B)

R2(B)

W1(A)

R2(A)

W2(A)

Page 28: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

2. (e)Transaction 1 Transaction 2

R1(A)

R1(B)

R2(B)

W1(A)

R2(A)

W2(A)

Serializable: 1, 2

Page 29: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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.

Page 30: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

3.

Page 31: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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

Page 32: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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

Page 33: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

3. a) Wait-Die

Page 34: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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

Page 35: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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)

Page 36: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

3. b) Wound-Wait

Page 37: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

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.

Page 38: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

Deadlock Detection

• Allow all transactions to wait for resources

• If a cycle is detected in the wait-for graph, kill one of the transactions

Page 39: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

3. c) Deadlock Detection

Page 40: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

Random Project 2 Stuff

• I know nothing!• Contact Sean Lau <slau@engmail>

with any questions

Page 41: ECE454: Assignment 7 Ordering and Deadlocksmamunawa/ece454/ordering_deadlock_tut.p… · deadlock prevention? It takes 1µs to restart a killed transaction. If events happen simultaneously,

Please keep me company during my office hours!

Mondays 4:30 - 5:30 in EIT 4131

• Newsgroup: uw.ece.ece454 (preferred)• Email: [email protected]


Recommended