RFR: 8372247: OSX: Semaphore.trywait requires os::Bsd::clock_init [v3]

Kim Barrett kbarrett at openjdk.org
Wed Jan 14 07:44:42 UTC 2026


On Mon, 12 Jan 2026 13:12:30 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> The OSX implementation of the Semaphore requires `os::javaTimeNanos` which requires that we have initiated the clocks via `os::Bsd::clock_init()`. Or we will get an integer division by zero when performing a trywait.
>> 
>> I propose that we let this test setup `os::Bsd::clock_init()` rather than being forced to run in VM.
>> 
>> An alternative would be to simply run this test in VM. Making the dependency more clear. Or only use VM for `__APPLE__`.
>
> Axel Boldt-Christmas has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
> 
>  - Merge branch 'JDK-8372241' into JDK-8372247
>  - Merge branch 'JDK-8372241' into JDK-8372247
>  - OSX: Semaphore.trywait requires os::Bsd::clock_init

I think a better solution would be to change `OSXSemaphore::trywait()` to not
call `timedwait`, with the associated `os::javaTimeNanos` calls. Instead, call
`semaphore_timedwait` directly, with a zero waitspec. `trywait` is supposed to
be fairly lowlevel and "fast", and having it do clock accesses seems wrong.

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

Changes requested by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28417#pullrequestreview-3659315057


More information about the hotspot-runtime-dev mailing list