From dfb78c531b902363430c790be9276c9bf929b447 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 23 Apr 2021 07:43:29 -0500 Subject: [PATCH] Update: signal wait after each time the state becomes "idle". This should give processes waiting more opportunities to wake up. --- level_3/controller/c/private-rule.c | 12 ++++++++++++ level_3/controller/c/private-thread.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 4f03c60..7f81f50 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -2471,6 +2471,10 @@ extern "C" { // the thread is done, so close the thread. if (process->state == controller_process_state_done) { controller_thread_join(&process->id_thread); + + f_thread_mutex_lock(&process->wait_lock); + f_thread_condition_signal_all(&process->wait); + f_thread_mutex_unlock(&process->wait_lock); } process->id = at; @@ -2592,6 +2596,10 @@ extern "C" { process->state = controller_process_state_idle; } + f_thread_mutex_lock(&process->wait_lock); + f_thread_condition_signal_all(&process->wait); + f_thread_mutex_unlock(&process->wait_lock); + f_thread_unlock(&process->lock); } @@ -5555,6 +5563,10 @@ extern "C" { process->state = controller_process_state_idle; f_thread_unlock(&process->active); + + f_thread_mutex_lock(&process->wait_lock); + f_thread_condition_signal_all(&process->wait); + f_thread_mutex_unlock(&process->wait_lock); } if (caller) { diff --git a/level_3/controller/c/private-thread.c b/level_3/controller/c/private-thread.c index cd1f373..6ebf7f7 100644 --- a/level_3/controller/c/private-thread.c +++ b/level_3/controller/c/private-thread.c @@ -86,6 +86,10 @@ extern "C" { process->state = controller_process_state_idle; process->id_thread = 0; + f_thread_mutex_lock(&process->wait_lock); + f_thread_condition_signal_all(&process->wait); + f_thread_mutex_unlock(&process->wait_lock); + f_thread_unlock(&process->lock); } else { -- 1.8.3.1