开发者

does my solution satisfy the requirements for a mutual exclusion

i wrote 2 processes in order to satisfy mutual exclusion but om not sure if it is.. my initial flag value is 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

}

in fact they are exactly the same. does those 2 processes satisfy the mutual exclusion? i cant开发者_开发问答 see what requirement is violated..


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜