Post your solutions to the March 6 In-Class Exercise to this thread.
Best,
Chris
Processor 0:
Choose R1
Wait for lock
Get R1 Lock
Read R=0 t=1 (case b)
write B=0 T=1
Release R1 Lock
Go to R2, get R2 Lock
Read R=# (case a)
Halt
Processor 1 Choose R1 Get Lock (Ahead of Processor 0) Read R=0 T=0 (case e) Random bit 0 Write R=B=0, T=t=1 Release R1 lock Go to R2, get R2 lock Read R=0 T=0 (case c) Write # and halt and release R2 lock
(Edited: 2019-03-06)<pre> Partner: Yaoyan
C[0] = (0,0), C[1] = (0,0)
P[0] chooses C[0], P[1] chooses C[1] P[0] reads from C[0] T[0] = 0, t[0] = 0, B[0] = 0, R[0] Case e) B[0] = 0, T[0] = 1, t[0] = 1, R[0] = 0 C[0] = (1, 0)
P[1] reads from C[1] T[1] = 0, t[1] = 0, B[1] = 0, R[1] = 0 Case e) B[1] = 0, T[1] = 1, t[1] = 1, R[1] = 0 C[1] = (1, 0)
P[1] reads from C[0] T[1] = 1, t[1] = 1, B[1] = 0, R[1] = 0 Case e) B[1] = 1, T[1] =2, t[1] = 2, R[1] = 1 C[0] = (2, 1)
P[1] reads from C[1] T[1] = 2, t[1] = 1, B[1] = 1, R[1] = 0 Case c) C[1] = (3, #) P[1] halts
P[0] reads C[1] T[0] = 1, t[0] = 3, B[0] = 0, R[0] = # Case a) P[0] halts </pre>
(Edited: 2019-03-06)