Question: This problem is related Sequential Consistency. Consider the following code segments executed by 3 threads. Thread1? Lock a=1 print(b,c) Unlock Therad2 Lock b=2 print(a,c) Unlock

 This problem is related Sequential Consistency. Consider the following code segments

This problem is related Sequential Consistency. Consider the following code segments executed by 3 threads.

Thread1? Lock a=1 print(b,c) Unlock

Therad2 Lock b=2 print(a,c) Unlock

Thread3 Lock c=3 print(a,b) Unlock

a). Assume that initially all variables are set to zero. generated by the print statements.

Show at least 3 different correct outputs

b). Now consider the same code without using locks.

Thread1 a = 1 print(b,c)

Therad2 b = 2 print(a,c)

Thread3 c =3 print(a,b)

Show 3 possible correct outputs, based on sequential consistency, but different from those you have shown in part (a).

2. (22%) This problem is related Sequential Consistency. Consider the following code segments executed by 3 threads Therad2 Threadl Lock Thread3 Lock Lock print(b,c) Unlock print(a,c) Unlock print(a,b) Unlock a). Assume that initially all variables are set to zero. Show at least 3 different correct outputs generated by the print statements b). Now consider the same code without using locks. Threadl Therad2 Thread3 print(b,c) print(a,c) print(a,b) Show 3 possible correct outputs, based on sequential consistency, but different from those you have shown in part (a)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!