void SuspendibleThreadSet::leave() {
assert(Thread::current()->is_suspendible_thread(), "Thread not joined");
MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag);
assert(_nthreads > 0, "Invalid");
DEBUG_ONLY(Thread::current()->clear_suspendible_thread();)
_nthreads--; if (suspend_all() && is_synchronized()) { // This leave completes a request, so inform the requestor.
_synchronize_wakeup->signal();
}
}
void SuspendibleThreadSet::yield() {
assert(Thread::current()->is_suspendible_thread(), "Must have joined");
MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag); if (suspend_all()) {
_nthreads_stopped++; if (is_synchronized()) { if (ConcGCYieldTimeout > 0) { double now = os::elapsedTime();
guarantee((now - _suspend_all_start) * 1000.0 < (double)ConcGCYieldTimeout, "Long delay");
} // This yield completes the request, so inform the requestor.
_synchronize_wakeup->signal();
} while (suspend_all()) {
ml.wait();
}
assert(_nthreads_stopped > 0, "Invalid");
_nthreads_stopped--;
}
}
void SuspendibleThreadSet::synchronize() {
assert(Thread::current()->is_VM_thread(), "Must be the VM thread"); if (ConcGCYieldTimeout > 0) {
_suspend_all_start = os::elapsedTime();
}
{
MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag);
assert(!suspend_all(), "Only one at a time");
Atomic::store(&_suspend_all, true); if (is_synchronized()) { return;
}
} // Release lock before semaphore wait.
// Semaphore initial count is zero. To reach here, there must be at // least one not yielded thread in the set, e.g. is_synchronized() // was false before the lock was released. A thread in the set will // signal the semaphore iff it is the last to yield or leave while // there is an active suspend request. So there will be exactly one // signal, which will increment the semaphore count to one, which // will then be consumed by this wait, returning it to zero. No // thread can exit yield or enter the set until desynchronize is // called, so there are no further opportunities for the semaphore // being signaled until we get back here again for some later // synchronize call. Hence, there is no need to re-check for // is_synchronized after the wait; it will always be true there.
_synchronize_wakeup->wait();
#ifdef ASSERT
MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag);
assert(suspend_all(), "STS not synchronizing");
assert(is_synchronized(), "STS not synchronized"); #endif
}
void SuspendibleThreadSet::desynchronize() {
assert(Thread::current()->is_VM_thread(), "Must be the VM thread");
MonitorLocker ml(STS_lock, Mutex::_no_safepoint_check_flag);
assert(suspend_all(), "STS not synchronizing");
assert(is_synchronized(), "STS not synchronized");
Atomic::store(&_suspend_all, false);
ml.notify_all();
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.