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; }
42 bool same_var(ModelAction *act);
43 bool same_thread(ModelAction *act);
44 bool is_dependent(ModelAction *act);
56 Backtrack(ModelAction *d, action_list_t *t) {
59 iter = actionTrace->begin();
61 ModelAction * get_diverge() { return diverge; }
62 action_list_t * get_trace() { return actionTrace; }
63 void advance_state() { iter++; }
64 ModelAction * get_state() {
65 return iter == actionTrace->end() ? NULL : *iter;
69 action_list_t *actionTrace;
70 /* points to position in actionTrace as we replay */
71 action_list_t::iterator iter;
78 class Scheduler *scheduler;
80 void set_system_context(ucontext_t *ctxt) { system_context = ctxt; }
81 ucontext_t * get_system_context(void) { return system_context; }
83 void set_current_action(ModelAction *act) { current_action = act; }
84 void check_current_action(void);
85 void print_summary(void);
86 Thread * schedule_next_thread();
88 int add_thread(Thread *t);
89 void remove_thread(Thread *t);
90 Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
94 int switch_to_master(ModelAction *act);
96 bool next_execution();
101 ModelAction * get_last_conflict(ModelAction *act);
102 void set_backtracking(ModelAction *act);
103 thread_id_t advance_backtracking_state();
104 thread_id_t get_next_replay_thread();
105 Backtrack * get_next_backtrack();
106 void reset_to_initial_state();
108 class ModelAction *current_action;
109 Backtrack *exploring;
110 thread_id_t nextThread;
112 ucontext_t *system_context;
113 action_list_t *action_trace;
114 std::map<thread_id_t, class Thread *> thread_map;
115 class TreeNode *rootNode, *currentNode;
116 std::list<class Backtrack *> backtrack_list;
119 extern ModelChecker *model;
121 #endif /* __MODEL_H__ */