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 Thread *get_thread(thread_id_t tid) { return thread_map[tid]; }
84 void assign_id(Thread *t);
86 int switch_to_master(ModelAction *act);
90 ModelAction *get_last_conflict(ModelAction *act);
91 void set_backtracking(ModelAction *act);
92 thread_id_t advance_backtracking_state();
93 thread_id_t get_next_replay_thread();
95 class ModelAction *current_action;
97 thread_id_t nextThread;
99 action_list_t *action_trace;
100 std::map<thread_id_t, class Thread *> thread_map;
101 class TreeNode *rootNode, *currentNode;
102 std::list<class Backtrack *> backtrack_list;
105 extern ModelChecker *model;
107 int thread_switch_to_master(ModelAction *act);
109 #endif /* __MODEL_H__ */