source: CIVL/examples/translation/pthread/fib_bench_longest_true.c@ 764d472

1.23 2.0 main test-branch
Last change on this file since 764d472 was 16d81051, checked in by John Edenhofner <johneden@…>, 12 years ago

Added more tests to PthreadTests, modified transformer to only add pthread_exit(NULL) to void pointer methods that will be called as a thread. Transforms each main to have a return(0) call at its end so that the thread pool is freed each time (frees upon return)

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

  • Property mode set to 100644
File size: 659 bytes
Line 
1#include <pthread.h>
2
3void __VERIFIER_assert(int expression) { if (!expression) { ERROR: goto ERROR; }; return; }
4
5int i=1, j=1;
6
7#define NUM 11
8
9void *
10t1(void* arg)
11{
12 int k = 0;
13
14 for (k = 0; k < NUM; k++)
15 i+=j;
16
17 pthread_exit(NULL);
18}
19
20void *
21t2(void* arg)
22{
23 int k = 0;
24
25 for (k = 0; k < NUM; k++)
26 j+=i;
27
28 pthread_exit(NULL);
29}
30
31int
32main(int argc, char **argv)
33{
34 pthread_t id1, id2;
35
36 pthread_create(&id1, NULL, t1, NULL);
37 pthread_create(&id2, NULL, t2, NULL);
38
39 pthread_join(id1, 0);
40 pthread_join(id2, 0);
41 printf("%d", i);
42 printf("%d", j);
43
44 if (i > 46368 || j > 46368) {
45 ERROR:
46 goto ERROR;
47 }
48
49 return 0;
50}
Note: See TracBrowser for help on using the repository browser.