#hazardpointers

Joe Seighjwseigh
2025-07-27

There are about 3 or 4 ways to make instead of merely . I had though Linux restartable sequences (RSEQ) couldn't be inlines but apparently they can. I did a quick and dirty perf rest and it looks like protect() runs 3x faster w/o that conditional branch. But this only works on Linux and you need asynchronous memory barriers.

Felix Palmen :freebsd: :c64:zirias@bsd.cafe
2025-06-13

The #lockfree command #queue in #poser (for #swad) is finally fixed!

The original algorithm from [MS96] works fine *only* if the "free" function has some "magic" in place to defer freeing the object until no thread holds a reference any more ... and that magic is, well, left as an exercise to the reader. 🙈

Doing more research, I found a few suggestions how to do that "magic", including for example #hazardpointers ... but they're known to cause quite some runtime overhead, so not really an option. I decided to implement some "shared object manager" based on the ideas from [WICBS18], which is kind of a "manually triggered garbage collector" in the end. And hey, it works! 🥳
github.com/Zirias/poser/blob/m

[MS96] dl.acm.org/doi/10.1145/248052.
[WICBS18] cs.rochester.edu/u/scott/paper

#coding #c #c11 #atomics

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst