9 ModelChecker::ModelChecker()
11 /* First thread created (system_thread) will have id 1 */
12 this->used_thread_id = 0;
13 /* Initialize default scheduler */
14 this->scheduler = new Scheduler();
16 this->current_action = NULL;
19 ModelChecker::~ModelChecker()
21 delete this->scheduler;
24 void ModelChecker::assign_id(Thread *t)
26 t->set_id(++used_thread_id);
29 void ModelChecker::add_system_thread(Thread *t)
31 this->system_thread = t;
34 void ModelChecker::check_current_action(void)
36 if (this->current_action)
37 this->action_trace.push_back(this->current_action);
39 DEBUG("trying to push NULL action...\n");
42 void ModelChecker::print_trace(void)
44 std::list<class ModelAction *>::iterator it;
46 for (it = action_trace.begin(); it != action_trace.end(); it++) {
52 int ModelChecker::add_thread(Thread *t)
54 thread_map[t->get_id()] = t;
58 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value)
60 Thread *t = thread_current();
61 ModelAction *act = this;
66 act->tid = t->get_id();
70 void ModelAction::print(void)
75 type_str = "thread create";
78 type_str = "thread yield";
81 type_str = "thread join";
84 type_str = "atomic read";
87 type_str = "atomic write";
90 type_str = "unknown type";
93 printf("Thread: %d\tAction: %s\tMO: %d\tLoc: %#014zx\tValue: %d\n", tid, type_str, order, (size_t)location, value);