Lockfree standard collections and tutorial or articles

时光怂恿深爱的人放手 提交于 2019-12-22 08:52:04

问题


Does someone know of a good resource for the implementation (meaning source code) of lock-free usual data types. I'm thinking of Lists, Queues and so on?

Locking implementations are extremely easy to find but I can't find examples of lock free algorithms and how to exactly does CAS work and how to use it to implement those structures.


回答1:


Check out Julian M Bucknall's blog. He describes (in detail) lock-free implementations of queues, lists, stacks, etc.

http://www.boyet.com/Articles/LockfreeQueue.html

http://www.boyet.com/Articles/LockfreeStack.html




回答2:


http://www.liblfds.org

Written in C.




回答3:


If C++ is okay with you, take a look at boost::lockfree. It has lock-free Queue, Stack, and Ringbuffer implementations.

In the boost::lockfree::details section, you'll find a lock-free freelist and tagged pointer (ABA prevention) implementation. You will also see examples of explicit memory ordering via boost::atomic (an in-development version of C++0x std::atomic).

Both boost::lockfree and boost::atomic are not part of boost yet, but both have seen attention from the boost-development mailing list and are on the schedule for review.



来源:https://stackoverflow.com/questions/1725827/lockfree-standard-collections-and-tutorial-or-articles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!