I'm probably missing something.
I don't understand why in internal_try_acquire_writer() & internal_acquire_writer(), it checks against WRITER | READERS, but not against WRITER_PENDING?
Won't this cause the following CAS operation to replace the value with WRITER, potentially erasing WRITER_PENDING bit?
Assuming the WRITER lock is released before any new WRITER_PENDING get set, any 'reader' could get set before the 'pending writer' (whose bit got erased).
Is sthg else in the code preventing this scenario from happening, or is it an expected / acceptable behavior?
Thanks in advance,