Example #1
0
int main()
{
  key1 = nondet_uchar();
  key2 = key1;

  pthread_t t;
  pthread_create(&t,NULL,foo1,NULL);
  pthread_create(&t,NULL,foo2,NULL);

  if(done1 && done2)
    assert(res1 == res2);
}
Example #2
0
int main ()
{
  int            rval;
  int            size;
  struct file    my_file;
  char          *buffer; /* we do not model this buffer */
  struct inode   inode;
  unsigned int   count;
  unsigned char  random;

  int lock_held = 0; 

  dummy_major = register_chrdev (0, "dummy");
  inode.i_rdev = dummy_major << MINORBITS;

  init_module ();

  /* assign arbitrary values */
  my_file.f_mode = nondet_uint ();
  my_file.f_pos  = nondet_uint ();

  do
    {
      random = nondet_uchar ();
      __CPROVER_assume (0 <= random && random <= 3);

      switch (random)
	{
	case 1: 
	  rval = dummy_open (&inode, &my_file);
	  if (rval == 0)
	    lock_held = TRUE;
	  break;
	case 2:
	  __CPROVER_assume (lock_held);
	  count = dummy_read (&my_file, buffer, BUF_SIZE); 
	  break;
	case 3:
	  dummy_release (&inode, &my_file);
	  lock_held = FALSE;
	  break;
	default:
	  break;
	}
    }
  while (random || lock_held);

  cleanup_module ();
  unregister_chrdev (dummy_major, "dummy");

  return 0;
}
Example #3
0
File: grade.c Project: qif/sqifc
int func(){
	// S is the number of the student
	size_t S = 5;
	// G is the number of grade, from 0 to G-1
	size_t G = 5;
	// n is the number of random numbers generated
	size_t n;
	// this is the sum that will be printed
	size_t output;

	// this is an internal counter for the sum
	size_t sum = 0;

	// these are the random numbers; each one is shared between two students
	size_t numbers[S];

	// these are the public announcements of each student
	size_t announcements[S];

	// there are S secret votes, each one with G possible values:
	size_t h[S]; // h[i] can only take value from 0 to G-1

	// these are just counters
	size_t i = 0;
	size_t j = 0;

	// calculating n
	n = ((G-1)*S)+1;
	
	// counter
	size_t c = 0;

	// generate the random numbers
	for (c = 0; c < S; c++) {
		h[c] = nondet_uchar() % G;
	}

	// generate the random numbers
	for (c = 0; c < S; c++) {
		numbers[c] = nondet_uchar() % n;
	}

	// producing the declarations according to the secret value
	while (i<S) {
  		j=0;
  		while (j<G) {
    			if (h[i]==j)
      				announcements[i]=(j+numbers[i]-numbers[(i+1)%S])%n;
    			j=j+1;
  		}
  		i=i+1;
	}

	//computing the sum, producing the output and terminating
	for (c = 0; c < S; c++) {
  		sum += announcements[c];
	}
	output = sum % n;

	return output;
}