home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / tests / benchmarks / bench-4.1 / signocsw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-05-06  |  406 b   |  32 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.  
  14.     if (argc < 2) {
  15.         printf("usage: %s nsignals\n", argv[0]);
  16.         exit(1);
  17.     }
  18.     nsigs = atoi(argv[1]);
  19.     signal(SIGALRM, sigsub);
  20.     pid = getpid();
  21.     kill(pid, SIGALRM);
  22. }
  23.  
  24. sigsub()
  25. {
  26.     static int i = 0;
  27.  
  28.     signal(SIGALRM, sigsub);
  29.     if (i++ < nsigs)
  30.         kill(pid, SIGALRM);
  31. }
  32.