7 #include "threads-model.h"
9 #define INIT_SEQ_NUMBER 0xffffffff
16 void enter_function(const uint32_t func_id, thread_id_t tid);
17 void exit_function(const uint32_t func_id, thread_id_t tid);
19 uint32_t get_func_counter() { return func_counter; }
20 void incr_func_counter() { func_counter++; }
22 void resize_func_nodes(uint32_t max_func_id);
23 void process_action(ModelAction *act, thread_id_t tid);
25 HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncMap() { return &func_map; }
26 ModelVector<const char *> * getFuncMapRev() { return &func_map_rev; }
28 ModelVector<FuncNode *> * getFuncNodes() { return &func_nodes; }
29 FuncNode * get_func_node(uint32_t func_id);
30 FuncNode * get_curr_func_node(thread_id_t tid);
32 void update_write_history(void * location, uint64_t write_val);
33 HashTable<void *, value_set_t *, uintptr_t, 0> * getWriteHistory() { return write_history; }
34 void update_loc_rd_func_nodes_map(void * location, FuncNode * node);
35 void update_loc_wr_func_nodes_map(void * location, FuncNode * node);
36 SnapVector<FuncNode *> * getRdFuncNodes(void * location);
37 SnapVector<FuncNode *> * getWrFuncNodes(void * location);
39 void add_waiting_write(ConcretePredicate * concrete);
40 void remove_waiting_write(thread_id_t tid);
41 void check_waiting_write(ModelAction * write_act);
42 SnapVector<ConcretePredicate *> * getThrdWaitingWrite() { return thrd_waiting_write; }
44 WaitObj * getWaitObj(thread_id_t tid);
45 void add_waiting_thread(thread_id_t self_id, thread_id_t waiting_for_id, FuncNode * target_node, int dist);
46 void remove_waiting_thread(thread_id_t tid);
47 void stop_waiting_for_node(thread_id_t self_id, thread_id_t waiting_for_id, FuncNode * target_node);
49 void set_new_exec_flag();
50 void dump_func_node_graph();
51 void print_func_node();
52 void print_waiting_threads();
56 uint32_t func_counter;
57 modelclock_t last_seq_number;
59 /* Map function names to integer ids */
60 HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
62 /* Map integer ids to function names */
63 ModelVector<const char *> func_map_rev;
65 ModelVector<FuncNode *> func_nodes;
67 /* Map a location to a set of values that have been written to it */
68 HashTable<void *, value_set_t *, uintptr_t, 0> * write_history;
70 /* Map a location to FuncNodes that may read from it */
71 HashTable<void *, SnapVector<FuncNode *> *, uintptr_t, 0> * loc_rd_func_nodes_map;
73 /* Map a location to FuncNodes that may write to it */
74 HashTable<void *, SnapVector<FuncNode *> *, uintptr_t, 0> * loc_wr_func_nodes_map;
76 HashTable<void *, SnapVector<ConcretePredicate *> *, uintptr_t, 0> * loc_waiting_writes_map;
78 /* thrd_func_list stores a list of function ids for each thread.
79 * Each element in thrd_func_list stores the functions that
80 * thread i has entered and yet to exit from
82 SnapVector<func_id_list_t> * thrd_func_list;
83 SnapVector<uint32_t> * thrd_last_entered_func;
85 /* The write values each paused thread is waiting for */
86 SnapVector<ConcretePredicate *> * thrd_waiting_write;
87 SnapVector<WaitObj *> * thrd_wait_obj;
89 bool skip_action(ModelAction * act);
90 void monitor_waiting_thread(uint32_t func_id, thread_id_t tid);
91 void monitor_waiting_thread_counter(thread_id_t tid);
95 #endif /* __HISTORY_H__ */