From 1a75079a60d2788bad4ee82378182abcfade51c8 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 25 May 2012 19:13:36 -0700 Subject: [PATCH] action: add create_cv() and read_from() These functions provide basic wrapper functionality for creating and updating the clock vector for a particular ModelAction. --- action.cc | 18 ++++++++++++++++++ action.h | 5 +++++ 2 files changed, 23 insertions(+) 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(); } -- 2.34.1