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<inst_act_map_t *> * ModelHistory::getThrdInstActMap(uint32_t func_id)
{
ASSERT(func_id != 0);
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<inst_act_map_t *> * getThrdInstActMap(uint32_t func_id);
conditional_sleep(read_thread);
- find_threads(read);
-
return -1;
/*
SnapVector<ModelAction *> * pruned_writes = thrd_pruned_writes[thread_id];
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()
{
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;
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;
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();