source: CIVL/examples/pthread/esbmc/singleton_with-uninit-problems-true.c@ bd7a43e

main test-branch
Last change on this file since bd7a43e 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: 940 bytes
Line 
1extern void __VERIFIER_error();
2
3#include <stdlib.h>
4#include <pthread.h>
5#include <string.h>
6
7void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; }
8
9char *v;
10
11void *thread1(void * arg)
12{
13 v = malloc(sizeof(char));
14 return 0;
15}
16
17void *thread2(void *arg)
18{
19 v[0] = 'X';
20 return 0;
21}
22
23void *thread3(void *arg)
24{
25 v[0] = 'Y';
26 return 0;
27}
28
29void *thread0(void *arg)
30{
31 pthread_t t1, t2, t3, t4, t5;
32
33 pthread_create(&t1, 0, thread1, 0);
34 pthread_join(t1, 0);
35 pthread_create(&t2, 0, thread2, 0);
36 pthread_create(&t3, 0, thread3, 0);
37 pthread_create(&t4, 0, thread2, 0);
38 pthread_create(&t5, 0, thread2, 0);
39 pthread_join(t2, 0);
40 pthread_join(t3, 0);
41 pthread_join(t4, 0);
42 pthread_join(t5, 0);
43
44 return 0;
45}
46
47int main(void)
48{
49 pthread_t t;
50
51 pthread_create(&t, 0, thread0, 0);
52 pthread_join(t, 0);
53
54 __VERIFIER_assert(v[0] == 'X' || v[0] == 'Y');
55 free(v);
56 return 0;
57}
58
59
Note: See TracBrowser for help on using the repository browser.