X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=mutex.cc;h=0776db8eef5857b34c47bdbf3493194c9672097a;hp=0bb627d293b03a27d29673b3a95b1b3e136093c2;hb=f85203775e7ad8285c9e33e44ff951e8980feaa9;hpb=11bd7a3e906795b46b1fd20276a28002978bf1ab diff --git a/mutex.cc b/mutex.cc index 0bb627d2..0776db8e 100644 --- a/mutex.cc +++ b/mutex.cc @@ -1,25 +1,27 @@ -#include +#include "mutex.h" #include "model.h" +#include "execution.h" #include "threads-model.h" #include "clockvector.h" #include "action.h" -namespace std { +namespace cdsc { mutex::mutex() { - state.islocked = false; + state.locked = NULL; thread_id_t tid = thread_current()->get_id(); state.alloc_tid = tid; - state.alloc_clock = model->get_cv(tid)->getClock(tid); + ClockVector *cv = model->get_execution()->get_cv(tid); + state.alloc_clock = cv == NULL ? 0 : cv->getClock(tid); } - + void mutex::lock() { model->switch_to_master(new ModelAction(ATOMIC_LOCK, std::memory_order_seq_cst, this)); } - + bool mutex::try_lock() { return model->switch_to_master(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this));