On Wed, 19 Apr 2023 09:51:48 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:

>> src/hotspot/os/posix/os_posix.cpp line 1545:
>> 
>>> 1543: 
>>> 1544: int PlatformEvent::park_nanos(jlong nanos) {
>>> 1545:   assert(0 <= nanos, "nanos are in range");
>> 
>> `nanos` should never be zero else you call the untimed park.
>
> OK, I see how is that guaranteed in the Windows case. In POSIX case, calling 
> `park()` is untimed wait, but `park(0)` is converted to absolute time that is 
> already passed, and so `pthread_cond_timedwait` would return immediately, 
> right? So `park(0)` is not equivalent to just `park()`? Still, the strongest 
> behavior from Windows case takes precedence here. Changed the assert.

Posix is missing the assertion that Windows has, but if you check the callers 
you will find we never pass 0. The typical pattern is:

        if (millis <= 0) {
          self->_ParkEvent->park();
        } else {
          self->_ParkEvent->park(millis);
        }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13225#discussion_r1171323075

Reply via email to