source: CIVL/examples/pthread/stateful01_true.cvl@ 4b4bbb3

1.23 2.0 main test-branch
Last change on this file since 4b4bbb3 was 38374b7, checked in by John Edenhofner <johneden@…>, 12 years ago

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

  • Property mode set to 100644
File size: 966 bytes
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_true.cvl
8*/
9
10#include <civlc.h>
11#include "pthread.cvh"
12
13pthread_mutex_t ma, mb;
14int data1, data2;
15
16void *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
28void *thread2(void*arg)
29{
30 pthread_mutex_lock(&ma);
31 data1+=5;
32 pthread_mutex_unlock(&ma);
33
34 pthread_mutex_lock(&ma);
35 data2-=6;
36 pthread_mutex_unlock(&ma);
37}
38
39
40void main()
41{
42 pthread_t t1, t2;
43
44 pthread_mutex_init(&ma, 0);
45 pthread_mutex_init(&mb, 0);
46
47 data1 = 10;
48 data2 = 10;
49
50 pthread_create(&t1, 0, thread1, 0);
51 pthread_create(&t2, 0, thread2, 0);
52
53 pthread_join(t1, 0);
54 pthread_join(t2, 0);
55
56 if (data1!=16 && data2!=5)
57 {
58 $assert($false);
59 }
60}
Note: See TracBrowser for help on using the repository browser.