void* thr1(void* arg) { while(1) { __VERIFIER_atomic_acquire(&mutexa); assert_nl(count >= -1); __VERIFIER_atomic_acquire(&mutexb); assert(count == 0); __VERIFIER_atomic_release(&mutexb); __VERIFIER_atomic_release(&mutexa); } return 0; }
inline void my_thread1() { __VERIFIER_atomic_acquire(&mutexa); count++; count--; __VERIFIER_atomic_release(&mutexa); __VERIFIER_atomic_acquire(&mutexa); count--; count++; __VERIFIER_atomic_release(&mutexa); return; }
void * thr1(void* arg) { __VERIFIER_atomic_acquire(&m_inode); if(inode == 0){ __VERIFIER_atomic_acquire(&m_busy); busy = 1; __VERIFIER_atomic_release(&m_busy); inode = 1; } block = 1; assert(block == 1); __VERIFIER_atomic_release(&m_inode); return 0; }
void* thr1(void* arg) { int x; int y; x = __VERIFIER_nondet_int(); y = __VERIFIER_nondet_int(); int z; __VERIFIER_atomic_acquire(); if(x == y) { z = 0; } else { z = 1; } if(z == 0) { assert_nl(x == y); } else { assert(x != y); } __VERIFIER_atomic_release(); return 0; }
inline void my_thread2() { __VERIFIER_atomic_acquire(&mutexb); __VERIFIER_atomic_dec(); __VERIFIER_atomic_inc(); __VERIFIER_atomic_release(&mutexb); }
inline void findMax(int offset){ int i; int e; int my_max = 0x80000000; for(i = offset; i < offset+WORKPERTHREAD; i++) { #ifndef NOBUG e = storage[i]; #else e = rand(); #endif if(e > my_max) { my_max = e; } assert_nl(e <= my_max); } __VERIFIER_atomic_acquire(); { if(my_max > max) { max = my_max; } } __VERIFIER_atomic_release(); assert(my_max <= max); }
void* thr1(void* arg) { __VERIFIER_atomic_acquire(); // m=0 /\ m'=1 x = 0; x = 1; assert(x>=1); __VERIFIER_atomic_release(); return 0; }
void* thr1(void* arg) { __VERIFIER_atomic_acquire(); g0=1,g1=1; __VERIFIER_atomic_release(); lock=1; return 0; }
void Barrier2() { __VERIFIER_atomic_acquire(); count++; if (count == 3) { cnd_broadcast(COND); //pthread_cond_broadcast(&cond); count = 0; } else cnd_wait(COND,MTX); //pthread_cond_wait(&cond, &m); __VERIFIER_atomic_release(); }
void* thr1(void* arg) { //nsThread::Init (mozilla/xpcom/threads/nsThread.cpp 1.31) int PR_CreateThread__RES = 1; __VERIFIER_atomic_acquire(); start_main=1; __VERIFIER_atomic_thr1(PR_CreateThread__RES); __VERIFIER_atomic_release(); return 0; }
void* thr2(void* arg) { //nsThread::Main (mozilla/xpcom/threads/nsThread.cpp 1.31) int self = mThread; while (start_main==0); __VERIFIER_atomic_acquire(); __VERIFIER_atomic_release(); __VERIFIER_atomic_thr2(self); return 0; }
/* * =========================================================================== ..dec():::ENTER True: see comments above main() ::dec_flag == ::inc_v ::dec_flag == ::dec_v True: value is always incremented ::value one of { 0, 1 } True: m is sometimes acquired before this thread starts ::m one of { 0, 1 } ::inc_flag one of { 0, 1 } True: sometimes decremented ::dec_flag == 0 True: const arg == null ::value <= ::inc_flag ::value >= ::dec_flag ::m <= ::inc_flag ::m >= ::dec_flag ::inc_flag >= ::dec_flag =========================================================================== ..dec():::EXIT True: m is always zero on end ::m == ::inc_v ::m == orig(::dec_flag) ::m == orig(::inc_v) ::m == orig(::dec_v) ::dec_flag == ::dec_v ::value one of { 0, 1 } ::m == 0 ::inc_flag one of { 0, 1 } ::dec_flag one of { 0, 1 } True: const return != null ::value >= ::m ::value <= ::inc_flag ::m <= ::inc_flag ::m <= ::dec_flag ::m <= orig(::value) ::m <= orig(::m) ::m <= orig(::inc_flag) ::inc_flag >= ::dec_flag ::inc_flag >= orig(::value) ::inc_flag >= orig(::m) ::inc_flag >= orig(::inc_flag) ::dec_flag >= orig(::value) */ void* dec(void *arg) { __VERIFIER_atomic_acquire(); if(value == 0) { __VERIFIER_atomic_release(); }else{ dec_v = value; dec_flag = 1, value = dec_v - 1; /*set flag, then update*/ __VERIFIER_atomic_release(); } }
void * thr2(void* arg) { __VERIFIER_atomic_acquire(&m_busy); if(busy == 0){ block = 0; assert(block == 0); } __VERIFIER_atomic_release(&m_busy); return 0; }
void* thr1(void* arg) { while(1) { __VERIFIER_atomic_acquire(); assert(a != b); __VERIFIER_atomic_release(); } return 0; }
/* =========================================================================== ..inc():::ENTER True: value is always zero when inc() starts (inc thread starts first) ::value == ::inc_flag ::value == ::dec_flag ::value == ::inc_v ::value == ::dec_v ::value == 0 ::m one of { 0, 1 } True: const arg == null ::value <= ::m =========================================================================== ..inc():::EXIT True: inc_v is always 0 and m is always released ::m == ::inc_v ::m == orig(::value) ::m == orig(::inc_flag) ::m == orig(::dec_flag) ::m == orig(::inc_v) ::m == orig(::dec_v) True: see above main() ::dec_flag == ::dec_v True: value is always incremented ::value one of { 0, 1 } True: inc_v is always 0 and m is always released ::m == 0 True: value is always incremented ::inc_flag == 1 True: dec only sometimes ::dec_flag one of { 0, 1 } return != null ::value >= ::m ::value <= ::inc_flag ::value != ::dec_flag ::value >= orig(::m) ::m <= ::dec_flag ::m <= orig(::m) ::inc_flag >= ::dec_flag ::inc_flag >= orig(::m) */ void* inc(void *arg) { __VERIFIER_atomic_acquire(); if(value == 0u-1) { __VERIFIER_atomic_release(); }else{ inc_v = value; inc_flag = 1, value = inc_v + 1; /*set flag, then update*/ __VERIFIER_atomic_release(); } }
void* thr1(void* arg) { /* reachable */ while(1) { __VERIFIER_atomic_acquire(&mutexa); /* assert OK */ assert(count >= -1); __VERIFIER_atomic_release(&mutexa); } return 0; /* UNREACHABLE */ }
void* thr3(void* arg) { __VERIFIER_atomic_acquire(); if(__VERIFIER_nondet_int()) { g0=0; g1=0; lock=0; } __VERIFIER_atomic_release(); __VERIFIER_atomic_acquire(); if(lock) { x=1; assert(g0==1 && g1==1); } __VERIFIER_atomic_release(); return 0; }
inline int PseudoRandomUsingAtomic_nextInt() { int read, nexts, nextInt_return; assert(seed != 0); __VERIFIER_atomic_acquire(); read = seed; nexts = calculateNext(read); seed = nexts; __VERIFIER_atomic_release(); nextInt_return = min(nexts,NUM); return nextInt_return; }
void* thr2(void* arg) { for(;;){ __VERIFIER_atomic_acquire(); temp = a; a = b; b = c; c = temp; __VERIFIER_atomic_release(); } return 0; }
inline void push(int d) { int oldTop = -1, newTop = -1; __VERIFIER_atomic_index_malloc(&newTop); if(newTop == 0) exit(-1); else{ INDIR(newTop,0) = d; __VERIFIER_atomic_acquire(); oldTop = top; INDIR(newTop,1) = oldTop; top = newTop; __VERIFIER_atomic_release(); } }
inline int index_malloc(){ int curr_alloc_idx = -1; __VERIFIER_atomic_acquire(&m); if(next_alloc_idx+2-1 > MEMSIZE){ __VERIFIER_atomic_release(&m); curr_alloc_idx = 0; }else{ curr_alloc_idx = next_alloc_idx; next_alloc_idx += 2; __VERIFIER_atomic_release(&m); } return curr_alloc_idx; }
void* thr2(void* arg) { FuncType pf; if( /* reachable */ __VERIFIER_nondet_int() ) pf = f1; else pf = f2; __VERIFIER_atomic_acquire(); res = pf(4,3); __VERIFIER_atomic_release(); return 0; }
inline int push(int d) { int oldTop = -1, newTop = -1; newTop = index_malloc(); if(newTop == 0){ return 0; }else{ INDIR(newTop,0) = d; __VERIFIER_atomic_acquire(&m); oldTop = top; INDIR(newTop,1) = oldTop; top = newTop; __VERIFIER_atomic_release(&m); return 1; } }
inline unsigned inc() { unsigned inc_v = 0; __VERIFIER_atomic_acquire(); if(value == 0u-1) { __VERIFIER_atomic_release(); return 0; }else{ inc_v = value; inc_flag = 1, value = inc_v + 1; /*set flag, then update*/ __VERIFIER_atomic_release(); atomic_assert(dec_flag || value > inc_v); return inc_v + 1; } }
inline void findMax(int offset) { int i; int e; for(i = offset; i < offset+WORKPERTHREAD; i++) { e = storage[i]; __VERIFIER_atomic_acquire(); { if(e > max) { max = e; } } __VERIFIER_atomic_release(); assert(e <= max); } }
void* thr1(void* arg) { __VERIFIER_atomic_acquire(&m2); switch(state) { case 0: EBStack_init(); state = 1; //fall-through case 1: __VERIFIER_atomic_release(&m2); push_loop(); break; } return 0; }
inline unsigned dec() { unsigned dec_v; __VERIFIER_atomic_acquire(); if(value == 0) { __VERIFIER_atomic_release(); return 0u-1; /*decrement failed, return max*/ }else{ dec_v = value; dec_flag = 1, value = dec_v - 1; /*set flag, then update*/ __VERIFIER_atomic_release(); atomic_assert(inc_flag || value < dec_v); return dec_v - 1; } }
void* thr1(void* arg) { __VERIFIER_atomic_acquire(); switch(state) { case STATE_UNINITIALIZED: PseudoRandomUsingAtomic_constructor(1); state = STATE_INITIALIZED; __VERIFIER_atomic_release(); PseudoRandomUsingAtomic_monitor(); //never returns break; case STATE_INITIALIZED: __VERIFIER_atomic_release(); PseudoRandomUsingAtomic__threadmain(); break; } return 0; }
inline int PseudoRandomUsingAtomic_nextInt(int n) { int read, nexts, nextInt_return; __VERIFIER_atomic_acquire(); read = seed; do { nexts = __VERIFIER_nondet_int(); } while(nexts == read || nexts == 0); assert(nexts != read); seed = nexts; __VERIFIER_atomic_release(); nextInt_return = nexts % n; //assume(nexts < n + 1); //nextInt_return = nexts; return nextInt_return; }