2 * @brief Stack of operations for use in backtracking.
5 #ifndef __NODESTACK_H__
6 #define __NODESTACK_H__
13 #include "stl-model.h"
18 struct fairness_info {
19 unsigned int enabled_count;
26 * @brief A single node in a NodeStack
28 * Represents a single node in the NodeStack. Each Node is associated with up
29 * to one action and up to one parent node. A node holds information
30 * regarding the last action performed (the "associated action"), the thread
31 * choices that have been explored (explored_children) and should be explored
32 * (backtrack), and the actions that the last action may read from.
36 Node(ModelAction *act, Node *par,
40 bool is_enabled(Thread *t) const;
41 bool is_enabled(thread_id_t tid) const;
43 ModelAction * get_action() const { return action; }
44 void set_uninit_action(ModelAction *act) { uninit_action = act; }
45 ModelAction * get_uninit_action() const { return uninit_action; }
47 int get_num_threads() const { return num_threads; }
48 /** @return the parent Node to this Node; that is, the action that
49 * occurred previously in the stack. */
50 Node * get_parent() const { return parent; }
58 ModelAction * const action;
60 /** @brief ATOMIC_UNINIT action which was created at this Node */
61 ModelAction *uninit_action;
63 const int num_threads;
66 typedef ModelVector<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).
81 void register_engine(const ModelExecution *exec);
83 ModelAction * explore_action(ModelAction *act);
84 Node * get_head() const;
85 Node * get_next() const;
86 void reset_execution();
88 int get_total_nodes() { return total_nodes; }
94 node_list_t node_list;
96 const struct model_params * get_params() const;
98 /** @brief The model-checker execution object */
99 const ModelExecution *execution;
102 * @brief the index position of the current head Node
104 * This index is relative to node_list. The index should point to the
105 * current head Node. It is negative when the list is empty.
112 #endif /* __NODESTACK_H__ */