source: CIVL/examples/translation/pthread/fib_bench_false.c@ 4540352

1.23 2.0 main test-branch
Last change on this file since 4540352 was 1d26ee6, checked in by John Edenhofner <johneden@…>, 12 years ago

Updated examples

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

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