2 * @brief Models actions taken by threads.
12 #include "libatomic.h"
16 typedef enum action_type {
25 /* Forward declaration */
30 * The ModelAction class encapsulates an atomic action.
34 ModelAction(action_type_t type, memory_order order, void *loc, int value);
36 void print(void) const;
38 thread_id_t get_tid() const { return tid; }
39 action_type get_type() const { return type; }
40 memory_order get_mo() const { return order; }
41 void * get_location() const { return location; }
42 int get_seq_number() const { return seq_number; }
44 Node * get_node() const { return node; }
45 void set_node(Node *n) { node = n; }
48 bool is_write() const;
50 bool is_acquire() const;
51 bool is_release() const;
52 bool is_seqcst() const;
53 bool same_var(const ModelAction *act) const;
54 bool same_thread(const ModelAction *act) const;
55 bool is_synchronizing(const ModelAction *act) const;
57 void create_cv(ModelAction *parent = NULL);
58 ClockVector * get_cv() const { return cv; }
59 void read_from(ModelAction *act);
61 bool happens_before(ModelAction *act);
63 inline bool operator <(const ModelAction& act) const {
64 return get_seq_number() < act.get_seq_number();
66 inline bool operator >(const ModelAction& act) const {
67 return get_seq_number() > act.get_seq_number();
73 /** Type of action (read, write, thread create, thread yield, thread join) */
76 /** The memory order for this operation. */
79 /** A pointer to the memory location for this action. */
82 /** The thread id that performed this action. */
85 /** The value read or written (if RMW, then the value written). This
86 * should probably be something longer. */
89 /** A back reference to a Node in NodeStack, if this ModelAction is
90 * saved on the NodeStack. */
95 /** The clock vector stored with this action; only needed if this
96 * action is a store release? */
100 typedef std::list<class ModelAction *> action_list_t;
102 #endif /* __ACTION_H__ */