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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started