2 ms·
I think you're mixing up allocation with a data structure. There are lots of implementations of lock free lists and stacks in C++ out there. One simple implemen
by CyberDildonics 4y ago
I think you're mixing up allocation with a data structure. There are lots of implementations of lock free lists and stacks in C++ out there. One simple implementation is an array where every index holds the next index. A current variable holds the next index to deal with and a version number.
When you want to allocate an index you check the current index and version, and replace it with the index points to if the version is the same. Freeing is the reverse since you have an index to give the list.
These indices are used to coordinate to a second array where you can store whatever data you want.
Here are some other techniques.
https://people.csail.mit.edu/shanir/publications/Lock_Free.pdf https://people.csail.mit.edu/shanir/publications/Lock_Free.p...
https://www.boost.org/doc/libs/1_55_0/boost/lockfree/stack.hpp https://www.boost.org/doc/libs/1_55_0/boost/lockfree/stack.h...
https://lumian2015.github.io/lockFreeProgramming/lock-free-stack.html https://lumian2015.github.io/lockFreeProgramming/lock-free-s...
Still, I'm not sure what garbage collection changes about these techniques. Lock free lists have been studied for a long time, they have nothing to do with memory allocation.