跟室友一起寫作業(yè)系列...
老師要改進Dekker算法...Dekker算法畢竟是滿足了critical-problem三個條件的算法呢经伙,問題在哪里呢...
- 難道是長得看上去沒有Peterson機智?其實本質是一樣的啦...
- 只適用于兩個進程...Dekker算法是利用了對稱性不錯...但擴展到多個看上去也是可以的大不了丑了點...
- busy waiting...軟件同步機制問題都是醬啦...掛起進程看上去也沒機智到哪里去
書上有這么一句
Because of the way modern computer architectures perform basic machine-language instructions, such as load and store, there are no guarantees that Peterson’s solution will work correctly on such architectures.
看書的時候走馬觀花辜御、沒看懂就跳過去了...后來才get到這句話的意思...多線程的cpu內(nèi)存模型的弱一致性會改變load和store的順序伍派,導致Dekker算法失效
ref
https://en.wikipedia.org/wiki/Dekker%27s_algorithm
http://www.parallellabs.com/2010/12/04/why-should-we-be-care-of-volatile-keyword-in-multithreaded-applications/
(最近貴校網(wǎng)又被關在墻內(nèi)了...那些vpn看上去蠢爆了ss最近慢的不行...好絕望)