1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * This is a translation of a Pthread program from
|
|---|
| 3 | * the Pthread benchmarks of SV-COMP 2014.
|
|---|
| 4 | * https://svn.sosy-lab.org/software/sv-benchmarks/tags/svcomp14/
|
|---|
| 5 | *
|
|---|
| 6 | * Command line execution:
|
|---|
| 7 | * civl verify stateful01_false.cvl -min
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #include <civlc.h>
|
|---|
| 11 | #include "pthread.cvh"
|
|---|
| 12 |
|
|---|
| 13 | pthread_mutex_t ma, mb;
|
|---|
| 14 | int data1, data2;
|
|---|
| 15 |
|
|---|
| 16 | void *thread1(void*arg)
|
|---|
| 17 | {
|
|---|
| 18 | pthread_mutex_lock(&ma);
|
|---|
| 19 | data1++;
|
|---|
| 20 | pthread_mutex_unlock(&ma);
|
|---|
| 21 |
|
|---|
| 22 | pthread_mutex_lock(&ma);
|
|---|
| 23 | data2++;
|
|---|
| 24 | pthread_mutex_unlock(&ma);
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | void *thread2(void*arg)
|
|---|
| 28 | {
|
|---|
| 29 | pthread_mutex_lock(&ma);
|
|---|
| 30 | data1+=5;
|
|---|
| 31 | pthread_mutex_unlock(&ma);
|
|---|
| 32 |
|
|---|
| 33 | pthread_mutex_lock(&ma);
|
|---|
| 34 | data2-=6;
|
|---|
| 35 | pthread_mutex_unlock(&ma);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | void main()
|
|---|
| 39 | {
|
|---|
| 40 | pthread_t t1, t2;
|
|---|
| 41 |
|
|---|
| 42 | pthread_mutex_init(&ma, 0);
|
|---|
| 43 | pthread_mutex_init(&mb, 0);
|
|---|
| 44 |
|
|---|
| 45 | data1 = 10;
|
|---|
| 46 | data2 = 10;
|
|---|
| 47 |
|
|---|
| 48 | pthread_create(&t1, 0, thread1, 0);
|
|---|
| 49 | pthread_create(&t2, 0, thread2, 0);
|
|---|
| 50 |
|
|---|
| 51 | pthread_join(t1, 0);
|
|---|
| 52 | pthread_join(t2, 0);
|
|---|
| 53 |
|
|---|
| 54 | if (data1==16 && data2==5)
|
|---|
| 55 | {
|
|---|
| 56 | $assert($false);
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.