10 #include "libthreads.h"
11 #include "libatomic.h"
17 typedef enum action_type {
25 typedef std::list<class ModelAction *> action_list_t;
29 ModelAction(action_type_t type, memory_order order, void *loc, int value);
32 thread_id_t get_tid() { return tid; }
33 action_type get_type() { return type; }
34 memory_order get_mo() { return order; }
35 void * get_location() { return location; }
37 TreeNode * get_node() { return node; }
38 void set_node(TreeNode *n) { node = n; }
44 bool same_var(ModelAction *act);
45 bool same_thread(ModelAction *act);
46 bool is_dependent(ModelAction *act);
58 Backtrack(ModelAction *d, action_list_t *t) {
61 iter = actionTrace->begin();
63 ModelAction * get_diverge() { return diverge; }
64 action_list_t * get_trace() { return actionTrace; }
65 void advance_state() { iter++; }
66 ModelAction * get_state() {
67 return iter == actionTrace->end() ? NULL : *iter;
71 action_list_t *actionTrace;
72 /* points to position in actionTrace as we replay */
73 action_list_t::iterator iter;
80 class Scheduler *scheduler;
82 void set_system_context(ucontext_t *ctxt) { system_context = ctxt; }
83 ucontext_t * get_system_context(void) { return system_context; }
85 void set_current_action(ModelAction *act) { current_action = act; }
86 void check_current_action(void);
87 void print_summary(void);
88 Thread * schedule_next_thread();
90 int add_thread(Thread *t);
91 void remove_thread(Thread *t);
92 Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
96 int switch_to_master(ModelAction *act);
98 bool next_execution();
103 ModelAction * get_last_conflict(ModelAction *act);
104 void set_backtracking(ModelAction *act);
105 thread_id_t advance_backtracking_state();
106 thread_id_t get_next_replay_thread();
107 Backtrack * get_next_backtrack();
108 void reset_to_initial_state();
110 class ModelAction *current_action;
111 Backtrack *exploring;
112 thread_id_t nextThread;
114 ucontext_t *system_context;
115 action_list_t *action_trace;
116 std::map<thread_id_t, class Thread *> thread_map;
117 class TreeNode *rootNode, *currentNode;
118 std::list<class Backtrack *> backtrack_list;
121 extern ModelChecker *model;
123 #endif /* __MODEL_H__ */