RFR (S) 8130039: Move the platform-specific [OS]Semaphore code

David Holmes david.holmes at oracle.com
Wed Jan 10 22:05:48 UTC 2018


<trimming>

On 10/01/2018 10:51 PM, coleen.phillimore at oracle.com wrote:
> On 1/10/18 12:11 AM, David Holmes wrote:
>> Well this is quite a mess :( The Solaris unpackTime code is 
>> technically incorrect if Solaris is using posix semaphores because it 
>> reads the time from gettimeofday, but the manpage for sem_timedwait 
>> clearly states the timespec should be from CLOCK_REALTIME. So in 
>> actuality what we currently have in the Linux code is what the shared 
>> POSIX code should look like and what Solaris should actually use.
>>
>> Further, the non-OSX BSD code purports to use PosixSemaphore but it 
>> defines:
>>
>> struct timespec PosixSemaphore::create_timespec(unsigned int sec, int 
>> nsec) {
>>   struct timespec ts;
>>   unpackTime(&ts, false, (sec * NANOSECS_PER_SEC) + nsec);
>>
>>   return ts;
>> }
>>
>> but there is no unpackTime method on BSD!
> 
> Right, there is no unpackTime on BSD so I removed this for BSD !APPLE 
> semaphores, since nothing that we have compiles this, and anything that 
> needs it has more work to do.

Plain BSD should use the shared Posix implementation - including the 
timespec logic once it is put into shared code.

> Yes, please file an RFE.  I might get to it but there was a complication 
> for posix because it also needs to get this clock_gettime function: 
> os::Linux::clock_gettime(CLOCK_REALTIME, &ts);  We're never done, but 
> hopefully my change is a start.

https://bugs.openjdk.java.net/browse/JDK-8194860

We already handle clock_gettime in os_posix.cpp - just need to expose it 
to the semaphore class. Or maybe for JDK 11 we can finally do away with 
the dynamic lookup?

Cheers,
David

> Thanks,
> Coleen
>>
>> I think we need a separate RFE to clean up this mess. I'll file one.
>>
>> Thanks,
>> David
>>
>>> thanks,
>>> Coleen
>>>>> ---
>>>>>
>>>>> semaphore_posix.cpp
>>>>>
>>>>>   26 #ifndef __APPLE__
>>>>>   27 #include "runtime/os.hpp"
>>>>>   28 // POSIX unamed semaphores are not supported on OS X.
>>>>>   29 #include "semaphore_posix.hpp"
>>>>>   30 #include <semaphore.h>
>>>>>   31 #endif
>>>>>   32
>>>>>   33
>>>>>   34 // POSIX unamed semaphores are not supported on OS X.
>>>>>   35 #ifndef __APPLE__
>>>>>
>>>>> The whole file contents should be ifndef __APPLE__ so this just 
>>>>> reduces to:
>>>>>
>>>>>   // POSIX unamed semaphores are not supported on OS X.
>>>>>   #ifndef __APPLE__
>>>>>   #include "runtime/os.hpp"
>>>>>   #include "semaphore_posix.hpp"
>>>>>   #include <semaphore.h>
>>>>>   ...
>>>>>
>>>>
>>>> Ok.  I'll fix that.
>>>>
>>>> Thanks,
>>>> Coleen
>>>>> ---
>>>>>
>>>>> Thanks,
>>>>> David
>>>>>
>>>>>> Thanks,
>>>>>> Coleen
>>>>
>>>
> 


More information about the hotspot-runtime-dev mailing list