integer array control [ 1 : N ] ; integer k
其中,1<= k <= N, control 的每个元素为 0、1 和 2,所有元素的初值为 0,k 的处置使任意的。
第 i 个进程( 1<= i <= N)的代码如下:
begin integer j; L0: control [i] := 1; L1: for j: = k step l until N, 1 step 1until k do begin if j = i then goto L2; if control [j] != 0 then goto L1 end; L2: control [i] := 2; L3: if control [k] != 0 and k != i then goto L0; L4: k :=i; 临界区 L5: for j := k step 1 until N, 1 step 1 until k do if j != control [j] != 0 then begin k := j; goto L6 end; L6: control [i] := 0; L7: 循环剩余部分; goto L0; end
这就是 Eisenberg-McGuire 算法, 解释算法的操作和主要特点。