/***************************************************************************** * SOURCE: This is a translation of a Pthread program from * the Pthread benchmarks of SV-COMP 2014. * https://svn.sosy-lab.org/software/sv-benchmarks/tags/svcomp14/ * FILE: queue_ok_true.cvl * DESCRIPTION: * * Command line execution: * civl verify queue_ok_true.cvl ******************************************************************************/ #include #include #include #include #include "pthread.cvh" #define SIZE (4) #define EMPTY (-1) #define FULL (-2) #define FALSE (0) #define TRUE (1) typedef struct { int element[SIZE]; int head; int tail; int amount; } QType; int stored_elements[SIZE]; _Bool enqueue_flag, dequeue_flag; pthread_mutex_t m; QType queue; int init(QType *q) { q->head=0; q->tail=0; q->amount=0; } int nondet() { return $choose_int(2); } int empty(QType *q) { if (q->head == q->tail) { printf("queue is empty\n"); return EMPTY; } return 0; } int full(QType *q) { if (q->amount == SIZE) { printf("queue is full\n"); return FULL; } else return 0; } int enqueue(QType *q, int x) { q->element[q->tail] = x; q->amount++; if (q->tail == SIZE) { q->tail = 1; } else { q->tail++; } return 0; } int dequeue(QType *q) { int x; x = q->element[q->head]; q->amount--; if (q->head == SIZE) { q->head = 1; } else q->head++; return x; } void *t1(void *arg) { int value, i; printf("1"); pthread_mutex_lock(&m); if (enqueue_flag) { for(i=0; i