@pkhuong @tobinbaker
#hazardpointers w/o the membar was done as POC around this time
https://groups.google.com/g/comp.programming.threads/c/XU6BtGNSkF0/m/AmWXvkGn3DAJ?pli=1

EBR wait-free w/o membar implementation (smrproxy) in here https://github.com/jseigh/proxies

Also there are about 2 or more ways to do #waitfree hazard pointers. See postings in https://jseigh.wordpress.com/

Hazard Pointers w/o memory barrier.

There are about 3 or 4 ways to make #hazardpointers #waitfree instead of merely #lockfree. 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.

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! 🥳
https://github.com/Zirias/poser/blob/master/src/lib/core/sharedobj.c

[MS96] https://dl.acm.org/doi/10.1145/248052.248106
[WICBS18] https://www.cs.rochester.edu/u/scott/papers/2018_PPoPP_IBR.pdf

#coding #c #c11 #atomics

poser/src/lib/core/sharedobj.c at master · Zirias/poser

POsix SERvices framework for C. Contribute to Zirias/poser development by creating an account on GitHub.

GitHub