Post your solution to the Apr 15 In-Class Exercise to this thread.
Best,
Chris
step 1) - sl_1(X) Has lock: 1 (shared) -- Waiting for lock: Group Mode: S
step 2) - ul_2(x) Has lock : 1 (shared), 2 (upgrade) -- Waiting for lock: Group Mode: U
step 3) - sl_3(x) Has lock : 1 (shared), 2 (upgrade) -- Waiting for lock: 3 (shared) Group Mode: U
step 4) - xl_2(X) Has lock: 1 (shared), 2 (upgrade) -- Waiting for lock: 3 (shared), 2 (exclusive) Group Mode: U
step 5) - u_1(X) Has lock: 2 (exclusive) -- Waiting for lock: 3 (shared) Group Mode: X
step 6) - xl_4(X) Has lock: 2 (exclusive),-- Waiting for lock: 3 (shared), 4 (exclusive) Group Mode: X
step 7) - u_2(X) Has lock: 3 (shared) -- Waiting for lock: 4 (exclusive) Group Mode: S
step 8) - sl_5(X) Has lock: 3 (shared), 5 (shared) -- Waiting for lock: 4 (exclusive) Group Mode: S
step 9) - u_3(X) Has lock: 5 (shared) -- Waiting for lock: 4 (exclusive) Group Mode: S
(Edited: 2020-04-15)</pre>
(Edited: 2020-04-15)| { |
|---|
! Transaction !! Element Info |-
| sl_1(X) | 1 (shared) | |
|---|---|---|
| ul_2(X) | 1 (shared) 2 (update) | |
| - | ||
| sl_3(X) | 1 (shared) 2 (update) 3 (shared - waiting) | |
| - | ||
| xl_2(X) | 1 (shared) 2 (update) 3 (shared - waiting) 2 (exclusive - waiting) | |
| - | ||
| u_1(X) | 2 (exclusive) 3 (shared - waiting) | |
| - | ||
| xl_4(X) | 2 (exclusive) 3 (shared - waiting) 4 (exclusive) | |
| - | ||
| u_2(X) | 3 (shared) 4 (exclusive - waiting) | |
| - | ||
| sl_5(X) | 3 (shared) 5 (shared) 4 (exclusive - waiting) | |
| - | ||
| u_3(X) | 5 (shared) 4 (exclusive - waiting) | |
| } |
sl_1(X), ul_2(X), sl_3(X), xl_2(X), u_1(X), xl_4(X), u_1(X), sl_5(X), u_3(X)
T1_S_no - wait: ----
T2_U_no - wait:----
T3_S_yes - wait: T3----
T2_X_yes - wait: T3, T2----
T1 unlock ----
T2_X_no - wait: T3----
T4_X_yes - wait: T3,T4----
T2 unlock ----
T3_X_no - wait: T4----
T5_S_yes - wait: T4,T5----
T3 unlock----
T4_X_no - wait: T5----
(Edited: 2020-04-15)sl_1(X) - Has lock: T1 (shared), Waiting: None ul_2(x) - Has lock: T1 (shared), Waiting: T2 (upgrade) sl_3(X) - Has lock: T1 (shared), Waiting: T2 (upgrade), T3(shared) xl_2(X) - Has lock: T1 (shared), T2 (exclusive lock), Waiting: T3 (shared) u_1(X) - Has lock: T2 (exclusive lock), Waiting: T3 (shared) xl_4(X) - Has lock: T2 (exclusive lock), Waiting: T3 (shared), T4 (exclusive) u_2(X) - Has lock: T3 (shared), Waiting: T4 (exclusive) sl_5(X) - Has lock: T3 (shared), Waiting: T4 (exclusive), T5(shared) u_3(X) - Has lock: T4 (exclusive), Waiting: T5 (shared)
sl_1(X): T1 -> S
ul_2(X): T1 -> S, T2 -> U
sl_3(X): T1 -> S, T2 -> U, T3 -> S (wait)
xl_2(X): T1 -> S, T2 -> U, T3 -> S (wait), T2 -> X (wait)
u_1(X): T2 -> X, T3 -> S (wait)
xl_4(X): T2 -> X, T3 -> S (wait), T4 -> X (wait)
u_2(X): T3 -> S, T4 -> X (wait)
sl_5(X): T3 -> S, T4 -> X (wait), T5 -> S
u_3(X): T5 -> S, T4 -> X (wait)
<pre> sl_1(X) - {Has lock: T1 (shared)}, {Waiting: None} ul_2(x) - {Has lock: T1 (shared)}, {Waiting: T2 (upgrade)} sl_3(X) - {Has lock: T1 (shared)}, {Waiting: T2 (upgrade), T3(shared)} xl_2(X) - {Has lock: T1 (shared), T2 (exclusive lock)}, {Waiting: T3 (shared)} u_1(X) - {Has lock: T2 (exclusive lock)}, {Waiting: T3 (shared)} xl_4(X) - {Has lock: T2 (exclusive lock)}, {Waiting: T3 (shared), T4 (exclusive)} u_2(X) - {Has lock: T3 (shared)}, {Waiting: T4 (exclusive)} sl_5(X) - {Has lock: T3 (shared)}, {Waiting: T4 (exclusive), T5(shared)} u_3(X) - {Has lock: T4 (exclusive)}, {Waiting: T5 (shared)} </pre>
(Edited: 2020-04-15)step 1) sl_1(X)
T1 shared lock
step 2) ul_2(X)
T1 shared lock, T2 updated
step 3) sl_3(X)
T1 shared, T2 updated, waiting for T3 shared
step 4) xl_2(X)
T1 shared, T2 updated, waiting for T3 shared and T2 exclusive
step 5) u_1(X)
T2 exclusive, waiting for T1 upgrade
step 6) xl_4(X)
T2 exclusive, T1 upgraded, waiting for T4 exclusive
step 7) u_1(X)
Waiting for T4 exclusive
set 8) sl_5(X)
T5 shared, waiting for T4 exclusive
step 9) u_3(X)
T5 shared, waiting for T4 exclusive