home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / byte-benchmarks3.1 / part01 / src / execl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-01  |  2.3 KB  |  94 lines

  1. /*******************************************************************************
  2.  *  The BYTE UNIX Benchmarks - Release 3
  3.  *          Module: execl.c   SID: 3.3 5/15/91 19:30:19
  4.  *          
  5.  *******************************************************************************
  6.  * Bug reports, patches, comments, suggestions should be sent to:
  7.  *
  8.  *    Ben Smith, Rick Grehan or Tom Yager
  9.  *    ben@bytepb.byte.com   rick_g@bytepb.byte.com   tyager@bytepb.byte.com
  10.  *
  11.  *******************************************************************************
  12.  *  Modification Log:
  13.  *  $Header: execl.c,v 3.5 87/06/22 15:37:08 kjmcdonell Beta $
  14.  *  August 28, 1990 - Modified timing routines
  15.  *
  16.  ******************************************************************************/
  17. /*
  18.  *  Execing
  19.  *
  20.  */
  21. char SCCSid[] = "@(#) @(#)execl.c:3.3 -- 5/15/91 19:30:19";
  22.  
  23. #include <stdio.h>
  24. #include <sys/types.h>
  25.  
  26. char    bss[8*1024];    /* something worthwhile */
  27.  
  28. #define main dummy
  29.             
  30. #include "big.c"        /* some real code */
  31.  
  32. #undef main
  33.  
  34. /* added by BYTE */
  35. char *getenv();
  36.  
  37.  
  38. main(argc, argv)    /* the real program */
  39. int    argc;
  40. char    *argv[];
  41. {
  42.         unsigned long iter = 0;
  43.     char *ptr; 
  44.     char *fullpath;
  45.     int     duration;
  46.     char    count_str[6], start_str[12], path_str[81], *dur_str;
  47.     long    start_time, this_time;
  48.  
  49. #ifdef DEBUG
  50.     int count;
  51.     for(count = 0; count < argc; ++ count)
  52.         printf("%s ",argv[count]);
  53.         printf("\n");
  54. #endif
  55.     if (argc < 2) 
  56.         {
  57.         printf("Usage: %s duration\n", argv[0]);
  58.         exit(1);
  59.         }
  60.  
  61.  
  62.     duration = atoi(argv[1]);
  63.     if (duration > 0) 
  64.         /* the first invocation */
  65.         {  
  66.         dur_str = argv[1];
  67.         if((ptr = getenv("BINDIR")) != NULL)
  68.             sprintf(path_str,"%s/execl",ptr);
  69.         fullpath=path_str;
  70.         time(&start_time);
  71.         }
  72.     else  /* one of those execl'd invocations */
  73.         {
  74.         /* real duration follow the phoney null duration */
  75.         duration = atoi(argv[2]);
  76.         dur_str = argv[2];
  77.         iter = (unsigned long)atoi(argv[3]); /* where are we now ? */
  78.         sscanf(argv[4], "%ld", &start_time);
  79.         fullpath = argv[0];
  80.         } 
  81.  
  82.     sprintf(count_str, "%d", ++iter); /* increment the execl counter */
  83.     sprintf(start_str, "%ld", start_time);
  84.     time(&this_time);
  85.     if (this_time - start_time >= duration) { /* time has run out */
  86.         fprintf(stderr, "%ld loops\n", iter);
  87.         exit(0);
  88.         }
  89.     execl(fullpath, fullpath, "0", dur_str, count_str, start_str, 0);
  90.     printf("Exec failed at iteration %d\n", iter);
  91.     perror("Reason");
  92.     exit(1);
  93. }
  94.