source: CIVL/examples/pthread/stateful01_true.cvl@ 761eb6f

1.23 2.0 main test-branch
Last change on this file since 761eb6f was 9f23e8b, checked in by John Edenhofner <johneden@…>, 12 years ago

Added bug fix programs and some documentation

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

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*****************************************************************************
2* SOURCE: 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* FILE: stateful01_true.cvl
6* DESCRIPTION:
7*
8* Command line execution:
9* civl verify stateful01_true.cvl
10******************************************************************************/
11
12#include <civlc.h>
13#include "pthread.cvh"
14
15pthread_mutex_t ma, mb;
16int data1, data2;
17
18void *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
30void *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
42void 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.