a number of fixes to add missing mo_graph edges to speed up detection of infeasible
[c11tester.git] / mutex.cc
1 #include "mutex.h"
2 #include "model.h"
3
4 namespace std {
5 mutex::mutex() {
6         state.islocked=false;
7         thread_id_t tid=thread_current()->get_id();
8         state.alloc_tid=tid;
9         state.alloc_clock=model->get_cv(tid)->getClock(tid);
10 }
11         
12 void mutex::lock() {
13   model->switch_to_master(new ModelAction(ATOMIC_LOCK, std::memory_order_seq_cst, this));
14 }
15         
16 bool mutex::try_lock() {
17   model->switch_to_master(new ModelAction(ATOMIC_TRYLOCK, std::memory_order_seq_cst, this));
18   return thread_current()->get_return_value();
19 }
20
21 void mutex::unlock() {
22   model->switch_to_master(new ModelAction(ATOMIC_UNLOCK, std::memory_order_seq_cst, this));
23 }
24
25 }