RFR: 8291714: Implement a Multi-Reader Single-Writer mutex for Hotspot

Kim Barrett kbarrett at openjdk.org
Thu Aug 18 15:00:17 UTC 2022


On Wed, 17 Aug 2022 13:02:47 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > HotSpot Mutex has a rank,
> 
> True, but I would put the read/write lock in the same basket as Semaphore, being completely independent of Mutex/Monitor. The onus is on the user to use them with care. A shared ranking mechanism would be tricky I think, and read locks don't fit well with ranking schemes.

I would not put them in the same basket as semaphore. Semaphores are a
signaling mechanism, with no concept of scope or (shared) ownership (though
semaphores sometimes get conscripted into the implementation of such
mechanisms).

I don't see any interesting difference between an unshared locking of a
shared_mutex and locking an ordinary mutex.  If ranks (or anything of a
similar nature) make sense for the latter, then they make sense for the former
and ought to be the same mechanism.

I agree that read locks with ranking could have problems. Though I wonder if
"use with care" might solve most of those problems.

-------------

PR: https://git.openjdk.org/jdk/pull/9838


More information about the hotspot-runtime-dev mailing list