2

以下代码是尝试解决 N 进程临界区问题。你能告诉我是对还是错!请给我一个小细节!请

     boolean array want[1..n] [false,…., false]
      loop forever
     non-critical section
      p1: want[i] true
      p2: for all processes j< i
      p3: if want[j]
    p4: want [i] false
    p5: while not want[j] do skip
       goto p1
       p6: for a ll processes j>i
      p7: while not want[j] do skip
     critical section
         p8: want[i] false
4

0 回答 0