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(const struct model_params *params, ModelAction *act, Node *par,
40 bool is_enabled(Thread *t) const;
41 bool is_enabled(thread_id_t tid) const;
42 enabled_type_t enabled_status(thread_id_t tid) const;
44 ModelAction * get_action() const { return action; }
45 void set_uninit_action(ModelAction *act) { uninit_action = act; }
46 ModelAction * get_uninit_action() const { return uninit_action; }
48 bool has_priority(thread_id_t tid) const;
49 void update_yield(Scheduler *);
50 bool has_priority_over(thread_id_t tid, thread_id_t tid2) const;
51 int get_num_threads() const { return num_threads; }
52 /** @return the parent Node to this Node; that is, the action that
53 * occurred previously in the stack. */
54 Node * get_parent() const { return parent; }
62 const struct model_params * get_params() const { return params; }
63 ModelAction * const action;
64 const struct model_params * const params;
66 /** @brief ATOMIC_UNINIT action which was created at this Node */
67 ModelAction *uninit_action;
69 const int num_threads;
72 typedef ModelVector<Node *> node_list_t;
75 * @brief A stack of nodes
77 * Holds a Node linked-list that can be used for holding backtracking,
78 * may-read-from, and replay information. It is used primarily as a
79 * stack-like structure, in that backtracking points and replay nodes are
80 * only removed from the top (most recent).
87 void register_engine(const ModelExecution *exec);
89 ModelAction * explore_action(ModelAction *act, enabled_type_t * is_enabled);
90 Node * get_head() const;
91 Node * get_next() const;
92 void reset_execution();
94 int get_total_nodes() { return total_nodes; }
100 node_list_t node_list;
102 const struct model_params * get_params() const;
104 /** @brief The model-checker execution object */
105 const ModelExecution *execution;
108 * @brief the index position of the current head Node
110 * This index is relative to node_list. The index should point to the
111 * current head Node. It is negative when the list is empty.
118 #endif /* __NODESTACK_H__ */