5 #include "libinterface.h"
8 /** Example implementation of linux rw lock along with 2 thread test
15 static inline bool write_trylock(rwlock_t *rw, MCID *retval)
17 MCID m_priorval=MC2_nextRMW(MCID_NODEP, MCID_NODEP, MCID_NODEP);
18 int priorvalue=rmw_32(CAS, &rw->lock, 0, 1);
23 static inline void write_unlock(rwlock_t *rw)
25 MC2_nextOpStore(MCID_NODEP, MCID_NODEP);
26 store_32(&rw->lock, 0);
33 bool flag=write_trylock(&mylock,&val);
36 br=MC2_branchUsesID(val, 1, 2, true);
39 br=MC2_branchUsesID(val, 0, 2, true);
40 write_unlock(&mylock);
45 static void a(void *obj)
52 int user_main(int argc, char **argv)
54 thrd_t t1, t2;//, t3, t4;
55 MC2_nextOpStore(MCID_NODEP, MCID_NODEP);
56 store_32(&mylock.lock, 0);
58 thrd_create(&t1, (thrd_start_t)&a, NULL);
59 thrd_create(&t2, (thrd_start_t)&a, NULL);
60 //thrd_create(&t3, (thrd_start_t)&a, NULL);
61 //thrd_create(&t4, (thrd_start_t)&a, NULL);