2011-02-28 74 views
0

我写了2个进程,以满足相互排斥,但OM不知道这是否是.. 我最初的标志值是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 

} 
事实上

他们完全一样。 这两个过程是否满足互斥? 我看不到被违反什么规定..

回答

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. 
+0

感谢lot.so易于在我eyes..my值的前面必须是相反的... – Dchris 2011-02-28 17:41:01

相关问题