On Thu, 7 Mar 2024 00:54:30 GMT, David Holmes <[email protected]> wrote:
>> OK. It's a good thing HotSpot doesn't need to worry about
>> priority-inheritance for mutexes.
>
> Semaphore seems simpler/cleaner and ready to use.
It's such a rare race and unusual condition that we could execute more Java
code, that I started out with just a shared bit. Then David suggested a
semaphore that obeys the safepoint protocol, which seems a lot better. I've
literally skimmed over OSThreadWaitState. It looks like
Semaphore::wait_with_a_safepoint_check() uses it. I still don't know why it
exists:
// Note: the ThreadState is legacy code and is not correctly implemented.
// Uses of ThreadState need to be replaced by the state in the JavaThread.
enum ThreadState {
Does a PlatformMutex handle priority-inheritance? It still feels like it would
be overkill for this usage. I hope this RecursiveLocker does not become more
widely used, where we would have to replace the simple implementation with
something more difficult. We should discourage further use when possible.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17739#discussion_r1515364466