2 * @brief Stack of operations for use in backtracking.
5 #ifndef __NODESTACK_H__
6 #define __NODESTACK_H__
16 typedef std::list< const ModelAction *, MyAlloc< const ModelAction * > > readfrom_set_t;
19 * @brief A single node in a NodeStack
21 * Represents a single node in the NodeStack. Each Node is associated with up
22 * to one action and up to one parent node. A node holds information
23 * regarding the last action performed (the "associated action"), the thread
24 * choices that have been explored (explored_children) and should be explored
25 * (backtrack), and the actions that the last action may read from.
29 Node(ModelAction *act = NULL, Node *par = NULL, int nthreads = 1);
31 /* return true = thread choice has already been explored */
32 bool has_been_explored(thread_id_t tid);
33 /* return true = backtrack set is empty */
34 bool backtrack_empty();
35 void explore_child(ModelAction *act);
36 /* return false = thread was already in backtrack */
37 bool set_backtrack(thread_id_t id);
38 thread_id_t get_next_backtrack();
39 bool is_enabled(Thread *t);
40 ModelAction * get_action() { return action; }
42 /** @return the parent Node to this Node; that is, the action that
43 * occurred previously in the stack. */
44 Node * get_parent() const { return parent; }
46 void add_read_from(const ModelAction *act);
52 void explore(thread_id_t tid);
57 std::vector< bool, MyAlloc<bool> > explored_children;
58 std::vector< bool, MyAlloc<bool> > backtrack;
61 /** The set of ModelActions that this the action at this Node may read
62 * from. Only meaningful if this Node represents a 'read' action. */
63 readfrom_set_t may_read_from;
66 typedef std::list< Node *, MyAlloc< Node * > > node_list_t;
69 * @brief A stack of nodes
71 * Holds a Node linked-list that can be used for holding backtracking,
72 * may-read-from, and replay information. It is used primarily as a
73 * stack-like structure, in that backtracking points and replay nodes are
74 * only removed from the top (most recent).
80 ModelAction * explore_action(ModelAction *act);
83 void reset_execution();
85 int get_total_nodes() { return total_nodes; }
91 node_list_t node_list;
92 node_list_t::iterator iter;
97 #endif /* __NODESTACK_H__ */