home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / tests / benchmarks / signocsw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-05-06  |  502 b   |  37 lines

  1. /*
  2.  * Signal without context switch benchmark.
  3.  */
  4. #include <signal.h>
  5.  
  6. int    pid;
  7. int    nsigs;
  8. int    sigsub();
  9.  
  10. main(argc, argv)
  11.     char *argv[];
  12. {
  13.     register int i;
  14.  
  15.     if (argc < 2) {
  16.         printf("usage: %s nsignals\n", argv[0]);
  17.         exit(1);
  18.     }
  19.     nsigs = atoi(argv[1]);
  20.     signal(SIGALRM, sigsub);
  21.     pid = getpid();
  22.     for (i = 0; i < nsigs; i++)
  23.         kill(pid, SIGALRM);
  24. }
  25.  
  26. sigsub()
  27. {
  28.     static mustreset = 1;
  29.     int (*osig)();
  30.  
  31.     if (mustreset) {
  32.         osig = signal(SIGALRM, sigsub);
  33.         if (osig == sigsub)
  34.             mustreset = 0;
  35.     }
  36. }
  37.