Please take a look on the following pseudo-code:
boolean blocked[2]; int turn; void P(int id) { while(true) { blocked[id] = true;
Compiler might have optimized out the "empty" while loop. Declaring variables as volatile might help, but is not guaranteed to be sufficient on multiprocessor systems.