3
对比Peterson和Dekker的算法
我试图理解Peterson和Dekker的算法,它们非常相似并且显示出很多对称性。 我试图用非正式语言来制定算法,如下所示: Peterson's: "I want to enter." flag[0]=true; "You can enter next." turn=1; "If you want to enter and while(flag[1]==true&&turn==1){ it's your turn I'll wait." } Else: Enter CS! // CS "I don't want to enter any more." flag[0]=false; Dekker's: "I want to enter." flag[0]=true; "If you want to enter …