LWN.net Logo

Fast reader/writer locks

Fast reader/writer locks

Posted Jan 30, 2003 13:43 UTC (Thu) by bastiaan (guest, #5170)
In reply to: Fast reader/writer locks by cpeterso
Parent article: Fast reader/writer locks

I guess what Rick means is that if you use one sequence the reader will know a concurrent write is in progress if the sequence is odd, in which case it can retry without first copying the data. In code:

do {
   while((seq = fr_read_seq(&some_lock)) & 1);
   /* copy data */
} while (seq != fr_read_seq(&some_lock));

However, since the concurrent write is very unlikely to happen, this extra test may be not worthwhile. But I still don't see why Stephen uses two sequences instead of one.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds