nextThread(THREAD_ID_T_NONE),
action_trace(new action_list_t()),
thread_map(new std::map<int, class Thread *>),
+ obj_thrd_map(new std::map<void *, std::vector<action_list_t> >()),
+ thrd_last_action(new std::vector<ModelAction *>(1)),
node_stack(new NodeStack()),
next_backtrack(NULL)
{
delete (*it).second;
delete thread_map;
+ delete obj_thrd_map;
delete action_trace;
-
+ delete thrd_last_action;
delete node_stack;
delete scheduler;
}
return next_thread_id++;
}
+int ModelChecker::get_num_threads()
+{
+ return next_thread_id;
+}
+
int ModelChecker::get_next_seq_num()
{
return ++used_sequence_numbers;
}
curr = node_stack->explore_action(curr);
+ curr->create_cv(get_parent_action(curr->get_tid()));
+
+ /* Assign 'creation' parent */
+ if (curr->get_type() == THREAD_CREATE) {
+ Thread *th = (Thread *)curr->get_location();
+ th->set_creation(curr);
+ }
+
nextThread = get_next_replay_thread();
currnode = curr->get_node();
next_backtrack = curr;
set_backtracking(curr);
- this->action_trace->push_back(curr);
+
+ add_action_to_lists(curr);
+}
+
+void ModelChecker::add_action_to_lists(ModelAction *act)
+{
+ action_trace->push_back(act);
+
+ std::vector<action_list_t> *vec = &(*obj_thrd_map)[act->get_location()];
+ if (id_to_int(act->get_tid()) >= (int)vec->size())
+ vec->resize(next_thread_id);
+ (*vec)[id_to_int(act->get_tid())].push_back(act);
+
+ (*thrd_last_action)[id_to_int(act->get_tid())] = act;
+}
+
+ModelAction * ModelChecker::get_last_action(thread_id_t tid)
+{
+ int nthreads = get_num_threads();
+ if ((int)thrd_last_action->size() < nthreads)
+ thrd_last_action->resize(nthreads);
+ return (*thrd_last_action)[id_to_int(tid)];
+}
+
+ModelAction * ModelChecker::get_parent_action(thread_id_t tid)
+{
+ ModelAction *parent = get_last_action(tid);
+ if (!parent)
+ parent = get_thread(tid)->get_creation();
+ return parent;
}
void ModelChecker::print_summary(void)