hotspot/src/os/linux/vm/os_linux.cpp
// returns true on success and false on error - really an error is fatal
// but this seems the normal response to library errors
static bool do_suspend(OSThread* osthread) {
{- -------------------------------------------
(1) os::Linux::SuspendResume::set_suspend_action() を呼んで
処理対象の OSThread の sr フィールドに SR_SUSPEND をセットした後,
そのスレッドに対して pthread_kill() で SR_signum を送信する.
---------------------------------------- -}
// mark as suspended and send signal
osthread->sr.set_suspend_action(SR_SUSPEND);
int status = pthread_kill(osthread->pthread_id(), SR_signum);
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert_status(status == 0, status, "pthread_kill");
{- -------------------------------------------
(1) 処理対象のスレッドが sissuspend() で眠りにつくまでここで少し待機 (See: SR_handler()).
眠りについたのを確認したら, os::Linux::SuspendResume::set_suspend_action() を呼んで
処理対象の OSThread の sr フィールドを SR_NONE に戻した後, リターン.
---------------------------------------- -}
// check status and wait until notified of suspension
if (status == 0) {
for (int i = 0; !osthread->sr.is_suspended(); i++) {
os::yield_all(i);
}
osthread->sr.set_suspend_action(SR_NONE);
return true;
}
else {
osthread->sr.set_suspend_action(SR_NONE);
return false;
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.