From 8b57ab066a2b74a81c4261482ba9030465eb0dbe Mon Sep 17 00:00:00 2001 From: weiyu Date: Mon, 6 Apr 2020 12:49:48 -0700 Subject: [PATCH] Fix waiter list --- execution.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/execution.cc b/execution.cc index d455b516..48c73cfb 100644 --- a/execution.cc +++ b/execution.cc @@ -401,8 +401,17 @@ bool ModelExecution::process_mutex(ModelAction *curr) /* unlock the lock - after checking who was waiting on it */ state->locked = NULL; - /* disable this thread */ - get_safe_ptr_action(&condvar_waiters_map, curr->get_location())->push_back(curr); + /* remove old wait action and disable this thread */ + action_list_t * waiters = get_safe_ptr_action(&condvar_waiters_map, curr->get_location()); + for (sllnode * it = waiters->begin(); it != NULL; it = it->getNext()) { + ModelAction * wait = it->getVal(); + if (wait->get_tid() == curr->get_tid()) { + waiters->erase(it); + break; + } + } + + waiters->push_back(curr); scheduler->sleep(get_thread(curr)); } -- 2.34.1