Question: Consider the following psudocode. int x; P 1 ( ) { compare _ and _ swap ( x , compare _ and _ swap (

Consider the following psudocode.
int x;
P1(){
compare_and_swap(x,compare_and_swap(x,1,2),1);
}
P2(){
int y =9;
exchange(x,y);
exchange(y,x);
}
main(){
x =0;
P1();
P2();
}
What are the possible values of x after P1 and P2 finish?
0,1
0,2
9,2

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!