Standardize License information
[openafs.git] / src / lwp / test / test.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <stdio.h>
11 #include <sys/time.h>
12 #include <potpourri.h>
13 #include "lwp.h"
14
15 char semaphore;
16
17 int OtherProcess()
18     {
19     for(;;)
20         {
21         LWP_SignalProcess(&semaphore);
22         }
23     }
24
25 main(argc, argv)
26 int argc; char *argv[];
27     {
28     struct timeval t1, t2;
29     int pid, otherpid;
30     register int i,  count, x;
31     char *waitarray[2];
32     static char c[] = "OtherProcess";
33     
34     count = atoi(argv[1]);
35
36     assert(LWP_InitializeProcessSupport(0, &pid) == LWP_SUCCESS);
37     assert(LWP_CreateProcess(OtherProcess,4096,0, 0, c, &otherpid) == LWP_SUCCESS);
38
39     waitarray[0] = &semaphore;
40     waitarray[1] = 0;
41     gettimeofday(&t1, NULL);
42     for (i = 0; i < count; i++)
43         {
44         LWP_MwaitProcess(1, waitarray, 1);
45         }
46     gettimeofday(&t2, NULL);
47
48     x = (t2.tv_sec -t1.tv_sec)*1000000 + (t2.tv_usec - t1.tv_usec);
49     printf("%d milliseconds for %d MWaits (%f usec per Mwait and Signal)\n", x/1000, count, (float)(x/count));
50     }