Fast reader/writer locks
Posted Feb 2, 2003 8:24 UTC (Sun) by
acristianb (guest, #1702)
Parent article:
Fast reader/writer locks
If the writer starts by increasing the first seq then, the reader reads the first seq, reads data, then the writer changes data and second seq, than the reader reads the last seq, the two sequences match for the reader but the data is invalid.
A small twist of the reader algorithm that will solve this, and would make this frlock suitable for long (or longer) calculations is this:
* reads first seq and second seq
* compares them (if they are not equal start over because a writer is changing data)
* reads data
* reads second seq
* compares first and second sequences (if they are not equal start over)
(
Log in to post comments)