Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / performance-tests / Synch-Benchmarks / context.c
blobf76ae0df8a099c3f15ed55329d8bd74b24daca48
1 /* FUZZ: disable check_for_improper_main_declaration */
3 #include <stdio.h>
4 // @(#)context.c 1.1 10/18/96
6 #include <stdlib.h>
7 #include <thread.h>
9 #define NSLEEP 100
10 #define TMAX 2
11 int count[TMAX];
13 void *
14 work (void *n)
16 int ni = (int) n;
18 while (1)
20 thr_yield ();
21 count[ni]++;
23 return 0;
26 main (int argc, char *argv[])
28 int ncorr, t1arg, t0arg, orig_ncorr;
29 thread_t tid1, tid0;
30 float rate;
32 if (argc != 6)
34 printf ("usage: %s t0_bound t0_new_lwp t1_bound t1_new_lwp ncorr\n", argv[0]);
35 exit (1);
37 t0arg = THR_DETACHED;
38 if (atoi (argv[1]))
39 t0arg |= THR_BOUND;
40 if (atoi (argv[2]))
41 t0arg |= THR_NEW_LWP;
43 t1arg = THR_DETACHED;
44 if (atoi (argv[3]))
45 t1arg |= THR_BOUND;
46 if (atoi (argv[4]))
47 t1arg |= THR_NEW_LWP;
49 ncorr = atoi (argv[5]);
51 if (thr_create (0, 0, work, 0, t0arg, &tid0) != 0)
52 perror ("couldn't create thread 0");
53 if (thr_create (0, 0, work, (void *) 1, t1arg, &tid1) != 0)
54 perror ("couldn't create thread 1");
56 orig_ncorr = thr_getconcurrency ();
57 if (ncorr)
58 thr_setconcurrency (ncorr);
59 sleep (NSLEEP);
60 rate = (count[0] + count[1]) / ((float) NSLEEP);
61 printf ("\n------------------------------------------------------------------------\n");
62 printf ("t0arg 0x%x (%s, %s, %s)\nt1arg 0x%x (%s, %s, %s)\ncount[0] %d count[1] %d\n\
63 ncorr_orig %d ncorr_set %d ncorr_end %d rate %.3f per_cxt %.2f usec\n",
64 t0arg,
65 (t0arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
66 (t0arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
67 (t0arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
68 t1arg,
69 (t1arg & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
70 (t1arg & THR_BOUND) ? "THR_BOUND" : "Not Bound",
71 (t1arg & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
72 count[0], count[1],
73 orig_ncorr, ncorr, thr_getconcurrency (), rate, 1.0e6 / rate);