657 views
4 4 votes
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.

Please log in or register to answer this question.

Position:
Show:

No related questions found