[crac] RFR: Wake up all TIMED_WAITING threads after restore [v2]
Anton Kozlov
akozlov at openjdk.org
Tue Jun 20 10:09:39 UTC 2023
On Tue, 20 Jun 2023 06:37:33 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
>> src/hotspot/os/linux/os_linux.cpp line 6132:
>>
>>> 6130: t->interrupt();
>>> 6131: t->osthread()->set_interrupted(false);
>>> 6132: }
>>
>> I think the problem of the native implementation of the timed wait is being fixed on the wrong level of abstraction. The interrupt() is much higher leve operation than the pthread_cond_signal, that we are actually targeting. And the latter would be also much cheaper. Could you replace the code with signaling every cond?
>
> We are not triggering the Java InterruptedException; when you look into the implementation of `JavaThread::interrupt` you'll see that unparking from those 3 types of conditions is all it's actually doing, setting and immediately unsetting the interrupted flag is a noop on posix systems.
> So I don't think this can be any cheaper. We are operating on a bit higher level only to reuse code that we would otherwise inline in here.
t->interrupt() triggers unparks of two ParkEvents and of a Parker. They do some bookkeeping in addition to just pthread_cond_timedwait(). But OK, I see we need to actually unpark the thread for park() callers to recalculate the abs time. Anyway, Thread::interrupt looks like a hack. AFAICS unpark()s can be called without Java thread state check, which also will be more straightforward.
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/85#discussion_r1235042673
More information about the crac-dev
mailing list