[ntp:hackers] [Gpsd-dev] A lightweight synchronization mechanism for shared memory

Eric Raymond esr at thyrsus.com
Fri Mar 25 04:06:25 UTC 2011


tz <thomas at mich.com>:
> Anyway it won't work if memcpy is interruptable.
> 
> Reader starts the memcpy, copies the start sentinel and half the payload.
> Writer increments the start sentinel. and writes into the payload.
> Reader continues the memcpy where it left off through the end sentinel.
> 
> Both sentinels are equal, yet the bottom part of the payload is invalid.

Hm.  You're right.  The copy has to be uninterruptible.

> The only way I can think of is a single writer sets a bool to safe to
> read - unsafe to write, and a single reader sets it back to safe to
> read - unsafe to write.

Doesn't help the multiple-readers case.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>


More information about the hackers mailing list