The Java implementation does not use bit stealing - it uses an atomic pointer to an immutable struct - the same can be done in Go.
> On May 6, 2021, at 6:16 AM, Vitaly Isaev <vitalyisa...@gmail.com> wrote: > > > In a well-known book "The Art of Multiprocessor Programming" by Herlihy, > Shavit some of lock-free and wait-free algorithms utilize Java's template > AtomicMarkableReference<T> type. It allows to perform single atomic CAS > operation on the pair consisting of T reference and boolean mark. > > There is no similar type in C/C++/Go stdlib, but at least in C++ it's > possible to model it using bit stealing approach (see C++ example). On x86_64 > arch only 48 bits of 64 bits are actually used, so one can store arbitrary > data in the remaining 16 bits, and work with the whole pointer and the data > atomically. > > As far as I understand, there are two requirements to implement this approach: > > Pointers must be aligned. > Pointer's low bits must be clear (if you want to store something like bool in > this area, it must not be already occupied). > But some stackowerflow users have questioned whether these remaining bits are > really free in Go. Perhaps Go runtime already uses these area for GC or some > other background routines? > So is it possible to use pointer bit stealing technique in Go? Are there any > working examples? > > Thank you > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/b9e78da6-2a88-444b-9d83-64c2341bdc22n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/D4D76F2F-28DD-4865-AAE0-31528834DDC6%40ix.netcom.com.