Mutual Exclusion Problem

后端 未结 6 1107
陌清茗
陌清茗 2021-01-13 16:47

Please take a look on the following pseudo-code:

boolean blocked[2];
int turn;
void P(int id) {
      while(true) {
             blocked[id] = true;
                 


        
6条回答
  •  爱一瞬间的悲伤
    2021-01-13 17:26

    Maybe you need to declare blocked and turn as volatile, but without specifying the programming language there is no way to know.

提交回复
热议问题