2 * @brief Core model checker.
16 #include "libthreads.h"
17 #include "libatomic.h"
20 #include "clockvector.h"
22 /* Forward declaration */
26 /** @brief The central structure for model-checking */
32 /** The scheduler to use: tracks the running/ready Threads */
35 /** Stores the context for the main model-checking system thread (call
37 * @param ctxt The system context structure
39 void set_system_context(ucontext_t *ctxt) { system_context = ctxt; }
41 /** @returns the context for the main model-checking system thread */
42 ucontext_t * get_system_context(void) { return system_context; }
44 void check_current_action(void);
45 void print_summary(void);
46 Thread * schedule_next_thread();
48 int add_thread(Thread *t);
49 void remove_thread(Thread *t);
50 Thread * get_thread(thread_id_t tid) { return (*thread_map)[id_to_int(tid)]; }
52 thread_id_t get_next_id();
53 int get_num_threads();
54 modelclock_t get_next_seq_num();
56 int switch_to_master(ModelAction *act);
57 ClockVector * get_cv(thread_id_t tid);
58 bool next_execution();
64 modelclock_t used_sequence_numbers;
68 * Stores the ModelAction for the current thread action. Call this
69 * immediately before switching from user- to system-context to pass
71 * @param act The ModelAction created by the user-thread action
73 void set_current_action(ModelAction *act) { current_action = act; }
75 ModelAction * get_last_conflict(ModelAction *act);
76 void set_backtracking(ModelAction *act);
77 thread_id_t get_next_replay_thread();
78 ModelAction * get_next_backtrack();
79 void reset_to_initial_state();
81 void add_action_to_lists(ModelAction *act);
82 ModelAction * get_last_action(thread_id_t tid);
83 ModelAction * get_parent_action(thread_id_t tid);
84 ModelAction * get_last_seq_cst(const void *location);
85 void build_reads_from_past(ModelAction *curr);
86 void process_rmw(ModelAction * curr);
87 void r_modification_order(ModelAction * curr, const ModelAction *rf);
88 void w_modification_order(ModelAction * curr);
91 ModelAction *current_action;
93 thread_id_t nextThread;
95 ucontext_t *system_context;
96 action_list_t *action_trace;
97 std::map<int, Thread *> *thread_map;
99 /** Per-object list of actions. Maps an object (i.e., memory location)
100 * to a trace of all actions performed on the object. */
101 std::map<const void *, action_list_t> *obj_map;
103 std::map<void *, std::vector<action_list_t> > *obj_thrd_map;
104 std::vector<ModelAction *> *thrd_last_action;
105 NodeStack *node_stack;
106 ModelAction *next_backtrack;
107 CycleGraph * cyclegraph;
110 extern ModelChecker *model;
112 #endif /* __MODEL_H__ */