main
test-branch
|
Last change
on this file since bb03188 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:
692 bytes
|
| Line | |
|---|
| 1 | #include <pthread.h>
|
|---|
| 2 |
|
|---|
| 3 | #define assume(e) __VERIFIER_assume(e)
|
|---|
| 4 | #define assert_nl(e) { if(!(e)) { goto ERROR; } }
|
|---|
| 5 | #define assert(e) { if(!(e)) { ERROR: goto ERROR; (void)0; } }
|
|---|
| 6 |
|
|---|
| 7 | int m = 0;
|
|---|
| 8 |
|
|---|
| 9 | void __VERIFIER_atomic_acquire()
|
|---|
| 10 | {
|
|---|
| 11 | assume(m==0);
|
|---|
| 12 | m = 1;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | void __VERIFIER_atomic_release()
|
|---|
| 16 | {
|
|---|
| 17 | assume(m==1);
|
|---|
| 18 | m = 0;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | void* thr1(void* arg)
|
|---|
| 22 | {
|
|---|
| 23 | int x;
|
|---|
| 24 | int y;
|
|---|
| 25 |
|
|---|
| 26 | x = __VERIFIER_nondet_int();
|
|---|
| 27 | y = __VERIFIER_nondet_int();
|
|---|
| 28 |
|
|---|
| 29 | int z;
|
|---|
| 30 | __VERIFIER_atomic_acquire();
|
|---|
| 31 | if(x == y)
|
|---|
| 32 | {
|
|---|
| 33 | z = 0;
|
|---|
| 34 | } else {
|
|---|
| 35 | z = 1;
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | if(z == 0)
|
|---|
| 39 | {
|
|---|
| 40 | assert_nl(x == y);
|
|---|
| 41 | } else {
|
|---|
| 42 | assert(x != y);
|
|---|
| 43 | }
|
|---|
| 44 | __VERIFIER_atomic_release();
|
|---|
| 45 |
|
|---|
| 46 | return 0;
|
|---|
| 47 |
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | int main()
|
|---|
| 51 | {
|
|---|
| 52 | pthread_t t;
|
|---|
| 53 |
|
|---|
| 54 | while(1)
|
|---|
| 55 | {
|
|---|
| 56 | pthread_create(&t, 0, thr1, 0);
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.