跟室友一起写作业系列...
老师要改进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内存模型的弱一致性会改变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/
(最近贵校网又被关在墙内了...那些vpn看上去蠢爆了ss最近慢的不行...好绝望)