X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=action.h;h=bf5e6c35476693808b301ec6b4f5b9879e39214b;hb=6d7624344faab763eb30f3a6424f51538b7292a5;hp=2f856e9dfa9be1363dacd91ac84384a52d93cd07;hpb=810306cb85accaaace9a50f174264f105991230b;p=model-checker.git diff --git a/action.h b/action.h index 2f856e9..bf5e6c3 100644 --- a/action.h +++ b/action.h @@ -1,7 +1,13 @@ +/** @file action.h + * @brief Models actions taken by threads. + */ + #ifndef __ACTION_H__ #define __ACTION_H__ #include +#include + #include "threads.h" #include "libatomic.h" #include "mymemory.h" @@ -12,16 +18,21 @@ typedef enum action_type { THREAD_YIELD, THREAD_JOIN, ATOMIC_READ, - ATOMIC_WRITE + ATOMIC_WRITE, + ATOMIC_RMW } action_type_t; /* Forward declaration */ -class TreeNode; class Node; +class ClockVector; +/** + * The ModelAction class encapsulates an atomic action. + */ class ModelAction { public: ModelAction(action_type_t type, memory_order order, void *loc, int value); + ~ModelAction(); void print(void); thread_id_t get_tid() { return tid; } @@ -30,18 +41,21 @@ public: void * get_location() { return location; } int get_seq_number() const { return seq_number; } - TreeNode * get_treenode() { return treenode; } - void set_node(TreeNode *n) { treenode = n; } Node * get_node() { return node; } void set_node(Node *n) { node = n; } bool is_read(); bool is_write(); + bool is_rmw(); bool is_acquire(); bool is_release(); + bool is_seqcst(); bool same_var(ModelAction *act); bool same_thread(ModelAction *act); - bool is_dependent(ModelAction *act); + bool is_synchronizing(ModelAction *act); + + void create_cv(ModelAction *parent = NULL); + void read_from(ModelAction *act); inline bool operator <(const ModelAction& act) const { return get_seq_number() < act.get_seq_number(); @@ -49,18 +63,35 @@ public: inline bool operator >(const ModelAction& act) const { return get_seq_number() > act.get_seq_number(); } - MEMALLOC + + MEMALLOC private: + + /** Type of action (read, write, thread create, thread yield, thread join) */ action_type type; + + /** The memory order for this operation. */ memory_order order; + + /** A pointer to the memory location for this action. */ void *location; + + /** The thread id that performed this action. */ thread_id_t tid; + + /** The value written. This should probably be something longer. */ int value; - TreeNode *treenode; + Node *node; + int seq_number; + + /** The clock vector stored with this action if this action is a + * store release */ + + ClockVector *cv; }; -typedef std::list > action_list_t; +typedef std::list action_list_t; #endif /* __ACTION_H__ */