3 ms·
Some CPUs have a 128-bit compare-and-swap (lock cmpxchg16b on x64). You can build a lockless doubly-linked list with that. See for example https://gist.github.c
by Someone 9y ago
Some CPUs have a 128-bit compare-and-swap (lock cmpxchg16b on x64). You can build a lockless doubly-linked list with that. See for example https://gist.github.com/glampert/c40f2584d2fbc72316e1c8a6ef1c0436 https://gist.github.com/glampert/c40f2584d2fbc72316e1c8a6ef1...
As to the doubly-linked list in Rust: I think one could add the notions of “allocated block that must have n references to it” and accompanying “one of n references to an allocated block”. That could lead, for example, to code
let p1, p2 = heap::allocate2(elem_size, align);
to allocate such a block with two references. The borrow tracker could then ensure that both p1 and p2 get stored once somewhere before the function allocating the memory returns or get returned from the function, or that both get passed to a function freeing the memory, and never used afterwards.