fw4spl
CheckForPthreads.c
1 #include <stdio.h>
2 #include <pthread.h>
3 #include <unistd.h>
4 
5 void* runner(void*);
6 
7 int res = 0;
8 #ifdef __CLASSIC_C__
9 int main(){
10  int ac;
11  char*av[];
12 #else
13 int main(int ac, char*av[]){
14 #endif
15  pthread_t tid[2];
16  pthread_create(&tid[0], 0, runner, (void*)1);
17  pthread_create(&tid[1], 0, runner, (void*)2);
18 
19 #if defined(__BEOS__) && !defined(__ZETA__) // (no usleep on BeOS 5.)
20  usleep(1); // for strange behavior on single-processor sun
21 #endif
22 
23  pthread_join(tid[0], 0);
24  pthread_join(tid[1], 0);
25  if(ac > 1000){return *av[0];}
26  return res;
27 }
28 
29 void* runner(void* args)
30 {
31  int cc;
32  for ( cc = 0; cc < 10; cc ++ )
33  {
34  printf("%p CC: %d\n", args, cc);
35  }
36  res ++;
37  return 0;
38 }