[crac] RFR: Wake up all TIMED_WAITING threads after restore [v3]
Anton Kozlov
akozlov at openjdk.org
Fri Jun 23 12:12:31 UTC 2023
On Wed, 21 Jun 2023 09:10:30 GMT, Radim Vansa <rvansa at openjdk.org> wrote:
>> 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.
>
> The thread state check might be more of an optimization, even though unparking a non-parked thread is a noop, it still means some work that's unnecessary.
https://github.com/openjdk/crac/blob/crac/src/hotspot/share/runtime/osThread.hpp#L39:
// The thread states represented by the ThreadState values are platform-specific
// and are likely to be only approximate, because most OSes don't give you access
// to precise thread state information.
// Note: the ThreadState is legacy code and is not correctly implemented.
// Uses of ThreadState need to be replaced by the state in the JavaThread.
Relying on the ThreadState creates a risk of missing unparking, which does not pay off, since the operation is perfromed once on the restore. It's possible that ThreadState will become more broken over time as the rest of Hotspot implementation evolve.
-------------
PR Review Comment: https://git.openjdk.org/crac/pull/85#discussion_r1239740373
More information about the crac-dev
mailing list