From: Brian Norris Date: Thu, 21 Jun 2012 08:56:50 +0000 (-0700) Subject: action: add happens_before() function X-Git-Tag: pldi2013~391^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cb9b254332794ea63d0089b21b498f4a5301f08b;hp=e8bc4a0715ce1c86f3ff7d24179e1164bf3ee61b;p=model-checker.git action: add happens_before() function Now I can easily compare two ModelActions with the happens_before() relationship. Of course, the clock vectors are not fully complete yet, but this sets the stage... --- diff --git a/action.cc b/action.cc index 34650c6..9f95727 100644 --- a/action.cc +++ b/action.cc @@ -133,6 +133,17 @@ void ModelAction::read_from(ModelAction *act) value = act->value; } +/** + * Check whether 'this' happens before act, according to the memory-model's + * happens before relation. This is checked via the ClockVector constructs. + * @return true if this action's thread has synchronized with act's thread + * since the execution of act, false otherwise. + */ +bool ModelAction::happens_before(ModelAction *act) +{ + return act->cv->synchronized_since(this); +} + void ModelAction::print(void) { const char *type_str; diff --git a/action.h b/action.h index f554e36..ae4afb2 100644 --- a/action.h +++ b/action.h @@ -58,6 +58,8 @@ public: ClockVector * get_cv() const { return cv; } void read_from(ModelAction *act); + bool happens_before(ModelAction *act); + inline bool operator <(const ModelAction& act) const { return get_seq_number() < act.get_seq_number(); }