[ntp:hackers] [Gpsd-dev] Single-writer/many-reader consistency

Eric Raymond esr at thyrsus.com
Sat Mar 26 14:09:31 UTC 2011


tz <thomas at mich.com>:
> On Sat, Mar 26, 2011 at 1:34 AM, Eric Raymond <esr at snark.thyrsus.com> wrote:
> 
> > Only one process (the single writer) would ever change the semaphore
> > state; the readers would just block or spin until it goes to zero.  In
> > GPSD writes are infrequent, now normally 1 per second and highly
> > unlikely to exceed 100 per second even with survey-grade GPSes we
> > don't support yet.  Writes are also small, less than 8K.
> 
> If the readers don''t block on the semaphore, there is no guarantee
> that mid-read the writer will reaquire the semaphore and alter things
> - defeating the purpose.
> 
> However for multiple readers, a simple CRC might work as the validity
> mechanism.  The writer would just alter whatever, whenever it wants
> but at the end fix a CRC (make everything 32 bit - I think CRCs won't
> have collisions, maybe there is a better simple hash algorithm).  The
> readers read the whole block and check the CRC.

It will be a matter for empirical test, then, whether the CRC or reader
semaphore raising performs better.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>


More information about the hackers mailing list