
On Wed, Aug 3, 2011 at 7:06 AM, Helge Bahmann <hcb@chaoticmind.net> wrote:
- if the data is changing (through a writable mapping by someone else to the page), then you have some sort of producer-/consumer-problem and that is trivialley solvable with word-sized atomic operations
Really?
yes, really
keep an "even" and an "odd" copy of your data structure, keep an atomically readable "generation counter" -- on access, read the generation counter, read the data (depending on parity of generation counter), read the generation counter again
if it changed, start over. if it didn't change, you have your data; on modification, update generation counter as appropriate (if you are paranoid about counter overflows, you can repeat a similar trick with the counter itself)
This is single producer / single consumer? (probably works for spmc too). But not multi-producer. Right? Or do misunderstand? Tony