The compare and swap instruction mechanism is given below :
int comapre_and_swap ( int *word, int testval, int newval) {
int oldval;
oldval = *word;
if(oldval != testval)
*word = testval;
return oldval;
}
A. The above implementation is correct , guarantees Mutual Exclusion and Progress
B.The above implementation is incorrect because, wrong word value is set by the processes.