For the POSIX platforms (Linux, BSD, Solaris) we have per-platform functions to create the timespec for the timeout of timed-wait:
- Linux has the correct implementation for POSIX, using clock_gettime(CLOCK_REALTIME) and enforcing a time overflow check as described in os_posix.cpp
- Solaris has a similar implementation to Linux but incorrectly uses gettimeofday instead of clock_gettime(CLOCK_REALTIME) as actually required by the sem_timedwait function!
- BSD calls a non-existent unpackTime method! (this is dead code in OpenJDK at present as the BSD port is being maintained in a separate project not mainline due to lack of support).
We should have a single POSIX compliant mechanism to define the timespec to be used for all the platforms.
Given we already have code to dynamically check for the availability of clock_gettime in os_posix.cpp we should be able to leverage that. (Ideally we eventually will assume it always exists and statically bind it). We may have to expose the os::Posix API's to PosixSemaphore.
- relates to
-
JDK-8130039 Move the platform-specific [OS]Semaphore code
- Resolved