2 * @brief Core model checker.
17 #include "libthreads.h"
18 #include "libatomic.h"
22 /* Forward declaration */
25 /** @brief The central structure for model-checking */
31 /** The scheduler to use: tracks the running/ready Threads */
32 class Scheduler *scheduler;
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; }
44 * Stores the ModelAction for the current thread action. Call this
45 * immediately before switching from user- to system-context to pass
47 * @param act The ModelAction created by the user-thread action
49 void set_current_action(ModelAction *act) { current_action = act; }
50 void check_current_action(void);
51 void print_summary(void);
52 Thread * schedule_next_thread();
54 int add_thread(Thread *t);
55 void remove_thread(Thread *t);
56 Thread * get_thread(thread_id_t tid) { return (*thread_map)[id_to_int(tid)]; }
58 thread_id_t get_next_id();
59 int get_num_threads();
60 int get_next_seq_num();
62 int switch_to_master(ModelAction *act);
64 bool next_execution();
69 int used_sequence_numbers;
72 ModelAction * get_last_conflict(ModelAction *act);
73 void set_backtracking(ModelAction *act);
74 thread_id_t get_next_replay_thread();
75 ModelAction * get_next_backtrack();
76 void reset_to_initial_state();
78 void add_action_to_lists(ModelAction *act);
79 ModelAction * get_last_action(thread_id_t tid);
80 ModelAction * get_parent_action(thread_id_t tid);
82 void print_list(action_list_t *list);
84 ModelAction *current_action;
86 thread_id_t nextThread;
88 ucontext_t *system_context;
89 action_list_t *action_trace;
90 std::map<int, class Thread *> *thread_map;
91 std::map<void *, std::vector<action_list_t> > *obj_thrd_map;
92 std::vector<ModelAction *> *thrd_last_action;
93 class NodeStack *node_stack;
94 ModelAction *next_backtrack;
97 extern ModelChecker *model;
99 #endif /* __MODEL_H__ */