From: weiyu Date: Mon, 7 Oct 2019 18:55:22 +0000 (-0700) Subject: Fix methods X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=265c4e05ee590cfb3ac975d1871929a8c543f033;p=c11tester.git Fix methods --- diff --git a/history.cc b/history.cc index 93abfbc0..3f098a60 100644 --- a/history.cc +++ b/history.cc @@ -389,17 +389,21 @@ void ModelHistory::add_waiting_thread(thread_id_t self_id, other_wait_obj->add_waited_by(self_id); } -void ModelHistory::remove_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id) +void ModelHistory::remove_waiting_thread(thread_id_t tid) { - WaitObj * self_wait_obj = getWaitObj(self_id); - self_wait_obj->remove_waiting_for(waiting_for_id); + WaitObj * self_wait_obj = getWaitObj(tid); + thrd_id_set_t * waiting_for = self_wait_obj->getWaitingFor(); + + thrd_id_set_iter * iter = waiting_for->iterator(); + while (iter->hasNext()) { + thread_id_t other_id = iter->next(); + WaitObj * other_wait_obj = getWaitObj(other_id); + other_wait_obj->remove_waited_by(tid); + } - /* Update waited-by relation */ - WaitObj * other_wait_obj = getWaitObj(waiting_for_id); - other_wait_obj->remove_waited_by(self_id); + waiting_for->reset(); } - SnapVector * ModelHistory::getThrdInstActMap(uint32_t func_id) { ASSERT(func_id != 0); diff --git a/history.h b/history.h index 80307769..a7185106 100644 --- a/history.h +++ b/history.h @@ -41,7 +41,7 @@ public: WaitObj * getWaitObj(thread_id_t tid); void add_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id, int dist); - void remove_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id); + void remove_waiting_thread(thread_id_t tid); SnapVector * getThrdInstActMap(uint32_t func_id); diff --git a/newfuzzer.cc b/newfuzzer.cc index 69f1ce14..b5f1cd8e 100644 --- a/newfuzzer.cc +++ b/newfuzzer.cc @@ -65,8 +65,6 @@ int NewFuzzer::selectWrite(ModelAction *read, SnapVector * rf_set conditional_sleep(read_thread); - find_threads(read); - return -1; /* SnapVector * pruned_writes = thrd_pruned_writes[thread_id]; @@ -229,6 +227,9 @@ void NewFuzzer::conditional_sleep(Thread * thread) concrete->set_location(read->get_location()); history->add_waiting_write(concrete); + + /* history->add_waiting_thread is called in find_threads */ + find_threads(read); } bool NewFuzzer::has_paused_threads() @@ -240,7 +241,7 @@ Thread * NewFuzzer::selectThread(int * threadlist, int numthreads) { if (numthreads == 0 && has_paused_threads()) { wake_up_paused_threads(threadlist, &numthreads); - model_print("list size: %d, active t id: %d\n", numthreads, threadlist[0]); + //model_print("list size: %d, active t id: %d\n", numthreads, threadlist[0]); } int random_index = random() % numthreads; @@ -266,6 +267,7 @@ void NewFuzzer::wake_up_paused_threads(int * threadlist, int * numthreads) thread_id_t tid = thread->get_id(); history->remove_waiting_write(tid); + history->remove_waiting_thread(tid); model_print("thread %d is woken up\n", tid); threadlist[*numthreads] = tid; @@ -288,11 +290,14 @@ void NewFuzzer::notify_paused_thread(Thread * thread) thread_id_t tid = thread->get_id(); history->remove_waiting_write(tid); + history->remove_waiting_thread(tid); } /* Find threads that may write values that the pending read action is waiting for */ void NewFuzzer::find_threads(ModelAction * pending_read) { + ASSERT(pending_read->is_read()); + void * location = pending_read->get_location(); thread_id_t self_id = pending_read->get_tid();