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 = VALUE_NONE);
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; }
43 int get_value() const { return value; }
45 Node * get_node() const { return node; }
46 void set_node(Node *n) { node = n; }
47 void set_value(int val) { value = val; }
50 bool is_write() const;
52 bool is_acquire() const;
53 bool is_release() const;
54 bool is_seqcst() const;
55 bool same_var(const ModelAction *act) const;
56 bool same_thread(const ModelAction *act) const;
57 bool is_synchronizing(const ModelAction *act) const;
59 void create_cv(ModelAction *parent = NULL);
60 ClockVector * get_cv() const { return cv; }
61 void read_from(ModelAction *act);
63 bool happens_before(ModelAction *act);
65 inline bool operator <(const ModelAction& act) const {
66 return get_seq_number() < act.get_seq_number();
68 inline bool operator >(const ModelAction& act) const {
69 return get_seq_number() > act.get_seq_number();
75 /** Type of action (read, write, thread create, thread yield, thread join) */
78 /** The memory order for this operation. */
81 /** A pointer to the memory location for this action. */
84 /** The thread id that performed this action. */
87 /** The value read or written (if RMW, then the value written). This
88 * should probably be something longer. */
91 /** A back reference to a Node in NodeStack, if this ModelAction is
92 * saved on the NodeStack. */
97 /** The clock vector stored with this action; only needed if this
98 * action is a store release? */
102 typedef std::list<class ModelAction *> action_list_t;
104 #endif /* __ACTION_H__ */