From e0842c10af50c26e8479335f8bd9375309f3c478 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 17 Dec 2021 11:51:28 -0500 Subject: [PATCH] kernel/condition_variable: Pause between iterations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should hopefully resolve the remaining problem in #17455. Change-Id: I6e00286508c069705e07c9a0b59af2cf5e15e427 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4819 Tested-by: Commit checker robot Reviewed-by: Jérôme Duval --- src/system/kernel/condition_variable.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/condition_variable.cpp b/src/system/kernel/condition_variable.cpp index 7c624ea5f4..968f56d66c 100644 --- a/src/system/kernel/condition_variable.cpp +++ b/src/system/kernel/condition_variable.cpp @@ -157,8 +157,9 @@ ConditionVariableEntry::_RemoveFromVariable() int32 tries = 0; while (atomic_pointer_get(&fVariable) != NULL) { tries++; - if ((tries % 100000) == 0) + if ((tries % 10000) == 0) panic("variable pointer was not unset for a long time!"); + cpu_pause(); } return; @@ -396,6 +397,7 @@ ConditionVariable::_NotifyLocked(bool all, status_t result) tries++; if ((tries % 10000) == 0) panic("entries count was not decremented for a long time!"); + cpu_pause(); } } else { status_t waitStatus = atomic_get_and_set(&entry->fWaitStatus, result);