-- Feb 28 In-Class Exercise Thread
Initialize: C[0], C[1] = 0, 0
1st iteration
P[0]
Step 0: B[0] = 0
Step 1: Read Register C[0], fetch R[0]
Step 2c: Now (R[0] = 0 and B[0] = 0)
-> B[0] = Random(0,1) // o/p is 0
-> Write B[0] -> R[0] in C[0] // C[0] is 0
Step 3: Once P[1] completes step 2, P[0] Exchange register with P[1]
P[1]
Step 0: B[1] = 0
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 0 and B[1] = 0)
-> B[1] = Random(0,1) // o/p is 0
-> Write B[1] -> R[1] in C[1]
Step 3: P[1] Exchange register with P[0]
2nd Iteration
P[0]
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 0 and B[0] = 0)
-> B[0] = Random(0,1) //o/p is 1
-> Write B[0] -> R[1] in C[1]
Step 3: Once P[1] completes step 2, P[0] Exchange register with P[1]
P[1]
Step 1: Read Register C[0], fetch R[0]
Step 2c: Now (R[0] = 0 and B[1] = 0)
-> B[1] = Random(0,1) //o/p is 0
-> Write B[1] -> R[0] in C[0]
Step 3: P[0] Exchange register with P[1]
3rd Iteration
P[0]
Step 1: Read Register C[0], fetch R[0]
Step 2b: Now (R[0] = 0 and B[0] = 1)
-> write C[0] = #
-> Halt
p[1]
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 1 and B[1] = 0)
-> B[1] = Random(0,1) //o/p is 1
-> Write B[1] -> R[1] in C[1]
Step 3: P[1] exchange register with P[0]
Final : C[0] has #
(
Edited: 2018-02-28)
Initialize: C[0], C[1] = 0, 0
'''1st iteration'''
P[0]
Step 0: B[0] = 0
Step 1: Read Register C[0], fetch R[0]
Step 2c: Now (R[0] = 0 and B[0] = 0)
-> B[0] = Random(0,1) // o/p is 0
-> Write B[0] -> R[0] in C[0] // C[0] is 0
Step 3: Once P[1] completes step 2, P[0] Exchange register with P[1]
P[1]
Step 0: B[1] = 0
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 0 and B[1] = 0)
-> B[1] = Random(0,1) // o/p is 0
-> Write B[1] -> R[1] in C[1]
Step 3: P[1] Exchange register with P[0]
'''2nd Iteration'''
P[0]
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 0 and B[0] = 0)
-> B[0] = Random(0,1) //o/p is 1
-> Write B[0] -> R[1] in C[1]
Step 3: Once P[1] completes step 2, P[0] Exchange register with P[1]
P[1]
Step 1: Read Register C[0], fetch R[0]
Step 2c: Now (R[0] = 0 and B[1] = 0)
-> B[1] = Random(0,1) //o/p is 0
-> Write B[1] -> R[0] in C[0]
Step 3: P[0] Exchange register with P[1]
'''3rd Iteration'''
P[0]
Step 1: Read Register C[0], fetch R[0]
Step 2b: Now (R[0] = 0 and B[0] = 1)
-> write C[0] = #
-> Halt
p[1]
Step 1: Read Register C[1], fetch R[1]
Step 2c: Now (R[1] = 1 and B[1] = 0)
-> B[1] = Random(0,1) //o/p is 1
-> Write B[1] -> R[1] in C[1]
Step 3: P[1] exchange register with P[0]
'''Final''': C[0] has #