X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=mutex.cc;h=7fa0b589c8a4535a276c7f8f95eda76782bff554;hb=24dbae977ee0610d314b52a42a77f1a6f39752b3;hp=b31b20a8ed2f02446fd1c4fbea5965c65b2b6979;hpb=16ef61e0af2f98a34acaa919077def37ece3b5bd;p=model-checker.git diff --git a/mutex.cc b/mutex.cc index b31b20a..7fa0b58 100644 --- a/mutex.cc +++ b/mutex.cc @@ -1,12 +1,15 @@ -#include "mutex.h" -#include "model.h" +#include +#include "model.h" +#include "threads-model.h" +#include "clockvector.h" namespace std { -mutex::mutex() : - owner(0), islocked(false) -{ - +mutex::mutex() { + state.islocked=false; + thread_id_t tid=thread_current()->get_id(); + state.alloc_tid=tid; + state.alloc_clock=model->get_cv(tid)->getClock(tid); } void mutex::lock() { @@ -14,8 +17,7 @@ void mutex::lock() { } bool mutex::try_lock() { - model->switch_to_master(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this)); - return thread_current()->get_return_value(); + return model->switch_to_master(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this)); } void mutex::unlock() {