2 * @brief Models actions taken by threads.
12 #include "libatomic.h"
14 #include "clockvector.h"
18 typedef enum action_type {
27 /* Forward declaration */
32 * The ModelAction class encapsulates an atomic action.
36 ModelAction(action_type_t type, memory_order order, void *loc, int value = VALUE_NONE);
38 void print(void) const;
40 thread_id_t get_tid() const { return tid; }
41 action_type get_type() const { return type; }
42 memory_order get_mo() const { return order; }
43 void * get_location() const { return location; }
44 modelclock_t get_seq_number() const { return seq_number; }
45 int get_value() const { return value; }
47 Node * get_node() const { return node; }
48 void set_node(Node *n) { node = n; }
49 void set_value(int val) { value = val; }
52 bool is_write() const;
54 bool is_acquire() const;
55 bool is_release() const;
56 bool is_seqcst() const;
57 bool same_var(const ModelAction *act) const;
58 bool same_thread(const ModelAction *act) const;
59 bool is_synchronizing(const ModelAction *act) const;
61 void create_cv(const ModelAction *parent = NULL);
62 ClockVector * get_cv() const { return cv; }
63 void read_from(const ModelAction *act);
65 bool happens_before(const ModelAction *act) const;
67 inline bool operator <(const ModelAction& act) const {
68 return get_seq_number() < act.get_seq_number();
70 inline bool operator >(const ModelAction& act) const {
71 return get_seq_number() > act.get_seq_number();
77 /** Type of action (read, write, thread create, thread yield, thread join) */
80 /** The memory order for this operation. */
83 /** A pointer to the memory location for this action. */
86 /** The thread id that performed this action. */
89 /** The value read or written (if RMW, then the value written). This
90 * should probably be something longer. */
93 /** A back reference to a Node in NodeStack, if this ModelAction is
94 * saved on the NodeStack. */
97 modelclock_t seq_number;
99 /** The clock vector stored with this action; only needed if this
100 * action is a store release? */
104 typedef std::list<class ModelAction *> action_list_t;
106 #endif /* __ACTION_H__ */