2011-02-28 73 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

相關問題