hotspot/src/share/vm/runtime/os.cpp
// This method is called from signal handler when SIGSEGV occurs while the current
// thread tries to store to the "read-only" memory serialize page during state
// transition.
void os::block_on_serialize_page_trap() {
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
if (TraceSafepoint) {
tty->print_cr("Block until the serialize page permission restored");
}
{- -------------------------------------------
(1) SerializePageLock のロックを取れるまで待機し, 取れたらすぐに開放して終了する.
(これは, os::serialize_thread_states() との間で同期を取るための処理.
See: os::serialize_thread_states())
(なおコメントによると,
一般的にはシグナルハンドラの中でロックを取るのは危険だけど,
この場合のシグナルは同期的(SIGSEGV)だし, どこで発生するかも正確に分かっているので問題ない,
とのこと)
---------------------------------------- -}
// When VMThread is holding the SerializePageLock during modifying the
// access permission of the memory serialize page, the following call
// will block until the permission of that page is restored to rw.
// Generally, it is unsafe to manipulate locks in signal handlers, but in
// this case, it's OK as the signal is synchronous and we know precisely when
// it can occur.
Thread::muxAcquire(&SerializePageLock, "set_memory_serialize_page");
Thread::muxRelease(&SerializePageLock);
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.