Lock-free algorithm library
Is there a library that implements lock-free algorithms(queue, linked list and others) written in C (not in C++)开发者_开发技巧? I've taken a look at some libraries like Intel's, but I would like to use generic libraries, at least more generic than Intel's one.
See Practical lock-free data structures from the University of Cambridge
I've written my own, Rig, currently queue, stack and list are there, hash-table will soon follow. While I'm still working on it, it is intended for public consumption, and the API is mostly stable, just use the SVN trunk. :)
The only other such library in C that I know of is liblfds, though I've never used it.
liblfds
http://www.liblfds.org
Wiki with full API documentation, forum for questions, blog for reading the author rattle on :-)
Platform independent. Out of the box for Windows, Linux, Intel and ARM.
Release 7 should be out in a month or two. Will add run-time cache line alignment, backoff and SMR. (SMR also gives a ton of the other CPU types - basically, anything GCC compiles on which supports atomic ops, e.g. SPARC, MIPS, IA64, etc).
Also, there's no license - you can use the code however you want. Make money! It's not GPL.
I'm currently writing a lock-free lib but it's C++. Here's an STL-like Lock-Free Doubly-Linked List.
The memory manager it uses is quite powerful (32-bit CAS without ABA issues) so I'm using it to create a complete set of containers: a lock-free map/set (using skip lists), a lock-free bag (instead of queue/stack), and a lock-free unordered map (hash table using split-ordered lists).
For more info about the doubly-linked list check out my answer to a related question.
精彩评论