小编Sar*_*aki的帖子

如果我们重新排序彼得森算法中的命令以实现互斥,会发生什么?

我已经阅读了 Peterson 互斥算法的这篇文章。然后有一个问题,如果我们在 do...while 循环中重新排序第一个和第二个命令,会发生什么?如果我们这样做,我看不到会发生什么...有人可以告诉我我错过了什么吗?

do {
     flag[me] = TRUE;
     turn = other;
     while (flag[other] && turn == other)
             ;
     critical section
     flag[me] = FALSE;
     remainder section
   } while (TRUE);
Run Code Online (Sandbox Code Playgroud)

algorithm command mutual-exclusion

7
推荐指数
1
解决办法
2474
查看次数

标签 统计

algorithm ×1

command ×1

mutual-exclusion ×1