2 * @brief Core model checker.
15 #include "libthreads.h"
18 #include "clockvector.h"
19 #include "hashtable.h"
21 /* 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);
47 * Prints an execution summary with trace information.
48 * @param feasible Formats outputting according to whether or not the
49 * current trace is feasible. Defaults to feasible = true.
51 void print_summary(bool feasible = true);
53 Thread * schedule_next_thread();
55 int add_thread(Thread *t);
56 void remove_thread(Thread *t);
57 Thread * get_thread(thread_id_t tid) { return thread_map->get(id_to_int(tid)); }
59 thread_id_t get_next_id();
60 int get_num_threads();
61 modelclock_t get_next_seq_num();
63 int switch_to_master(ModelAction *act);
64 ClockVector * get_cv(thread_id_t tid);
65 bool next_execution();
67 bool isfinalfeasible();
68 void check_promises(ClockVector *old_cv, ClockVector * merge_cv);
73 modelclock_t used_sequence_numbers;
77 * Stores the ModelAction for the current thread action. Call this
78 * immediately before switching from user- to system-context to pass
80 * @param act The ModelAction created by the user-thread action
82 void set_current_action(ModelAction *act) { current_action = act; }
84 ModelAction * get_last_conflict(ModelAction *act);
85 void set_backtracking(ModelAction *act);
86 thread_id_t get_next_replay_thread();
87 ModelAction * get_next_backtrack();
88 void reset_to_initial_state();
89 void resolve_promises(ModelAction *curr);
90 void compute_promises(ModelAction *curr);
92 void add_action_to_lists(ModelAction *act);
93 ModelAction * get_last_action(thread_id_t tid);
94 ModelAction * get_parent_action(thread_id_t tid);
95 ModelAction * get_last_seq_cst(const void *location);
96 void build_reads_from_past(ModelAction *curr);
97 ModelAction * process_rmw(ModelAction * curr);
98 void post_r_modification_order(ModelAction * curr, const ModelAction *rf);
99 void r_modification_order(ModelAction * curr, const ModelAction *rf);
100 void w_modification_order(ModelAction * curr);
102 ModelAction *current_action;
103 ModelAction *diverge;
104 thread_id_t nextThread;
106 ucontext_t *system_context;
107 action_list_t *action_trace;
108 HashTable<int, Thread *, int> *thread_map;
110 /** Per-object list of actions. Maps an object (i.e., memory location)
111 * to a trace of all actions performed on the object. */
112 HashTable<const void *, action_list_t, uintptr_t, 4> *obj_map;
114 HashTable<void *, std::vector<action_list_t>, uintptr_t, 4 > *obj_thrd_map;
115 std::vector<Promise *> * promises;
116 std::vector<ModelAction *> *thrd_last_action;
117 NodeStack *node_stack;
118 ModelAction *next_backtrack;
119 CycleGraph * cyclegraph;
123 extern ModelChecker *model;
125 #endif /* __MODEL_H__ */