4 #include "libinterface.h"
7 /** Example implementation of linux rw lock along with 2 thread test
14 static inline bool write_trylock(rwlock_t *rw, MCID *retval)
16 MCID m_priorval=MC2_nextRMW(MCID_NODEP, MCID_NODEP, MCID_NODEP);
17 int priorvalue=rmw_32(CAS, &rw->lock, 0, 1);
22 static inline void write_unlock(rwlock_t *rw)
24 MC2_nextOpStore(MCID_NODEP, MCID_NODEP);
25 store_32(&rw->lock, 0);
32 bool flag=write_trylock(&mylock,&val);
35 br=MC2_branchUsesID(val, 1, 2, true);
38 br=MC2_branchUsesID(val, 0, 2, true);
39 write_unlock(&mylock);
44 static void a(void *obj)
51 int user_main(int argc, char **argv)
53 thrd_t t1, t2;//, t3, t4;
54 MC2_nextOpStore(MCID_NODEP, MCID_NODEP);
55 store_32(&mylock.lock, 0);
57 thrd_create(&t1, (thrd_start_t)&a, NULL);
58 thrd_create(&t2, (thrd_start_t)&a, NULL);
59 //thrd_create(&t3, (thrd_start_t)&a, NULL);
60 //thrd_create(&t4, (thrd_start_t)&a, NULL);