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

1.23 2.0 main test-branch
Last change on this file since e0fc189 was e3151da, checked in by Ziqing Luo <ziqing@…>, 11 years ago

re-organized example directory

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

  • Property mode set to 100644
File size: 902 bytes
RevLine 
[09bc145]1#include <stdlib.h>
2#include <pthread.h>
3#include <string.h>
4
5void __VERIFIER_assert(int expression) { if (!expression) { ERROR: goto ERROR; }; return; }
6
7char *v;
8
9void *thread1(void * arg)
10{
11 v = malloc(sizeof(char));
12 return 0;
13}
14
15void *thread2(void *arg)
16{
17 v[0] = 'X';
18 return 0;
19}
20
21void *thread3(void *arg)
22{
23 v[0] = 'Y';
24 return 0;
25}
26
27void *thread0(void *arg)
28{
29 pthread_t t1, t2, t3, t4, t5;
30
31 pthread_create(&t1, 0, thread1, 0);
32 pthread_join(t1, 0);
33 pthread_create(&t2, 0, thread2, 0);
34 pthread_create(&t3, 0, thread3, 0);
35 pthread_create(&t4, 0, thread2, 0);
36 pthread_create(&t5, 0, thread2, 0);
37 pthread_join(t2, 0);
38 pthread_join(t3, 0);
39 pthread_join(t4, 0);
40 pthread_join(t5, 0);
41 return 0;
42}
43
44int main(void)
45{
46 pthread_t t;
47
48 pthread_create(&t, 0, thread0, 0);
49 pthread_join(t, 0);
50
51 __VERIFIER_assert(v[0] == 'X' || v[0] == 'Y');
[289415b]52 free(v);
[09bc145]53 return 0;
54}
55
Note: See TracBrowser for help on using the repository browser.