5 #include "threads-model.h"
6 #include "clockvector.h"
11 mutex::mutex(int type)
14 thread_id_t tid = thread_current()->get_id();
15 state.alloc_tid = tid;
16 ClockVector *cv = model->get_execution()->get_cv(tid);
17 state.alloc_clock = cv == NULL ? 0 : cv->getClock(tid);
19 // For recursive mutex
26 model->switch_thread(new ModelAction(ATOMIC_LOCK, std::memory_order_seq_cst, this));
29 bool mutex::try_lock()
31 return model->switch_thread(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this));
36 model->switch_thread(new ModelAction(ATOMIC_UNLOCK, std::memory_order_seq_cst, this));