thrd_curr_pred(),
thrd_selected_child_branch(),
thrd_pruned_writes(),
- paused_thread_set(),
+ paused_thread_list(),
paused_thread_table(128)
{}
conditional_sleep(read_thread);
- find_threads(read);
-
return -1;
/*
SnapVector<ModelAction *> * pruned_writes = thrd_pruned_writes[thread_id];
*/
void NewFuzzer::conditional_sleep(Thread * thread)
{
- int index = paused_thread_set.size();
+ int index = paused_thread_list.size();
model->getScheduler()->add_sleep(thread);
- paused_thread_set.push_back(thread);
+ paused_thread_list.push_back(thread);
paused_thread_table.put(thread, index); // Update table
/* Add the waiting condition to ModelHistory */
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()
{
- return paused_thread_set.size() != 0;
+ return paused_thread_list.size() != 0;
}
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;
*/
void NewFuzzer::wake_up_paused_threads(int * threadlist, int * numthreads)
{
- int random_index = random() % paused_thread_set.size();
- Thread * thread = paused_thread_set[random_index];
+ int random_index = random() % paused_thread_list.size();
+ Thread * thread = paused_thread_list[random_index];
model->getScheduler()->remove_sleep(thread);
- Thread * last_thread = paused_thread_set.back();
- paused_thread_set[random_index] = last_thread;
- paused_thread_set.pop_back();
+ Thread * last_thread = paused_thread_list.back();
+ paused_thread_list[random_index] = last_thread;
+ paused_thread_list.pop_back();
paused_thread_table.put(last_thread, random_index); // Update table
paused_thread_table.remove(thread);
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;
int index = paused_thread_table.get(thread);
model->getScheduler()->remove_sleep(thread);
- Thread * last_thread = paused_thread_set.back();
- paused_thread_set[index] = last_thread;
- paused_thread_set.pop_back();
+ Thread * last_thread = paused_thread_list.back();
+ paused_thread_list[index] = last_thread;
+ paused_thread_list.pop_back();
paused_thread_table.put(last_thread, index); // Update table
paused_thread_table.remove(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();
int distance = node->compute_distance(target_node);
if (distance != -1) {
- history->add_waiting_thread(self_id, tid, distance);
+ history->add_waiting_thread(self_id, tid, target_node, distance);
model_print("thread: %d; distance from node %d to node %d: %d\n", tid, node->get_func_id(), target_node->get_func_id(), distance);
}