Filter Lock Algorithm

会有一股神秘感。 提交于 2019-12-04 08:30:41

My reading of

(∃k != me) (level[k] >= i && victim[i] == me)

is "there exists some k other than me such that level[k] >= i && victim[i] == me".

The loop spins until there is no k for which the condition holds.

Here is another way to state the same thing:

boolean conflicts_exist = true;
while (conflicts_exist) {
   conflicts_exist = false;
   for (int k = 1; k < n; k++) {
      if (k != me && level[k] >= i && victim[i] == me) {
         conflicts_exist = true;
         break;
      }
   }
}

It can be written as:

for (int k = 0; k < n; k++) {
      while ((k != me) && (level[k] >= i && victim[i] == me)) {
           //spin wait
      }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!