3 ms·
I think part of the reason is that there's a very similar code pattern which is user error, and avoiding that pattern tends to avoid this pattern as well. The
by Diggsey 3y ago
I think part of the reason is that there's a very similar code pattern which is user error, and avoiding that pattern tends to avoid this pattern as well.
The similar case occurs when you have:
- 1+ threads holding a shared lock (Readers)
- 1+ threads waiting to acquire an exclusive lock (Pending Writers)
- 1+ threads trying to acquire the shared lock (Pending Readers)
- 1+ Reader is waiting on a Pending Reader
In this case the Pending Readers will be unable to acquire the shared lock even though it is still in "read mode" because in a fair RW lock Pending Writers are prioritised above Pending Readers so as not to starve the writer side of the lock.