#define DBG()
#endif
-void *myMalloc(size_t size);
+void * myMalloc(size_t size);
void myFree(void *ptr);
#endif /* __COMMON_H__ */
}
}
-void *myMalloc(size_t size)
+void * myMalloc(size_t size)
{
if (real_malloc == NULL)
__my_alloc_init();
this->system_thread = t;
}
-Thread *ModelChecker::schedule_next_thread()
+Thread * ModelChecker::schedule_next_thread()
{
Thread *t;
if (nextThread == THREAD_ID_T_NONE)
bool ModelChecker::next_execution()
{
- return false;
+ num_executions++;
+ if ((exploring = model->get_next_backtrack()) == NULL)
+ return false;
+ model->reset_to_initial_state();
+ nextThread = get_next_replay_thread();
+ return true;
}
-ModelAction *ModelChecker::get_last_conflict(ModelAction *act)
+ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
{
void *loc = act->get_location();
action_type type = act->get_type();
thread_id_t get_tid() { return tid; }
action_type get_type() { return type; }
memory_order get_mo() { return order; }
- void *get_location() { return location; }
+ void * get_location() { return location; }
- TreeNode *get_node() { return node; }
+ TreeNode * get_node() { return node; }
void set_node(TreeNode *n) { node = n; }
private:
action_type type;
actionTrace = t;
iter = actionTrace->begin();
}
- ModelAction *get_diverge() { return diverge; }
- action_list_t *get_trace() { return actionTrace; }
+ ModelAction * get_diverge() { return diverge; }
+ action_list_t * get_trace() { return actionTrace; }
void advance_state() { iter++; }
- ModelAction *get_state() {
+ ModelAction * get_state() {
return iter == actionTrace->end() ? NULL : *iter;
}
private:
void set_current_action(ModelAction *act) { current_action = act; }
void check_current_action(void);
void print_trace(void);
- Thread *schedule_next_thread();
+ Thread * schedule_next_thread();
int add_thread(Thread *t);
- Thread *get_thread(thread_id_t tid) { return thread_map[tid]; }
+ Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
void assign_id(Thread *t);
int used_thread_id;
int num_executions;
- ModelAction *get_last_conflict(ModelAction *act);
+ ModelAction * get_last_conflict(ModelAction *act);
void set_backtracking(ModelAction *act);
thread_id_t advance_backtracking_state();
thread_id_t get_next_replay_thread();
readyList.push_back(t);
}
-Thread *Scheduler::next_thread(void)
+Thread * Scheduler::next_thread(void)
{
Thread *t = model->schedule_next_thread();
return t;
}
-Thread *Scheduler::get_current_thread(void)
+Thread * Scheduler::get_current_thread(void)
{
return current;
}
#define STACK_SIZE (1024 * 1024)
-static void *stack_allocate(size_t size)
+static void * stack_allocate(size_t size)
{
return malloc(size);
}
free(stack);
}
-Thread *thread_current(void)
+Thread * thread_current(void)
{
return model->scheduler->get_current_thread();
}
thread_state state;
};
-Thread *thread_current();
+Thread * thread_current();
static inline thread_id_t thrd_to_id(thrd_t t)
{
delete it->second;
}
-TreeNode *TreeNode::exploreChild(tree_t id)
+TreeNode * TreeNode::exploreChild(tree_t id)
{
TreeNode *n;
std::set<tree_t >::iterator it;
return *backtrack.begin();
}
-TreeNode *TreeNode::getRoot()
+TreeNode * TreeNode::getRoot()
{
if (parent)
return parent->getRoot();
TreeNode(TreeNode *par);
~TreeNode();
bool hasBeenExplored(tree_t id) { return children.find(id) != children.end(); }
- TreeNode *exploreChild(tree_t id);
+ TreeNode * exploreChild(tree_t id);
tree_t getNextBacktrack();
/* Return 1 if already in backtrack, 0 otherwise */
int setBacktrack(tree_t id);
- TreeNode *getRoot();
+ TreeNode * getRoot();
static int getTotalNodes() { return TreeNode::totalNodes; }
private:
TreeNode *parent;