Closed turnon closed 3 years ago
The condition @Count == @HeldCount does not correctly indicate that WE ARE THE ONLY READER.
@Count == @HeldCount
Because when we lock for read more than once, @HeldCount increases but @Count dosen't.
@HeldCount
@Count
lock.with_read_lock do lock.with_read_lock do # blocked here, can not acquire write lock ! Even though no else reader lock.with_write_lock {} end end
So we just compare @Count == 1 and try to set RUNNING_WRITER bit on
@Count == 1
Can you please rebase?
Ok, just rebased
The condition
@Count == @HeldCount
does not correctly indicate that WE ARE THE ONLY READER.Because when we lock for read more than once,
@HeldCount
increases but@Count
dosen't.So we just compare
@Count == 1
and try to set RUNNING_WRITER bit on