9 #include "libthreads.h"
10 #include "libatomic.h"
16 typedef enum action_type {
24 typedef std::list<class ModelAction *> action_list_t;
28 ModelAction(action_type_t type, memory_order order, void *loc, int value);
31 thread_id_t get_tid() { return tid; }
32 action_type get_type() { return type; }
33 memory_order get_mo() { return order; }
34 void * get_location() { return location; }
36 TreeNode * get_node() { return node; }
37 void set_node(TreeNode *n) { node = n; }
49 Backtrack(ModelAction *d, action_list_t *t) {
52 iter = actionTrace->begin();
54 ModelAction * get_diverge() { return diverge; }
55 action_list_t * get_trace() { return actionTrace; }
56 void advance_state() { iter++; }
57 ModelAction * get_state() {
58 return iter == actionTrace->end() ? NULL : *iter;
62 action_list_t *actionTrace;
63 /* points to position in actionTrace as we replay */
64 action_list_t::iterator iter;
71 class Scheduler *scheduler;
72 Thread *system_thread;
74 void add_system_thread(Thread *t);
76 void set_current_action(ModelAction *act) { current_action = act; }
77 void check_current_action(void);
78 void print_trace(void);
79 Thread * schedule_next_thread();
81 int add_thread(Thread *t);
82 void remove_thread(Thread *t);
83 Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
87 int switch_to_master(ModelAction *act);
89 bool next_execution();
94 ModelAction * get_last_conflict(ModelAction *act);
95 void set_backtracking(ModelAction *act);
96 thread_id_t advance_backtracking_state();
97 thread_id_t get_next_replay_thread();
98 Backtrack * get_next_backtrack();
99 void reset_to_initial_state();
101 class ModelAction *current_action;
102 Backtrack *exploring;
103 thread_id_t nextThread;
105 action_list_t *action_trace;
106 std::map<thread_id_t, class Thread *> thread_map;
107 class TreeNode *rootNode, *currentNode;
108 std::list<class Backtrack *> backtrack_list;
111 extern ModelChecker *model;
113 int thread_switch_to_master(ModelAction *act);
115 #endif /* __MODEL_H__ */