Re:A flexible, lightweight, spin-lock barrier
by PaulDavisThe1st on Wednesday March 16, 2022 @10:23AM
(#30699187)
Neither writer nor reader needs to block. The writer does CAS on the generation counter to ensure it is safe against other writer threads. The reader just spins until it reads the same generation counter value before and after the read.
Re:A flexible, lightweight, spin-lock barrier
by gpderetta on Wednesday March 16, 2022 @10:44AM
(#30699461)
What happens if a writer halts in the middle of a write? How the reader can ever complete a consistent read?
With double buffering the reader can always fall back on the other buffer (hence it is lock-free, assuming somehow that writers always agree on the current write buffer), but then a fast writer can always prevent a slow reader from reading a consistent timestamp in a row which means it is not wait free.
Edit: with double buffering I guess it would be lock free, but still not wait free as a fast producer can still starve consumers indefinitely.
/Pedantic