Peterson lock code taken from (German) wikipedia :
# define FALSE 0 # define TRUE 1 # define N 2 int turn; int interested[N]; void enter_region(int process) { int other; other = 1 - process; interested[process] = TRUE; turn = other; while (interested[other] == TRUE && turn == other) ; } void leave_region(int process) { interested[process] = FALSE; }
Can someone think of an example where an error occurs without the function of the leave_region
function?
NB: I know for sure that the mfence function is required in the enter_region
function.
source share