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