You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In multiple places in the code, we switch based on the empty queue behavior and do different logic for each.
Most prominantly, when FiberStart function fails to find a task or fiber to run, it will either loop, yield, or sleep. If behavior is set to Sleep, in AddTask(s) and when waiting tasks are ready, we then notify sleeping threads to wake.
const EmptyQueueBehavior behavior = m_emptyQueueBehavior.load(std::memory_order_relaxed);
if (behavior == EmptyQueueBehavior::Sleep) {
// Find a thread that is sleeping and wake itfor (size_t i = 0; i < m_numThreads; ++i) {
std::unique_lock<std::mutex> lock(m_tls[i].FailedQueuePopLock);
if (m_tls[i].FailedQueuePopAttempts >= kFailedPopAttemptsHeuristic) {
m_tls[i].FailedQueuePopAttempts = 0;
m_tls[i].FailedQueuePopCV.notify_one();
break;
}
}
}
However, if the user changes the behavior mid run, we can end up with a thread permanently sleeping:
Worker thread A goes to sleep since there are no tasks
User changes behavior from Sleep to Yield
User code calls AddTasks()
AddTasks() doesn't wake thread A because behavior is set to Yield now.
The text was updated successfully, but these errors were encountered:
In multiple places in the code, we switch based on the empty queue behavior and do different logic for each.
Most prominantly, when FiberStart function fails to find a task or fiber to run, it will either loop, yield, or sleep. If behavior is set to Sleep, in AddTask(s) and when waiting tasks are ready, we then notify sleeping threads to wake.
However, if the user changes the behavior mid run, we can end up with a thread permanently sleeping:
The text was updated successfully, but these errors were encountered: