2 * @brief Models actions taken by threads.
12 #include "libatomic.h"
14 #include "clockvector.h"
18 typedef enum action_type {
28 /* Forward declaration */
33 * The ModelAction class encapsulates an atomic action.
37 ModelAction(action_type_t type, memory_order order, void *loc, int value = VALUE_NONE);
39 void print(void) const;
41 thread_id_t get_tid() const { return tid; }
42 action_type get_type() const { return type; }
43 memory_order get_mo() const { return order; }
44 void * get_location() const { return location; }
45 modelclock_t get_seq_number() const { return seq_number; }
46 int get_value() const { return value; }
48 Node * get_node() const { return node; }
49 void set_node(Node *n) { node = n; }
50 void set_value(int val) { value = val; }
53 bool is_write() const;
55 bool is_initialization() const;
56 bool is_acquire() const;
57 bool is_release() const;
58 bool is_seqcst() const;
59 bool same_var(const ModelAction *act) const;
60 bool same_thread(const ModelAction *act) const;
61 bool is_synchronizing(const ModelAction *act) const;
63 void create_cv(const ModelAction *parent = NULL);
64 ClockVector * get_cv() const { return cv; }
65 void read_from(const ModelAction *act);
67 bool happens_before(const ModelAction *act) const;
69 inline bool operator <(const ModelAction& act) const {
70 return get_seq_number() < act.get_seq_number();
72 inline bool operator >(const ModelAction& act) const {
73 return get_seq_number() > act.get_seq_number();
79 /** Type of action (read, write, thread create, thread yield, thread join) */
82 /** The memory order for this operation. */
85 /** A pointer to the memory location for this action. */
88 /** The thread id that performed this action. */
91 /** The value read or written (if RMW, then the value written). This
92 * should probably be something longer. */
95 /** A back reference to a Node in NodeStack, if this ModelAction is
96 * saved on the NodeStack. */
99 modelclock_t seq_number;
101 /** The clock vector stored with this action; only needed if this
102 * action is a store release? */
106 typedef std::list<ModelAction *> action_list_t;
108 #endif /* __ACTION_H__ */