2 * @brief Core model checker.
16 #include "libthreads.h"
17 #include "libatomic.h"
20 #include "clockvector.h"
22 /* Forward declaration */
25 /** @brief The central structure for model-checking */
31 /** The scheduler to use: tracks the running/ready Threads */
34 /** Stores the context for the main model-checking system thread (call
36 * @param ctxt The system context structure
38 void set_system_context(ucontext_t *ctxt) { system_context = ctxt; }
40 /** @returns the context for the main model-checking system thread */
41 ucontext_t * get_system_context(void) { return system_context; }
43 void check_current_action(void);
44 void print_summary(void);
45 Thread * schedule_next_thread();
47 int add_thread(Thread *t);
48 void remove_thread(Thread *t);
49 Thread * get_thread(thread_id_t tid) { return (*thread_map)[id_to_int(tid)]; }
51 thread_id_t get_next_id();
52 int get_num_threads();
53 modelclock_t get_next_seq_num();
55 int switch_to_master(ModelAction *act);
56 ClockVector * get_cv(thread_id_t tid);
57 bool next_execution();
62 modelclock_t used_sequence_numbers;
66 * Stores the ModelAction for the current thread action. Call this
67 * immediately before switching from user- to system-context to pass
69 * @param act The ModelAction created by the user-thread action
71 void set_current_action(ModelAction *act) { current_action = act; }
73 ModelAction * get_last_conflict(ModelAction *act);
74 void set_backtracking(ModelAction *act);
75 thread_id_t get_next_replay_thread();
76 ModelAction * get_next_backtrack();
77 void reset_to_initial_state();
79 void add_action_to_lists(ModelAction *act);
80 ModelAction * get_last_action(thread_id_t tid);
81 ModelAction * get_parent_action(thread_id_t tid);
82 ModelAction * get_last_seq_cst(const void *location);
83 void build_reads_from_past(ModelAction *curr);
85 ModelAction *current_action;
87 thread_id_t nextThread;
89 ucontext_t *system_context;
90 action_list_t *action_trace;
91 std::map<int, Thread *> *thread_map;
93 /** Per-object list of actions. Maps an object (i.e., memory location)
94 * to a trace of all actions performed on the object. */
95 std::map<const void *, action_list_t> *obj_map;
97 std::map<void *, std::vector<action_list_t> > *obj_thrd_map;
98 std::vector<ModelAction *> *thrd_last_action;
99 NodeStack *node_stack;
100 ModelAction *next_backtrack;
103 extern ModelChecker *model;
105 #endif /* __MODEL_H__ */