0

相互排除を満たすために2つのプロセスを書きましたが、そうであるかどうかはわかりません..私の初期フラグ値は0です.

process 1
while(1){

while flag=1 do{-nothing-}

flag=1

-enter critical section-

flag=0

}

process 2
while(1){

while flag=1 do{-nothing-}

flag=1

-enter critical section-

flag=0

}

実際、それらはまったく同じです。これらの2つのプロセスは相互排除を満たしていますか? どの要件に違反しているのかわかりません..

4

1 に答える 1

1
Process 1                            Process 2

check if flag is 0 - it is
                                          check if flag is 0 - it is
set flag to 1
                                          set flag to 1        

At that point both processes are in their critical sections.
于 2011-02-28T17:38:17.980 に答える