コード例 #1
0
inline void findMax(int offset){
	int i;
	int e;
	int my_max = 0x80000000;
	int c; 
	int cret;

	for(i = offset; i < offset+WORKPERTHREAD; i++) {
		e = storage[i];
		if(e > my_max) {
			my_max = e;
		}
		assert_nl(e <= my_max);
	}

	while(1){
		c = max;
		if(my_max > c){
			__VERIFIER_atomic_CAS(&max,c,my_max,&cret);
			if(cret){
				break;
			}
		}else{
			break;
		}
	}

	assert(my_max <= max);
}
コード例 #2
0
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);
}
コード例 #3
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;

}
void* thr1(void* arg){
  unsigned int x, y, z;
  int i, j, k;
  for(/* reachable */
      /* invariant:
      i >= 0
      */
      i=0; i<x; i++) {
    for(/* invariant:
        -1-i+j >= 0
        i >= 0
        -1+x-i >= 0
        */
        j=i+1; j<y; j++) {
      for(/* invariant:
          -1-i+j >= 0
          i >= 0
          k-j >= 0
          -1+x-i >= 0
          -1+y-j >= 0
          */
          k = j; k < z; k++) {
	assert_nl(k > i);
      }
    }
  }

  /* assert not proved */
  assert(i == x && (/* uncomment to make error go away: x == 0 ||*/ j == y || y <= x+1) && (x == 0 || y <= x+1 || k == z || z < y)) ;

  /* reachable */
  return 0;
}
inline static void akbd_read_char(int wait) {
	/* assert not proved */
	mtx_lock(MTX);
	if (!buf && wait){
		cv_wait(COND,MTX);
		assert_nl(COND);}
	if (!buf) {
		mtx_unlock(MTX);
		return; 	}
	mtx_unlock(MTX); }
コード例 #6
0
inline void sysmonread_power(){
	if (__VERIFIER_nondet_int()){
		mutex_enter(MTX);
		for (;;) {
			if (sysmon_get_power_event()) {
				break;}
			if (__VERIFIER_nondet_int()) {
				break;}
			cv_wait(COND,MTX);
      assert_nl(COND); }
		mutex_exit(MTX); }
  assert(1);
}
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;
}