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