[Bug libstdc++/102962] shared locks / mutexes differ between linux and windows
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 3 16:45:46 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102962
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
FWIW, POSIX says this for its equivalent of lock_shared:
If the Thread Execution Scheduling option is not supported, it is
implementation-defined whether the calling thread acquires the lock when a
writer does not hold the lock and there are writers blocked on the lock.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html
The C++ proposals for shared mutex said:
An implementation is strongly encouraged to block other threads requesting
shared ownership while this thread is blocked waiting for exclusive ownership,
lest the blocked thread be starved by readers.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3568.html
However, that was for the upgrade lock functionality, which never made it into
the standard. The final wording for shared_mutex (and shared_timed_mutex) do
not even have that encouragement.
More information about the Gcc-bugs
mailing list