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

David Holmes dholmes at openjdk.org
Wed Aug 17 13:05:31 UTC 2022


On Tue, 16 Aug 2022 19:51:04 GMT, Kim Barrett <kbarrett 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.

> src/hotspot/share/runtime/mrswMutex.hpp line 63:
> 
>> 61:     Locker(T* lock)
>> 62:       : _lock(lock) {
>> 63:       if (_lock != nullptr) {
> 
> When would it ever make sense for the `lock` argument to be nullptr?  Instead assert in the constructor that it is not?

It would make sense in the same circumstances the MutexLocker also takes a NULL argument.

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

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


More information about the hotspot-runtime-dev mailing list