source: CIVL/examples/pthread/threader/szymanski_true-unreach-call.c@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.1 KB
Line 
1extern void __VERIFIER_error() __attribute__ ((__noreturn__));
2
3/* Testcase from Threader's distribution. For details see:
4 http://www.model.in.tum.de/~popeea/research/threader
5*/
6
7#include <pthread.h>
8#define assert(e) if (!(e)) ERROR: __VERIFIER_error();
9
10int flag1 = 0, flag2 = 0; // integer flags
11int x; // boolean variable to test mutual exclusion
12
13void *thr1() {
14 flag1 = 1;
15 while (flag2 >= 3);
16 flag1 = 3;
17 if (flag2 == 1) {
18 flag1 = 2;
19 while (flag2 != 4);
20 }
21 flag1 = 4;
22 while (flag2 >= 2);
23 // begin critical section
24 x = 0;
25 assert(x<=0);
26 // end critical section
27 while (2 <= flag2 && flag2 <= 3);
28 flag1 = 0;
29}
30
31void *thr2() {
32 flag2 = 1;
33 while (flag1 >= 3);
34 flag2 = 3;
35 if (flag1 == 1) {
36 flag2 = 2;
37 while (flag1 != 4);
38 }
39 flag2 = 4;
40 while (flag1 >= 2);
41 // begin critical section
42 x = 1;
43 assert(x>=1);
44 // end critical section
45 while (2 <= flag1 && flag1 <= 3);
46 flag2 = 0;
47}
48
49int main() {
50 pthread_t t1, t2;
51 pthread_create(&t1, 0, thr1, 0);
52 pthread_create(&t2, 0, thr2, 0);
53 pthread_join(t1, 0);
54 pthread_join(t2, 0);
55 return 0;
56}
Note: See TracBrowser for help on using the repository browser.