From: Brian Norris Date: Sat, 26 May 2012 02:13:36 +0000 (-0700) Subject: action: add create_cv() and read_from() X-Git-Tag: pldi2013~392^2~19 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=1a75079a60d2788bad4ee82378182abcfade51c8 action: add create_cv() and read_from() These functions provide basic wrapper functionality for creating and updating the clock vector for a particular ModelAction. --- diff --git a/action.cc b/action.cc index 1fe4c7f..b0d8fc9 100644 --- a/action.cc +++ b/action.cc @@ -3,6 +3,7 @@ #include "model.h" #include "action.h" #include "clockvector.h" +#include "common.h" ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value) { @@ -81,6 +82,23 @@ bool ModelAction::is_dependent(ModelAction *act) return false; } +void ModelAction::create_cv(ModelAction *parent) +{ + ASSERT(cv == NULL); + if (parent) + cv = new ClockVector(parent->cv, this); + else + cv = new ClockVector(); +} + +void ModelAction::read_from(ModelAction *act) +{ + ASSERT(cv); + if (act->is_release() && this->is_acquire()) + cv->merge(act->cv); + value = act->value; +} + void ModelAction::print(void) { const char *type_str; diff --git a/action.h b/action.h index 98ec873..6214174 100644 --- a/action.h +++ b/action.h @@ -2,6 +2,8 @@ #define __ACTION_H__ #include +#include + #include "threads.h" #include "libatomic.h" #include "mymemory.h" @@ -42,6 +44,9 @@ public: bool same_thread(ModelAction *act); bool is_dependent(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(); }