home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1228 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  57.6 KB

  1. From: kaul@icarus.eng.ohio-state.edu (Rich Kaul)
  2. Newsgroups: alt.sources
  3. Subject: NCR System Characterization Benchmark Part 2 of 4
  4. Message-ID: <KAUL.90Apr24093946@icarus.eng.ohio-state.edu>
  5. Date: 24 Apr 90 13:39:46 GMT
  6.  
  7. #! /bin/sh
  8. # This is a shell archive, meaning:
  9. # 1. Remove everything above the #! /bin/sh line.
  10. # 2. Save the resulting text in a file.
  11. # 3. Execute 
  12. the file with /bin/sh (not csh) to create:
  13. #    cpurun.c
  14. #    crun.c
  15. #    drun.c
  16. #    makefiles.c
  17. #    rplot.c
  18. #    tplot.c
  19. #    trun.c
  20. #    xrun.c
  21. # This archive created: Mon Apr 14 09:43:34 1986
  22. export PATH; PATH=/bin:/usr/bin:$PATH
  23. if test -f 'cpurun.c'
  24. then
  25.     echo shar: "will not over-write existing file 'cpurun.c'"
  26. else
  27. cat << \SHAR_EOF > 'cpurun.c'
  28. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  29.  
  30. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  31. #include "stdio.h"
  32. #define MAXPROC 64
  33.  
  34. #define NULL 0
  35.  
  36. FILE * stream;
  37.  
  38. static double timex,timey;
  39.  
  40.  
  41. static int noproc,maxjobs;
  42. static int nomp,nottyc,nottycl;
  43. static int count,itotal,status;
  44. static int pid,cid,tagid;
  45. static double stime;
  46. static int tablepid[MAXPROC];
  47. static int notty,nodiskw,nodiskr,nouser;
  48. static double jobs;
  49. static long start,end,ftime;
  50.  
  51.  
  52. main( )
  53. {
  54.     register int i,dc,tc;
  55.     static int k,j,n,nx;
  56.     static double ddcnt,ttcnt;
  57.     static double dstep,ddelta,tstep,tdelta;
  58.  
  59.     maxjobs = 200;
  60.     ptime(1);
  61.     count = 0;
  62.     itotal = 0;
  63.     noproc = 1;
  64.     for(i=1; i<=noproc; i++)
  65.     {
  66.         tablepid[i] = 0;
  67.     }
  68.     if( (stream = fopen("loopcount","r")) == NULL )
  69.     {
  70.         printf("unable to open file loopcount\n");
  71.         exit(0);
  72.     }
  73.     fscanf(stream,"%d",&nx);
  74.     fclose(stream);
  75.     nx--;
  76.     notty = 30;
  77.     nodiskr = 32;
  78.     dc = 1;
  79.     tc = 1;
  80.     dstep = 0.0;
  81.     ddelta = (double)nodiskr / (double)nx;
  82.     tstep = 0.0;
  83.     tdelta = (double)notty / (double)nx;
  84.     nx++;
  85.     i = -1;
  86.     start = ptime(1);
  87.     while( 1 )
  88.     {
  89.         i++;
  90.         tagid = getid( );
  91.         if( ( pid = fork( ) ) == 0 )
  92.         {
  93.             for(i=1; i<=nx; i++)
  94.             {
  95.                 dstep += ddelta;
  96.                 ddcnt = (double)dc;
  97.                 if( dstep >= ddcnt )
  98.                 {
  99.                     dc++;
  100.                 }
  101.                 tstep += tdelta;
  102.                 ttcnt = (double)tc;
  103.                 if( tstep >= ttcnt )
  104.                 {
  105.                     tc++;
  106.                 }
  107.             }
  108.             exit(0);
  109.         }
  110.         if( pid > 0 )
  111.         {
  112.             insert(pid);
  113.             count++;
  114.         }
  115.         else
  116.         {
  117.             printf(" can not fork child process\n");
  118.             exit(1);
  119.         }
  120.         if( count == noproc )
  121.         {
  122.             cid = wait(&status);
  123.             count--;
  124.             freeit(cid);
  125.             if( ++itotal >= (maxjobs + 1 - noproc) )
  126.             {
  127.                 while( count > 0 )
  128.                 {
  129.                     cid = wait(&status);
  130.                     count--;
  131.                     itotal++;
  132.                     freeit(cid);
  133.                 }
  134.                 goto ENDIT;
  135.             }
  136.         }
  137.     }
  138.     ENDIT:
  139.     end = ptime(1);
  140.     ftime = end - start;
  141.     timex = ( (double)ftime ) / 1000.0;
  142.     count = 0;
  143.     itotal = 0;
  144.     noproc = 8;
  145.     for(i=1; i<=noproc; i++)
  146.     {
  147.         tablepid[i] = 0;
  148.     }
  149.     nx--;
  150.     notty = 30;
  151.     nodiskr = 32;
  152.     dc = 1;
  153.     tc = 1;
  154.     dstep = 0.0;
  155.     ddelta = (double)nodiskr / (double)nx;
  156.     tstep = 0.0;
  157.     tdelta = (double)notty / (double)nx;
  158.     nx++;
  159.     i = -1;
  160.     start = ptime(1);
  161.     while( 1 )
  162.     {
  163.         i++;
  164.         tagid = getid( );
  165.         if( ( pid = fork( ) ) == 0 )
  166.         {
  167.             for(i=1; i<=nx; i++)
  168.             {
  169.                 dstep += ddelta;
  170.                 ddcnt = (double)dc;
  171.                 if( dstep >= ddcnt )
  172.                 {
  173.                     dc++;
  174.                 }
  175.                 tstep += tdelta;
  176.                 ttcnt = (double)tc;
  177.                 if( tstep >= ttcnt )
  178.                 {
  179.                     tc++;
  180.                 }
  181.             }
  182.             exit(0);
  183.         }
  184.         if( pid > 0 )
  185.         {
  186.             insert(pid);
  187.             count++;
  188.         }
  189.         else
  190.         {
  191.             printf(" can not fork child process\n");
  192.             exit(1);
  193.         }
  194.         if( count == noproc )
  195.         {
  196.             cid = wait(&status);
  197.             count--;
  198.             freeit(cid);
  199.             if( ++itotal >= (maxjobs + 1 - noproc) )
  200.             {
  201.                 while( count > 0 )
  202.                 {
  203.                     cid = wait(&status);
  204.                     count--;
  205.                     itotal++;
  206.                     freeit(cid);
  207.                 }
  208.                 goto ENDIT2;
  209.             }
  210.         }
  211.     }
  212.     ENDIT2:
  213.     end = ptime(1);
  214.     ftime = end - start;
  215.     timey = ( (double)ftime ) / 1000.0;
  216.     if( (stream = fopen("subele","a")) == NULL )
  217.     {
  218.         printf("unable to open file subele\n");
  219.         exit(1);
  220.     }
  221.     fprintf(stream," Effective CPU Processing Power %9.5f\n",timex / timey);
  222.     fclose(stream);
  223.     exit(0);
  224. }
  225.  
  226. long
  227. ptime(tflag)
  228.     int tflag;
  229. {
  230.     static long tm[4];
  231.     static int first = 1;
  232.     static long tstart = 0;
  233.     static long xtime = 0;
  234.     long times( );
  235.     register int i;
  236.  
  237.     if( tflag && first )
  238.     {
  239.         tstart = times(tm);
  240.         first = 0;
  241.         return(0);
  242.     }
  243.     xtime = times(tm);
  244.     if( tflag )
  245.     {
  246.         xtime = (1000 * (xtime - tstart)) / 60;
  247.     }
  248.     else
  249.     {
  250.         xtime = (1000 * tm[0] ) / 60;
  251.     }
  252.     return(xtime);
  253. }
  254.  
  255. insert(pid)
  256.     int pid;
  257. {
  258.     register int j;
  259.  
  260.     for(j=1; j<=noproc; j++)
  261.     {
  262.         if( tablepid[j] == 0 )
  263.         {
  264.             tablepid[j] = pid;
  265.             return(pid);
  266.         }
  267.     }
  268.     printf("no free space on insert pid\N");
  269.     return(0);
  270. }
  271.  
  272. freeit(pid)
  273.     int pid;
  274. {
  275.     register int j;
  276.  
  277.     for(j=1; j<=noproc; j++)
  278.     {
  279.         if( tablepid[j] == pid )
  280.         {
  281.             tablepid[j] = 0;
  282.             return(j);
  283.         }
  284.     }
  285.     printf("pid not found in table on free\n");
  286.     return(0);
  287. }
  288.  
  289. getid( )
  290. {
  291.     register int j;
  292.  
  293.     for(j=1; j<=noproc; j++)
  294.     {
  295.         if( tablepid[j] == 0 )
  296.         {
  297.             return(j);
  298.         }
  299.     }
  300.     printf("no free space on getpid\n");
  301.     return(0);
  302. }
  303. SHAR_EOF
  304. fi
  305. if test -f 'crun.c'
  306. then
  307.     echo shar: "will not over-write existing file 'crun.c'"
  308. else
  309. cat << \SHAR_EOF > 'crun.c'
  310. #include "sys/types.h"
  311. #include "sys/times.h"
  312. #include "stdio.h"
  313.  
  314. #define NOTEST 23
  315. #define NULL 0
  316.  
  317. FILE * stream;
  318.  
  319. /* add short test */
  320.     
  321. adds(n)
  322.     int n;
  323. {
  324.     register short sa,sb,*psa,*psb;
  325.     short sx,sy,asx[32],asy[32],*psx,*psy;
  326.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  327.     register int j;
  328.     register int s = 0;
  329.  
  330.     j = s + 1;
  331.     sa = s + 5;
  332.     sb = s + 10;
  333.     sy = s + 4;
  334.     sx = s + 5;
  335.     asx[1] = s + 7;
  336.     asy[1] = s + 3;
  337.     s1 = s;
  338.     s2 = s + 9;
  339.     as1[1] = s + 8;
  340.     as2[1] = s + 7;
  341.     
  342.     psx = &sx;
  343.     psb = &sy;
  344.     
  345.     while(n--)
  346.     {
  347.         s1 = s1 + sb + sx + sy + sa + sb + sx + sy + sa + sb + sx + sy
  348.             + sa + sb + sx + sy + sa + sb + sx + sy + sa + sb + s2
  349.             + sa + sa + sb + s2 + (*psb) + asx[j] + asy[j] + as1[j]
  350.             + as2[j] + (*psx);
  351.     }
  352.     return(s1);
  353. }
  354.     
  355. /* substract short test */
  356.  
  357. subs(n)
  358.     int n;
  359. {
  360.     register short sa,sb,*psa,*psb;
  361.     short sx,sy,asx[32],asy[32],*psx,*psy;
  362.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  363.     register int j;
  364.     register s = 0;
  365.  
  366.     j = s + 1;
  367.     sa = s + 5;
  368.     sb = s + 3;
  369.     sy = s + 5;
  370.     sx = s + 6;
  371.     asx[1] = s + 7;
  372.     asy[1] = s + 4;
  373.     s1 = s + 32000;
  374.     s2 = s + 2;
  375.     as1[1] = s + 3;
  376.     as2[1] = s + 7;
  377.     
  378.     psx = &sx;
  379.     psb = &sy;
  380.     
  381.     while(n--)
  382.     {
  383.         s1 = s1 - sb - sx - sy - sa - sb - sx - sy - sa - sb - sx - sy
  384.             - sa - sb - sx - sy - sa - sb - sx - sy - sa - sb - s2
  385.             - sa - sa - sb - s2 - (*psb) - asx[j] - asy[j] - as1[j]
  386.             - as2[j] - (*psx);
  387.     }
  388.     return(s1);
  389. }
  390.  
  391. /* multiply short */
  392.  
  393. muls(n)
  394.     int n;
  395. {
  396.     register short sa,sb,*psa,*psb;
  397.     short sx,sy,asx[32],asy[32],*psx,*psy;
  398.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  399.     register int j;
  400.     register int s = 0;
  401.  
  402.     j = s + 1;
  403.     sa = 2;
  404.     sb = s + 3;
  405.     sx = s + 2;
  406.     sy = s + 5;
  407.     s2 = s + 4;
  408.     asx[1] = s + 1;
  409.     as1[1] = s + 7;
  410.     asy[1] = s + 6;
  411.     as2[1] = s + 8;
  412.     s1 = s + 1;
  413.     
  414.     psx = &sx;
  415.     psb = &sy;
  416.     
  417.     while(n--)
  418.     {
  419.         s1 = sa * sb * sx * sy * (1+(s2 >> 12)) * (*psb) * asx[j] * as1[j] * (1+(s1 >> 12));
  420.         s2 = sa * as2[j] * asy[j] * (*psx) * sy * sx * (1+(s1 >> 12)) * ++s2 * sb;
  421.         s1 = sa * sb * sx * sy * (1+(s2 >> 12)) * (*psb) * asx[j] * as1[j] * (1+(s1 >> 12));
  422.         s2 = sa * as2[j] * asy[j] * (*psx) * sy * sx * (1+(s1 >> 12)) * ++s2 * sb;
  423.     }
  424.     return(s2);
  425. }
  426.  
  427. /* divide short test */
  428.  
  429. divs(n)
  430.     int n;
  431. {
  432.     register short sa,sb,*psa,*psb;
  433.     short sx,sy,asx[32],asy[32],*psx,*psy;
  434.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  435.     register int j;
  436.     register int s = 0;
  437.  
  438.     j = s + 1;
  439.     sa = 32000;
  440.     sb = s + 3;
  441.     sx = s + 2;
  442.     sy = s + 5;
  443.     s2 = s + 4;
  444.     asx[1] = s + 1;
  445.     as1[1] = s + 7;
  446.     asy[1] = s + 6;
  447.     as2[1] = s + 8;
  448.     s1 = s + 1;
  449.     
  450.     psx = &sx;
  451.     psb = &sy;
  452.     
  453.     while(n--)
  454.     {
  455.         s1 = sa / sb / sx / sy / ++s2 / (*psb) / asx[j] / as1[j] / ++s1;
  456.         s2 = sa / as2[j] / asy[j] / (*psx) / sy / sx / ++s1 / ++s2 / sb;
  457.         s1 = sa / sb / sx / sy / ++s2 / (*psb) / asx[j] / as1[j] / ++s1;
  458.         s2 = sa / as2[j] / asy[j] / (*psx) / sy / sx / ++s1 / ++s2 / sb;
  459.     }
  460.     return(s2);
  461. }
  462.  
  463. /* assign short test */
  464.  
  465. asgns(n)
  466.     int n;
  467. {
  468.     register short sa,sb,*psa,*psb;
  469.     short sx,sy,asx[32],asy[32],*psx,*psy;
  470.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  471.     register int j;
  472.     register int s = 0;
  473.  
  474.     j = s + 1;
  475.     sa = s + 5;
  476.     sb = s + 10;
  477.     sy = s + 15;
  478.     sx = s + 19;
  479.     asx[1] = s + 21;
  480.     asy[1] = s + 27;
  481.     s1 = s + 9;
  482.     s2 = s + 17;
  483.     as1[1] = s + 13;
  484.     as2[1] = s + 217;
  485.     
  486.     psx = &sx;
  487.     psb = &sy;
  488.     
  489.     while(n--)
  490.     {
  491.         sa = s2; sx = sa; sy = sx; s2 = sx; s1 = s2;
  492.         sb = s1; sa = sb; sx = sa; sy = sx; sb = sy;
  493.         *psb = sb; sa = *psb; asx[j] = sa; sx = asx[j];
  494.         asy[j] = sx; sb = asy[j]; *psx = sb; s2 = *psx;
  495.         s1 = s2; 
  496.         sb = s1; sa = sb; sx = sa; sy = sx; sb = sy;
  497.         *psb = sb; sa = *psb; asx[j] = sa; sx = asx[j];
  498.         asy[j] = sx; sb = asy[j]; *psx = sb; s2 = *psx;
  499.     }
  500.     return(s2);
  501. }
  502.  
  503. /* compare short test */
  504.  
  505. cmps(n)
  506.     int n;
  507. {
  508.     register short sa,sb,*psa,*psb;
  509.     short sx,sy,asx[32],asy[32],*psx,*psy;
  510.     static short s1,s2,as1[32],as2[32],*ps1,*ps2;
  511.     register int j;
  512.     register int s = 0;
  513.  
  514.     sb = sy =s2 = asy[1] = as2[1] = n - 1;
  515.     j = s + 1;
  516.     
  517.     psx = &sx;
  518.     psa = &sy;
  519.     
  520.     while(n--)
  521.     {
  522.         sa = sx = s1 = asx[1] = as1[1] = n;
  523.         if( sa == sb ) s++;
  524.         if( sa == sb ) s++;
  525.         if( sa == sb ) s++;
  526.         if( sa == sb ) s++;
  527.         if( sa == sb ) s++;
  528.         if( sa == sb ) s++;
  529.         if( sa == sb ) s++;
  530.         if( sx == sy ) s++;
  531.         if( sx == sy ) s++;
  532.         if( sx == sy ) s++;
  533.         if( sx == sy ) s++;
  534.         if( s1 == s2 ) s++;
  535.         if( *psa == *psx ) s++;
  536.         if( asx[j] == as1[j] ) s++;
  537.         sb = sy =s2 = asy[1] = as2[1] = n - 1;
  538.         if( sa != sb ) s++;
  539.         if( sa != sb ) s++;
  540.         if( sx != sy ) s++;
  541.         if( sx != sy ) s++;
  542.         if( asx[j] != asy[j] ) s++;
  543.         if( s1 != s2 ) s++;
  544.         if( sb < sa ) s++;
  545.         if( sb < sa ) s++;
  546.         if( sy < sx ) s++;
  547.         if( sy < sx ) s++;
  548.         if( sa > sb ) s++;
  549.         if( sx > sy ) s++;
  550.         if( sb <= sx ) s++;
  551.         if( sb <= sx ) s++;
  552.         if( sa >= sb ) s++;
  553.         if( sa >= sb ) s++;
  554.         if( sx >= sy ) s++;
  555.         if( sx >= sy ) s++;
  556.     }
  557.     return(s);
  558. }
  559.  
  560.  
  561. /* add long test */
  562.  
  563. addl(n)
  564.     int n;
  565. {
  566.     register int i = 0;
  567.     register long ia,ib,*pia,*pib;
  568.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  569.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  570.     register int j;
  571.  
  572.     j = i + 1;
  573.     ia = i + 5;
  574.     ib = i + 10;
  575.     iy = i + 15;
  576.     ix = i + 19;
  577.     aix[1] = i + 21;
  578.     aiy[1] = i + 27;
  579.     i1 = i;
  580.     i2 = i + 17;
  581.     ai1[1] = i + 13;
  582.     ai2[1] = i + 7;
  583.     
  584.     pix = &ix;
  585.     pib = &iy;
  586.     
  587.     while(n--)
  588.     {
  589.         i1 = i1 + ib + ix + iy + ia + ib + ix + iy + ia + ib + ix + iy
  590.             + ia + ib + ix + iy + ia + ib + ix + iy + ia + ib + i2
  591.             + ia + ia + ib + i2 + (*pib) + aix[j] + aiy[j] + ai1[j]
  592.             + ai2[j] + (*pix);
  593.     }
  594.     return(i1);
  595. }
  596.  
  597. /* substract long test */
  598.  
  599. subl(n)
  600.     int n;
  601. {
  602.     register int i = 0;
  603.     register long ia,ib,*pia,*pib;
  604.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  605.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  606.     register int j;
  607.  
  608.     j = i + 1;
  609.     ia = i + 5;
  610.     ib = i + 10;
  611.     iy = i + 15;
  612.     ix = i + 19;
  613.     aix[1] = i + 21;
  614.     aiy[1] = i + 27;
  615.     i1 = i + 917672934;
  616.     i2 = i + 17;
  617.     ai1[1] = i + 13;
  618.     ai2[1] = i + 7;
  619.     
  620.     pix = &ix;
  621.     pib = &iy;
  622.     
  623.     while(n--)
  624.     {
  625.         i1 = i1 - ib - ix - iy - ia - ib - ix - iy - ia - ib - ix - iy
  626.             - ia - ib - ix - iy - ia - ib - ix - iy - ia - ib - i2
  627.             - ia - ia - ib - i2 - (*pib) - aix[j] - aiy[j] - ai1[j]
  628.             - ai2[j] - (*pix);
  629.     }
  630.     return(i);
  631. }
  632.  
  633. /* multiply long test */
  634.  
  635. mull(n)
  636.     int n;
  637. {
  638.     register int i = 0;
  639.     register long ia,ib,*pia,*pib;
  640.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  641.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  642.     register int j;
  643.  
  644.     j = i + 1;
  645.     ia = 2;
  646.     ib = i + 3;
  647.     ix = i + 2;
  648.     iy = i + 5;
  649.     i2 = i + 4;
  650.     aix[1] = i + 1;
  651.     ai1[1] = i + 7;
  652.     aiy[1] = i + 6;
  653.     ai2[1] = i + 8;
  654.     i1 = i + 1;
  655.     
  656.     pix = &ix;
  657.     pib = &iy;
  658.     
  659.     while(n--)
  660.     {
  661.         i1 = ia * ib * ix * iy * (1+(i2 >> 12)) * (*pib) * aix[j] * ai1[j] * (1+(i1 >> 12 ));
  662.         i2 = ia * ai2[j] * aiy[j] * (*pix) * iy * ix * (1+(i1 >> 12)) * (1+(i2 >> 12)) * ib;
  663.         i1 = ia * ib * ix * iy * (1+(i2 >> 12)) * (*pib) * aix[j] * ai1[j] * (1+(i1 >> 12 ));
  664.         i2 = ia * ai2[j] * aiy[j] * (*pix) * iy * ix * (1+(i1 >> 12)) * (1+(i2 >> 12)) * ib;
  665.     }
  666.     return(i2);
  667. }
  668.  
  669. /* divide long test */
  670.  
  671. divl(n)
  672.     int n;
  673. {
  674.     register int i = 0;
  675.     register long ia,ib,*pia,*pib;
  676.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  677.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  678.     register int j;
  679.  
  680.     j = i + 1;
  681.     ia = 2072397218;
  682.     ib = i + 3;
  683.     ix = i + 2;
  684.     iy = i + 5;
  685.     i2 = i + 4;
  686.     aix[1] = i + 1;
  687.     ai1[1] = i + 7;
  688.     aiy[1] = i + 6;
  689.     ai2[1] = i + 8;
  690.     i1 = i + 1;
  691.     
  692.     pix = &ix;
  693.     pib = &iy;
  694.     
  695.     while(n--)
  696.     {
  697.         i1 = ia / ib / ix / iy / ++i2 / (*pib) / aix[j] / ai1[j] / ++i1;
  698.         i2 = ia / ai2[j] / aiy[j] / (*pix) / iy / ix / ++i1 / ++i2 / ib;
  699.         i1 = ia / ib / ix / iy / ++i2 / (*pib) / aix[j] / ai1[j] / ++i1;
  700.         i2 = ia / ai2[j] / aiy[j] / (*pix) / iy / ix / ++i1 / ++i2 / ib;
  701.     }
  702.     return(i2);
  703. }
  704.  
  705. /* assign long test */
  706.  
  707. asgnl(n)
  708.     int n;
  709. {
  710.     register int i = 0;
  711.     register long ia,ib,*pia,*pib;
  712.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  713.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  714.     register int j;
  715.  
  716.     j = i + 1;
  717.     ia = i + 5;
  718.     ib = i + 10;
  719.     iy = i + 15;
  720.     ix = i + 19;
  721.     aix[1] = i + 21;
  722.     aiy[1] = i + 27;
  723.     i1 = i + 9;
  724.     i2 = i + 17;
  725.     ai1[1] = i + 13;
  726.     ai2[1] = i + 217;
  727.     
  728.     pix = &ix;
  729.     pib = &iy;
  730.     
  731.     while(n--)
  732.     {
  733.         ia = i2; ix = ia; iy = ix; i2 = ix; i1 = i2;
  734.         ib = i1; ia = ib; ix = ia; iy = ix; ib = iy;
  735.         *pib = ib; ia = *pib; aix[j] = ia; ix = aix[j];
  736.         aiy[j] = ix; ib = aiy[j]; *pix = ib; i2 = *pix;
  737.         i1 = i2; 
  738.         ib = i1; ia = ib; ix = ia; iy = ix; ib = iy;
  739.         *pib = ib; ia = *pib; aix[j] = ia; ix = aix[j];
  740.         aiy[j] = ix; ib = aiy[j]; *pix = ib; i2 = *pix;
  741.     }
  742.     return(i2);
  743. }
  744.  
  745. /* compare long test */
  746.  
  747. cmpl(n)
  748.     int n;
  749. {
  750.     register int i = 0;
  751.     register long ia,ib,*pia,*pib;
  752.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  753.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  754.     register int j;
  755.  
  756.     ib = iy =i2 = aiy[1] = ai2[1] = n - 1;
  757.     j = i + 1;
  758.     
  759.     pix = &ix;
  760.     pia = &iy;
  761.     
  762.     while(n--)
  763.     {
  764.         ia = ix = i1 = aix[1] = ai1[1] = n;
  765.         if( ia == ib ) i++;
  766.         if( ia == ib ) i++;
  767.         if( ia == ib ) i++;
  768.         if( ia == ib ) i++;
  769.         if( ia == ib ) i++;
  770.         if( ia == ib ) i++;
  771.         if( ia == ib ) i++;
  772.         if( ix == iy ) i++;
  773.         if( ix == iy ) i++;
  774.         if( ix == iy ) i++;
  775.         if( ix == iy ) i++;
  776.         if( i1 == i2 ) i++;
  777.         if( *pia == *pix ) i++;
  778.         if( aix[j] == ai1[j] ) i++;
  779.         ib = iy =i2 = aiy[1] = ai2[1] = n - 1;
  780.         if( ia != ib ) i++;
  781.         if( ia != ib ) i++;
  782.         if( ix != iy ) i++;
  783.         if( ix != iy ) i++;
  784.         if( aix[j] != aiy[j] ) i++;
  785.         if( i1 != i2 ) i++;
  786.         if( ib < ia ) i++;
  787.         if( ib < ia ) i++;
  788.         if( iy < ix ) i++;
  789.         if( iy < ix ) i++;
  790.         if( ia > ib ) i++;
  791.         if( ix > iy ) i++;
  792.         if( ib <= ix ) i++;
  793.         if( ib <= ix ) i++;
  794.         if( ia >= ib ) i++;
  795.         if( ia >= ib ) i++;
  796.         if( ix >= iy ) i++;
  797.         if( ix >= iy ) i++;
  798.     }
  799.     return(i);
  800. }
  801.  
  802. /* bit long test */
  803.  
  804. bitl(n)
  805.     int n;
  806. {
  807.     register int i;
  808.     register long ia,ib,*pia,*pib;
  809.     long ix,iy,aix[32],aiy[32],*pix,*piy;
  810.     static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
  811.     register int j = 1;
  812.  
  813.     i = j + 7;
  814.     ia = i + 5;
  815.     ib = i + 10;
  816.     iy = i + 15;
  817.     ix = i + 19;
  818.     aix[1] = i + 21;
  819.     aiy[1] = i + 27;
  820.     i1 = i + 9;
  821.     i2 = i + 17;
  822.     ai1[1] = i + 13;
  823.     ai2[1] = i + 217;
  824.     
  825.     pix = pia = pi1 = &ix;
  826.     piy = pib = pi2 = &iy;
  827.     
  828.     while(n--)
  829.     {
  830.         i = 2;
  831.         while(i--)
  832.             i1 = ia & ib | (ix >> 1) & (~iy) | (i1 << 2) & i2 |
  833.                 (*pia) & (*pib) | aix[j] | aiy[j] |
  834.                 *pix | *piy | (~(*pix));
  835.     }
  836.     return(i1);
  837. }
  838.  
  839. /* logical and or not test */
  840.  
  841. logical(n)
  842.     int n;
  843. {
  844.     register int i = 0;
  845.     register long ia,ib;
  846.     long ix,iy;
  847.     static long i1,i2;
  848.     
  849.     i1 = ib =ix =iy = i + 1;
  850.     i2 = ia = ++i;
  851.     while(n--)
  852.     {
  853.         i = 2;
  854.         while(i--)
  855.         i1 = ia && ib || ix && iy || ia && ib ||
  856.             (!i1) && (!i2) || ix && iy || ia && ix
  857.             && iy && (!i1);
  858.     }
  859.     return(i1);
  860. }
  861.  
  862. /* character assign test */
  863.  
  864. asgnc(n)
  865.     int n;
  866. {
  867.     register int i = 0;
  868.     register char ca,cb,*pca,*pcb;
  869.     char cx,cy,acx[32],acy[32],*pcx,*pcy;
  870.     static char ac1[32],ac2[32],*pc1,*pc2;
  871.     static char c1 = 'a';
  872.     static char c2 = 'b';
  873.     register int j;
  874.  
  875.     pca = pcx = pc1 = &c1;
  876.     pcb = pcy = pc2 = &c2;
  877.     ca = acx[1] = ac1[1] = c2;
  878.     cb = acy[1] = ac2[1] = c1;
  879.     j = i + 1;
  880.     
  881.     while(n--)
  882.     {
  883.         *pca = c1; *pcb = *pca; *pcx = *pcb; *pcy = *pcx;
  884.         *pc1 = *pcy; *pc2 = *pc1; acx[j] = *pc2; acy[j] = acx[j];
  885.         ac1[j] = acy[j]; ac2[j] = ac1[j]; ca = ac2[j]; cb = ca;
  886.         cx = cb; cy = cx; *pca = cy; *pcb = *pca; *pcx = *pcb;
  887.         *pcy = *pcx; *pc1 = *pcy; acx[j] = *pc1; acy[j] = acx[j];
  888.         ac1[j] = acy[j]; ac2[j] = ac1[j];
  889.         *pcx = ac2[j]; *pcb = *pcx;
  890.         acx[j] = *pcb; acy[j] = acx[j]; *pca = acy[j]; *pcb = *pca;
  891.         ca = *pcb; *pca = ca; c1 = *pca;
  892.     }
  893.     return((int)c1);
  894. }
  895.  
  896. /* character compare test */
  897.  
  898. cmpc(n)
  899.     int n;
  900. {
  901.     register int i = 0;
  902.     register char ca,cb,*pca,*pcb;
  903.     char cx,cy,acx[32],acy[32],*pcx,*pcy;
  904.     static char ac1[32],ac2[32],*pc1,*pc2;
  905.     static char c1 = 'a';
  906.     static char c2 = 'a';
  907.     register int j;
  908.  
  909.     j = i + 1;
  910.     pca = pcx = pc1 = &c1;
  911.     pcb = pcy = pc2 = &c2;
  912.     cb = acy[1] = ac2[1] = c1;
  913.     
  914.     while(n--)
  915.     {
  916.         ca = acx[1] = ac1[1] = c1 = c2;
  917.         if( ca == cb ) i++;
  918.         if( cx == cy ) i++;
  919.         if( acx[j] == acy[j] ) i++;
  920.         if( acx[j] == acy[j] ) i++;
  921.         if( acx[j] == acy[j] ) i++;
  922.         if( ac1[j] == ac2[j] ) i++;
  923.         if( ac1[j] == ac2[j] ) i++;
  924.         if( *pca == *pcb ) i++;
  925.         if( *pca == *pcb ) i++;
  926.         if( *pca == *pcb ) i++;
  927.         if( *pca == *pcb ) i++;
  928.         if( *pcx == *pcy ) i++;
  929.         if( *pcx == *pcy ) i++;
  930.         ca = acx[1] = ac1[1] = c1 = 'b';
  931.         if( ca != cb ) i++;
  932.         if( acx[j] != acy[j] ) i++;
  933.         if( ac1[j] != ac2[j] ) i++;
  934.         if( *pca != *pcb ) i++;
  935.         if( *pca != *pcb ) i++;
  936.         if( *pcx != *pcy ) i++;
  937.         if( cb < ca ) i++;
  938.         if( ac2[j] < ac1[j] ) i++;
  939.         if( *pcb < *pca ) i++;
  940.         if( *pcy < *pcx ) i++;
  941.         if( acx[j] > ac2[j] ) i++;
  942.         if( *pca > *pcb ) i++;
  943.         if( *pcb <= *pcx ) i++;
  944.         if( acx[j] >= acy[j] ) i++;
  945.         if( *pca >= *pcb ) i++;
  946.         if( *pca > *pc2 ) i++;
  947.         if( *pcx >= *pcb ) i++;
  948.     }
  949.     return(i);
  950. }
  951.  
  952. /* character bit test */
  953.  
  954. bitc(n)
  955.     int n;
  956. {
  957.     register int i;
  958.     register char ca,cb,*pca,*pcb;
  959.     char cx,cy,acx[32],acy[32],*pcx,*pcy;
  960.     static char ac1[32],ac2[32],*pc1,*pc2;
  961.     static char c1 = 'A';
  962.     static char c2 = 'B';
  963.     register int j = 1;
  964.  
  965.     pca = pcx = pc1 = &c1;
  966.     pcb = pcy = pc2 = &c2;
  967.     ca = cx = acx[1] = ac1[1] = c1;
  968.     cb = cy = acy[1] = ac2[1] = c2;
  969.     c2 = ca;
  970.     
  971.     while(n--)
  972.     {
  973.         c1 = ca & cb & cx
  974.             & acx[j] & acy[j] & cy
  975.             & *pca & *pcb & *pcx
  976.             & *pcy & *pc1 & *pc2
  977.             | ca | cb
  978.             | cx | cy | acx[j]
  979.             | acy[j] | ac1[j] | ac2[j]
  980.             | *pca | *pcb | *pcx
  981.             | *pcy | *pc1 | *pc2
  982.             | (ca << 1) | (cb >> 2) | ~c2
  983.             | c1 ;
  984.     }
  985.     return((int)c1);
  986. }
  987.  
  988. /* function call no parameters */
  989.  
  990. funct0(n)
  991.     int n;
  992. {
  993.     register int  i,j;
  994.  
  995.     j = 0;
  996.     while (n--)
  997.     {
  998.         i = 2;
  999.         while(i--)
  1000.         {
  1001.               j += func0( ); j += func0( ); j += func0( ); j += func0( );
  1002.               j += func0( ); j += func0( ); j += func0( ); j += func0( );
  1003.               j += func0( ); j += func0( ); j += func0( ); j += func0( );
  1004.               j += func0( ); j += func0( ); j += func0( ); j += func0( );
  1005.         }
  1006.     }
  1007.     return(j);
  1008. }
  1009. func0()
  1010. {
  1011.     static int j = 0;
  1012.     return(++j);
  1013. }
  1014.  
  1015. /* function call one parameter test */
  1016.  
  1017. funct1(n)
  1018.     int n;
  1019. {
  1020.     register int  i,j;
  1021.  
  1022.     j = 0;
  1023.     while (n--)
  1024.     {
  1025.         i = 2;
  1026.         while(i--)
  1027.         {
  1028.               j += func1(n); j += func1(n); j += func1(n); j += func1(n);
  1029.               j += func1(n); j += func1(n); j += func1(n); j += func1(n);
  1030.               j += func1(n); j += func1(n); j += func1(n); j += func1(n);
  1031.               j += func1(n); j += func1(n); j += func1(n); j += func1(n);
  1032.         }
  1033.     }
  1034.     return(j);
  1035. }
  1036. func1(n)
  1037.     int n;
  1038. {
  1039.     return(++n);
  1040. }
  1041.  
  1042. /* function call two prameters test */
  1043.  
  1044. funct2(n)
  1045.     int n;
  1046. {
  1047.     register int  i,j;
  1048.  
  1049.     j = 0;
  1050.     while (n--)
  1051.     {
  1052.         i = 2;
  1053.         while(i--)
  1054.         {
  1055.               j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
  1056.               j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
  1057.               j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
  1058.               j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
  1059.         }
  1060.     }
  1061.     return(j);
  1062. }
  1063. func2(i,j)
  1064.     int i,j;
  1065. {
  1066.     return(i+j);
  1067. }
  1068.  
  1069.  
  1070. /* fork test */
  1071.  
  1072. sys1(n)
  1073.     int n;
  1074. {
  1075.     register int c;
  1076.     int status;
  1077.     
  1078.     while(n--)
  1079.     {
  1080.         c = fork( );
  1081.         if( c == 0 )
  1082.             _exit(0);
  1083.         if( c < 0 )
  1084.         {
  1085.             printf("unable to perform fork\n");
  1086.             return;
  1087.         }
  1088.         if( c != wait(&status) )
  1089.         {
  1090.             printf("wait does not return the correct child process id\n");
  1091.             return;
  1092.         }
  1093.     }
  1094. }
  1095.  
  1096. /* getpid test */
  1097.  
  1098. sys3(n)
  1099.     int n;
  1100. {
  1101.     register int i;
  1102.     while(n--)
  1103.         i = getpid( );
  1104.     return(i);
  1105. }
  1106.  
  1107. /* sbrk test */
  1108.     
  1109. sys4(n)
  1110.     int n;
  1111. {
  1112.     register int i;
  1113.     while(n--)
  1114.         i = sbrk(0);
  1115.     return(i);
  1116. }
  1117. sys5(n)
  1118.     int n;
  1119. {
  1120.     register int i;
  1121.     while(n--)
  1122.         i = umask(0);
  1123.     return(i);
  1124. }
  1125. static long start,end;
  1126. static double stime,ltime,factor;
  1127. static double ddelta,dstep,ddcnt;
  1128. static double tdelta,tstep,ttcnt;
  1129. static int nd,nt,nl,dd,td,i,ddcount,ttcount,lflag;
  1130. struct teststru
  1131. {
  1132.     int nops;
  1133.     int (*funcall)( );
  1134. };
  1135. static struct teststru test[NOTEST] =
  1136. {
  1137.     117,adds,
  1138.     93,subs,
  1139.     11,muls,
  1140.     5,divs,
  1141.     189,asgns,
  1142.     141,cmps,
  1143.     949,addl,
  1144.     751,subl,
  1145.     91,mull,
  1146.     43,divl,
  1147.     1521,asgnl,
  1148.     1135,cmpl,
  1149.     689,bitl,
  1150.     465,logical,
  1151.     878,asgnc,
  1152.     655,cmpc,
  1153.     354,bitc,
  1154.     593,funct0,
  1155.     976,funct1,
  1156.     344,funct2,
  1157.     1,sys3,
  1158.     1,sys4,
  1159.     1,sys5
  1160. };
  1161. main( )
  1162. {
  1163.     static char machine[100],s[100];
  1164.     static int noproc;
  1165.     static int nomp,novol;
  1166.     {
  1167.     register int j,n,i;
  1168.  
  1169.     if( (stream = fopen("config","r")) == NULL )
  1170.     {
  1171.         printf("unable to open file config\n");
  1172.         exit(0);
  1173.     }
  1174.     i = 1;
  1175.     while( i <=3 )
  1176.     {
  1177.         if( fgets(s,100,stream) == NULL )
  1178.         {
  1179.             printf("comfig file is empty\n");
  1180.             exit(1);
  1181.         }
  1182.         if( s[0] == '#' ) continue;
  1183.         switch(i)
  1184.         {
  1185.         case 1:
  1186.             sscanf(s,"%d",&nomp);
  1187.             break;
  1188.         case 2:
  1189.             sscanf(s,"%d",&noproc);
  1190.             break;
  1191.         case 3:
  1192.             sscanf(s,"%d",&novol);
  1193.             break;
  1194.         }
  1195.         i++;
  1196.     }
  1197.     fclose(stream);
  1198.     readmac:
  1199.     printf("ENTER THE NAME OR DESCRIPTION OF THIS MACHINE (5 TO 40 CHARTERS)\n$");
  1200.     gets(machine);
  1201.     if( (strlen(machine) < 5)  || (strlen(machine) > 40) )
  1202.     {
  1203.         printf("THE MACHINE NAME OR DESCRIPTION HAS AN INCORRECT LENGTH\n");
  1204.         goto readmac;
  1205.     }
  1206.     if( (stream = fopen("answers","w")) == NULL )
  1207.     {
  1208.         printf("unable to open file answers\n");
  1209.         exit(1);
  1210.     }
  1211.     fprintf(stream,"%s\n",machine);
  1212.     fprintf(stream,"%d\n",noproc);
  1213.     fclose(stream);
  1214.     ptime(1);
  1215.     start = ptime(1);
  1216.     for(j=0; j<NOTEST; j++)
  1217.     {
  1218.         n = test[j].nops;
  1219.         (*test[j].funcall)(n);
  1220.     }
  1221.     end = ptime(1);
  1222.     stime = (double)(end - start) / 60.0;
  1223.     if( (stream = fopen("crunout","w")) == NULL )
  1224.     {
  1225.         printf("unable to open file crunout\n");
  1226.         exit(1);
  1227.     }
  1228.     fprintf(stream,"%s\n",machine);
  1229.     fprintf(stream,"TESTTIME = %9.5f\n",stime);
  1230.     }
  1231.     {
  1232.     register int dc,tc,i;
  1233.     nl = 1000;
  1234.     nt = 30;
  1235.     nd = 32;
  1236.     lflag = 1;
  1237.     loop:
  1238.     dc = 1;
  1239.     tc = 1;
  1240.     ddcount = 0;
  1241.     ttcount = 0;
  1242.     dstep = 0.0;
  1243.     ddelta = (double)nd / (double)nl;
  1244.     tstep = 0.0;
  1245.     tdelta = (double)nt / (double)nl;
  1246.     factor = 2.100;
  1247.     nl++;
  1248.     start = ptime(1);
  1249.     for(i=1; i<=nl; i++)
  1250.     {
  1251.         dstep += ddelta;
  1252.         ddcnt = (double)dc;
  1253.         if( dstep >= ddcnt )
  1254.         {
  1255.             dc++;
  1256.         }
  1257.         tstep += tdelta;
  1258.         ttcnt = (double)tc;
  1259.         if( tstep >= ttcnt )
  1260.         {
  1261.             tc++;
  1262.         }
  1263.     }
  1264.     end = ptime(1);
  1265.     ltime = (double)(end - start) / 60.0;
  1266.     fprintf(stream,"nl = %d   ",nl);
  1267.     fprintf(stream,"ltime = %9.5f  dcount = %d   tcount = %d\n",ltime,dc,tc);
  1268.     if( lflag )
  1269.     {
  1270.         nl = (int)( (double)nl * (stime / (ltime * factor) ) );
  1271.         lflag = 0;
  1272.         goto loop;
  1273.     }
  1274.     fclose(stream);
  1275.     if( (stream = fopen("loopcount","w")) == NULL )
  1276.     {
  1277.         printf("unable to open file loopcount\n");
  1278.         exit(1);
  1279.     }
  1280.     fprintf(stream,"%d\n",nl);
  1281.     fclose(stream);
  1282.     if( (stream = fopen("subele","a")) == NULL )
  1283.     {
  1284.         printf("unable to open file subele\n");
  1285.         exit(1);
  1286.     }
  1287.     fprintf(stream,"\f\n\n");
  1288.     fprintf(stream," S Y S T E M   U N D E R   T E S T   %s\n\n\n",machine);
  1289.     fprintf(stream,"\n  C P U   S U B S Y S T E M \n");
  1290.     fprintf(stream," Time to Execute CRUN %9.3f\n",stime);
  1291.     fprintf(stream," Realative speed of a Single CPU  %9.3f\n", factor / stime );
  1292.     fprintf(stream," Number of Main CPU Processors %d\n",nomp);
  1293.     fclose(stream);
  1294.     }
  1295.     if( nomp > 1 )
  1296.     {
  1297.         if( execl("cpurun","cpurun",NULL) < 0 )
  1298.         {
  1299.             printf(" unable to execute cpurun \n");
  1300.         }
  1301.     }
  1302.     exit(0);
  1303. }
  1304.  
  1305. long
  1306. ptime(tflag)
  1307.     int tflag;
  1308. {
  1309.     static long tm[4];
  1310.     static int first = 1;
  1311.     static long tstart = 0;
  1312.     static long xtime = 0;
  1313.     long times( );
  1314.  
  1315.     if( tflag && first )
  1316.     {
  1317.         tstart = times(tm);
  1318.         first = 0;
  1319.         return(0);
  1320.     }
  1321.     xtime = times(tm);
  1322.     if( tflag )
  1323.     {
  1324.         xtime = xtime - tstart;
  1325.     }
  1326.     else
  1327.     {
  1328.         xtime = tm[0];
  1329.     }
  1330.     return(xtime);
  1331. }
  1332.  
  1333. SHAR_EOF
  1334. fi
  1335. if test -f 'drun.c'
  1336. then
  1337.     echo shar: "will not over-write existing file 'drun.c'"
  1338. else
  1339. cat << \SHAR_EOF > 'drun.c'
  1340. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  1341.  
  1342. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  1343. #include "sys/types.h"
  1344. #include "sys/times.h"
  1345. #include "stdio.h"
  1346. #define MAXPROC 64
  1347.  
  1348. #define NULL 0
  1349.  
  1350.  
  1351. static int diskrfd,diskwfd,toggle;
  1352. static double timex;
  1353.  
  1354.  
  1355. static int noproc,maxjobs;
  1356. static int nomp;
  1357. static int count,itotal,status;
  1358. static int pid,cid,tagid;
  1359. static double stime;
  1360. static char s[100];
  1361. static int tablepid[MAXPROC];
  1362. static int notty,nodiskw,nodiskr,nouser;
  1363. static double jobs;
  1364. static long start,end,ftime;
  1365.  
  1366.  
  1367. FILE * stream;
  1368. static char line[32],buffer[1024],pbuffer[32],bufin[1024];
  1369. static char namev[8][80];
  1370. static float pcnt[8],sum;
  1371. static int novol,fsum,nfile[8],lng,len[8];
  1372. static int total,ll[8],hl[8],cnt[8],vol,disk[200];
  1373. static int dist,sdist[8],oldf[8];
  1374. static int file1[200] =
  1375. {
  1376.     38,113,51,10,12,149,84,25,89,137,
  1377.     166,95,167,31,82,124,194,52,154,161,
  1378.     28,85,168,165,162,153,44,163,22,57,
  1379.     79,151,70,48,29,6,138,14,116,181,
  1380.     143,33,160,71,136,164,129,75,114,88,
  1381.     2,34,182,186,106,53,73,193,148,120,
  1382.     156,169,195,191,126,86,11,54,121,39,
  1383.     185,125,15,176,144,19,123,65,173,13,
  1384.     99,16,127,46,139,78,74,171,152,192,
  1385.     122,128,170,41,175,172,145,115,61,45,
  1386.     103,72,100,7,130,142,131,155,94,47,
  1387.     80,146,92,90,32,132,17,49,189,196,
  1388.     96,174,93,179,50,197,133,81,177,178,
  1389.     62,134,55,108,83,101,18,135,30,105,
  1390.     140,35,188,36,119,198,109,77,111,76,
  1391.     150,190,157,87,37,147,43,199,180,117,
  1392.     141,158,9,97,0,183,91,98,104,40,
  1393.     20,159,63,184,187,102,1,3,64,4,
  1394.     5,8,107,21,110,58,56,59,23,68,
  1395.     24,60,26,112,27,66,42,118,67,69
  1396. };
  1397. static int file2[200] =
  1398. {
  1399.     158,115,27,19,86,167,60,143,183,166,
  1400.     178,111,54,145,136,105,102,67,53,96,
  1401.     188,144,6,3,34,120,4,118,127,146,
  1402.     184,94,59,157,106,190,116,62,25,134,
  1403.     22,137,179,1,61,5,44,93,139,121,
  1404.     171,117,15,55,174,48,35,110,10,49,
  1405.     162,197,112,199,107,182,0,165,180,7,
  1406.     75,65,71,97,98,87,149,56,101,159,
  1407.     68,198,113,168,189,26,187,17,191,83,
  1408.     147,185,160,176,181,85,89,114,28,99,
  1409.     70,129,100,8,57,74,23,24,16,76,
  1410.     169,177,51,163,33,108,77,148,175,192,
  1411.     135,40,36,92,193,69,194,103,186,80,
  1412.     195,196,37,63,2,9,29,109,11,12,
  1413.     78,13,42,14,142,18,119,82,20,72,
  1414.     79,138,164,30,132,156,81,21,161,31,
  1415.     32,38,39,41,64,84,104,43,122,45,
  1416.     66,150,130,46,125,47,50,52,123,126,
  1417.     88,58,170,73,90,91,131,95,124,128,
  1418.     133,140,141,151,152,153,154,155,172,173
  1419. };
  1420.  
  1421. /* disk open */
  1422.  
  1423. dkopen(n)
  1424.     int n;
  1425. {
  1426.     register int d,f1,f2,lng;
  1427.  
  1428.     d = disk[n];
  1429.     f1 = file1[n];
  1430.     f2 = file2[n];
  1431.     lng = len[d];
  1432.  
  1433.     sprintf(&namev[d][lng],"%03d",f1);
  1434.     if( (diskrfd = open(&namev[d][0],0)) < 0 )
  1435.     {
  1436.         printf("can not open %s for disk read\n",&namev[d][0]);
  1437.         return;
  1438.     }
  1439.     sprintf(&namev[d][lng],"%03d",f2);
  1440.     if( (diskwfd = open(&namev[d][0],1)) < 0 )
  1441.     {
  1442.         printf("can not open %$ for disk write\n",&namev[d][0]);
  1443.         return;
  1444.     }
  1445.     return;
  1446. }
  1447. main(argc,argv)
  1448.     int argc;
  1449.     char * argv[ ];
  1450. {
  1451.     register int i,j,k;
  1452.  
  1453.     if( argc != 3 )
  1454.     {
  1455.         printf("incorrect number of arguments for run\n");
  1456.         exit(1);
  1457.     }
  1458.     for(k=0; k<1024; k++)
  1459.     {
  1460.         buffer[k] = 'A';
  1461.     }
  1462.     if( (stream = fopen("config","r")) == NULL )
  1463.     {
  1464.         printf("unable to open file config\n");
  1465.         exit(1);
  1466.     }
  1467.     i = 1;
  1468.     while( i <=3 )
  1469.     {
  1470.         if( fgets(s,100,stream) == NULL )
  1471.         {
  1472.             printf("comfig file is empty\n");
  1473.             exit(1);
  1474.         }
  1475.         if( s[0] == '#' ) continue;
  1476.         switch(i)
  1477.         {
  1478.         case 1:
  1479.             sscanf(s,"%d",&nomp);
  1480.             break;
  1481.         case 2:
  1482.             sscanf(s,"%d",&noproc);
  1483.             break;
  1484.         case 3:
  1485.             sscanf(s,"%d",&novol);
  1486.             break;
  1487.         }
  1488.         i++;
  1489.     }
  1490.     sum = 0.0;
  1491.     for(i=0; i<novol; i++)
  1492.     {
  1493.         lab2:
  1494.         if( fgets(s,100,stream) == NULL)
  1495.         {
  1496.             printf("not enough disk volume names\n");
  1497.             exit(1);
  1498.         }
  1499.         if( s[0] == '#' ) goto lab2;
  1500.         sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
  1501.         sum += pcnt[i];
  1502.     }
  1503.     fclose(stream);
  1504.     sscanf(argv[1],"%d",¬ty);
  1505.     sscanf(argv[2],"%d",&nodiskr);
  1506.     maxjobs = 200;
  1507.     fsum = 0;
  1508.     for(i=0; i<novol; i++)
  1509.     {
  1510.         nfile[i] = (int)( ( (pcnt[i] * 200.0) / sum ) );
  1511.         fsum += nfile[i];
  1512.     }
  1513.     for(i=0; i<novol; i++)
  1514.     {
  1515.         if( fsum < 200 )
  1516.         {
  1517.             nfile[i]++;
  1518.             fsum++;
  1519.         }
  1520.         else
  1521.         {
  1522.             break;
  1523.         }
  1524.     }
  1525.     for(i=0; i<novol; i++)
  1526.     {
  1527.         lng = strlen(&namev[i][0]);
  1528.         if( namev[i][lng-1] != '/')
  1529.         {
  1530.             namev[i][lng++] = '/';
  1531.         }
  1532.         namev[i][lng++] = 'd';
  1533.         namev[i][lng++] = 'k';
  1534.         len[i] = lng;
  1535.         namev[i][lng+3] = '\0';
  1536.         sprintf(&namev[i][len[i]],"%03d",i);
  1537.     }
  1538.     total = 0;
  1539.     for(i=0; i<novol; i++)
  1540.     {
  1541.         cnt[i] = 0;
  1542.         oldf[i] = 0;
  1543.         sdist[i] = 0;
  1544.         ll[i] = total;
  1545.         total += nfile[i];
  1546.         hl[i] = total - 1;
  1547.     }
  1548.     for(j=0; j<200; j++)
  1549.     {
  1550.         k = rand( ) % 200;
  1551.         for(i=0; i<novol; i++)
  1552.         {
  1553.             if( (k>=ll[i]) && (k<=hl[i]) )
  1554.             {
  1555.                 vol = i;
  1556.                 break;
  1557.             }
  1558.         }
  1559.         disk[j] = vol;
  1560.     }
  1561.     ptime(1);
  1562.     count = 0;
  1563.     itotal = 0;
  1564.     for(i=1; i<=noproc; i++)
  1565.     {
  1566.         tablepid[i] = 0;
  1567.     }
  1568.     start = ptime(1);
  1569.     i = -1;
  1570.     while( 1 )
  1571.     {
  1572.         i++;
  1573.         tagid = getid( );
  1574.         if( ( pid = fork( ) ) == 0 )
  1575.         {
  1576.             if( nodiskr )
  1577.                 dkopen(i);
  1578.             toggle = 1;
  1579.             for(i=1; i<=nodiskr; i++)
  1580.             {
  1581.                 if( toggle )
  1582.                 {
  1583.                     if( read(diskrfd,bufin,sizeof bufin)
  1584.                         != sizeof bufin )
  1585.                     {
  1586.                         printf("can not read %s on disk read\n",&namev[disk[i]][0]);
  1587.                         exit(1);
  1588.                     }
  1589.                     toggle = 0;
  1590.                 }
  1591.                 else
  1592.                 {
  1593.                     if( write(diskwfd,buffer,sizeof buffer)
  1594.                         != sizeof buffer )
  1595.                     {
  1596.                         printf("can not write %s on on disk write\n",&namev[disk[i]][0]);
  1597.                         exit(1);
  1598.                     }
  1599.                     toggle = 1;
  1600.                 }
  1601.             }
  1602.             if( nodiskr )
  1603.             {
  1604.                 close(diskrfd);
  1605.                 close(diskwfd);
  1606.             }
  1607.             exit(0);
  1608.         }
  1609.         if( pid > 0 )
  1610.         {
  1611.             insert(pid);
  1612.             count++;
  1613.         }
  1614.         else
  1615.         {
  1616.             printf(" can not fork child process\n");
  1617.             exit(1);
  1618.         }
  1619.         if( count == noproc )
  1620.         {
  1621.             cid = wait(&status);
  1622.             count--;
  1623.             freeit(cid);
  1624.             if( ++itotal >= (maxjobs + 1 - noproc) )
  1625.             {
  1626.                 while( count > 0 )
  1627.                 {
  1628.                     cid = wait(&status);
  1629.                     count--;
  1630.                     itotal++;
  1631.                     freeit(cid);
  1632.                 }
  1633.                 goto ENDIT;
  1634.             }
  1635.         }
  1636.     }
  1637.     ENDIT:
  1638.     end = ptime(1);
  1639.     if( (stream = fopen("answers","a")) == NULL )
  1640.     {
  1641.         printf("unable to open file answers\n");
  1642.         exit(1);
  1643.     }
  1644.     ftime = end - start;
  1645.     timex = ( (double)ftime ) / 1000.0;
  1646.     jobs = ((double)maxjobs * 60.0) / timex;
  1647.     fprintf(stream,"%3d %3d %9.3f %9.3f\n",
  1648.         1000,nodiskr,jobs,timex);
  1649.     fclose(stream);
  1650.     if( notty )
  1651.     {
  1652.         if( (stream = fopen("subele","a")) == NULL )
  1653.         {
  1654.             printf("unable to open file subele\n");
  1655.             exit(1);
  1656.         }
  1657.         fprintf(stream,"\n  D I S K   S U B S Y S T E M \n");
  1658.         fprintf(stream," Effective Disk System rate %9.4f K bytes per Second\n",
  1659.                 (double)(nodiskr * maxjobs) / timex);
  1660.         fprintf(stream," Average Time per Disk Request  %9.5f Seconds\n",
  1661.                 timex / ( (double) (nodiskr * maxjobs) ) );
  1662.         fprintf(stream," Total Disk Request  %d",nodiskr * maxjobs);
  1663.         fprintf(stream," Request Size  %d  K bytes\n",1);
  1664.         fprintf(stream," Time for All Disk Request  %9.3f Seconds\n",timex);
  1665.         fprintf(stream," Number of Disk Units %d\n",novol);
  1666.         for(i=0; i<novol; i++)
  1667.         {
  1668.             fprintf(stream," Disk Unit %d Percent %9.3f\n",i+1,pcnt[i]);
  1669.         }
  1670.         fprintf(stream," Disk Request per Job  %d\n",nodiskr);
  1671.         fprintf(stream," Jobs per Minute  %9.3f\n",jobs);
  1672.         fclose(stream);
  1673.     }
  1674.     exit(0);
  1675. }
  1676.  
  1677. long
  1678. ptime(tflag)
  1679.     int tflag;
  1680. {
  1681.     static long tm[4];
  1682.     static int first = 1;
  1683.     static long tstart = 0;
  1684.     static long xtime = 0;
  1685.     long times( );
  1686.     register int i;
  1687.  
  1688.     if( tflag && first )
  1689.     {
  1690.         tstart = times(tm);
  1691.         first = 0;
  1692.         return(0);
  1693.     }
  1694.     xtime = times(tm);
  1695.     if( tflag )
  1696.     {
  1697.         xtime = (1000 * (xtime - tstart)) / 60;
  1698.     }
  1699.     else
  1700.     {
  1701.         xtime = (1000 * tm[0] ) / 60;
  1702.     }
  1703.     return(xtime);
  1704. }
  1705.  
  1706. insert(pid)
  1707.     int pid;
  1708. {
  1709.     register int j;
  1710.  
  1711.     for(j=1; j<=noproc; j++)
  1712.     {
  1713.         if( tablepid[j] == 0 )
  1714.         {
  1715.             tablepid[j] = pid;
  1716.             return(pid);
  1717.         }
  1718.     }
  1719.     printf("no free space on insert pid\N");
  1720.     return(0);
  1721. }
  1722.  
  1723. freeit(pid)
  1724.     int pid;
  1725. {
  1726.     register int j;
  1727.  
  1728.     for(j=1; j<=noproc; j++)
  1729.     {
  1730.         if( tablepid[j] == pid )
  1731.         {
  1732.             tablepid[j] = 0;
  1733.             return(j);
  1734.         }
  1735.     }
  1736.     printf("pid not found in table on free\n");
  1737.     return(0);
  1738. }
  1739.  
  1740. getid( )
  1741. {
  1742.     register int j;
  1743.  
  1744.     for(j=1; j<=noproc; j++)
  1745.     {
  1746.         if( tablepid[j] == 0 )
  1747.         {
  1748.             return(j);
  1749.         }
  1750.     }
  1751.     printf("no free space on getpid\n");
  1752.     return(0);
  1753. }
  1754. SHAR_EOF
  1755. fi
  1756. if test -f 'makefiles.c'
  1757. then
  1758.     echo shar: "will not over-write existing file 'makefiles.c'"
  1759. else
  1760. cat << \SHAR_EOF > 'makefiles.c'
  1761. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  1762.  
  1763. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  1764. #include <stdio.h>
  1765.  
  1766. FILE * stream;
  1767.  
  1768. static char bufferw[5120],bufferr[5120];
  1769. static char s[100],namev[8][80];
  1770. static double pcnt[8];
  1771. static int fdr,novol,lng;
  1772. static int nomp,noproc;
  1773.  
  1774. main( )
  1775. {
  1776.     register int i,k,j;
  1777.     register char * pw;
  1778.     register char * pr;
  1779.  
  1780.     pw = bufferw;
  1781.     pr = bufferr;
  1782.     for(i=0; i<5120; i++);
  1783.     {
  1784.         *pw++ = 'w';
  1785.         *pr++ = 'r';
  1786.     }
  1787.     if( (stream = fopen("config","r")) == NULL )
  1788.     {
  1789.         printf("unable to open file config\n");
  1790.         exit(1);
  1791.     }
  1792.     i = 1;
  1793.     while( i <=3 )
  1794.     {
  1795.         if( fgets(s,100,stream) == NULL )
  1796.         {
  1797.             printf("comfig file is empty\n");
  1798.             exit(1);
  1799.         }
  1800.         if( s[0] == '#' ) continue;
  1801.         switch(i)
  1802.         {
  1803.         case 1:
  1804.             sscanf(s,"%d",&nomp);
  1805.             break;
  1806.         case 2:
  1807.             sscanf(s,"%d",&noproc);
  1808.             break;
  1809.         case 3:
  1810.             sscanf(s,"%d",&novol);
  1811.             break;
  1812.         }
  1813.         i++;
  1814.     }
  1815.     for(i=0; i<novol; i++)
  1816.     {
  1817.         lab2:
  1818.         if( fgets(s,100,stream) == NULL)
  1819.         {
  1820.             printf("not enough disk volume names\n");
  1821.             exit(1);
  1822.         }
  1823.         if( s[0] == '#' ) goto lab2;
  1824.         sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
  1825.     }
  1826.     fclose(stream);
  1827.     for(i=0; i<novol; i++)
  1828.     {
  1829.         lng = strlen(&namev[i][0]);
  1830.         if( namev[i][lng-1] != '/')
  1831.         {
  1832.             namev[i][lng++] = '/';
  1833.         }
  1834.         namev[i][lng++] = 'd';
  1835.         namev[i][lng++] = 'k';
  1836.         namev[i][lng+3] = '\0';
  1837.         for(j=0; j<=199; j++)
  1838.         {
  1839.             sprintf(&namev[i][lng],"%03d",j);
  1840.             if( (fdr = creat(&namev[i][0],0666)) < 0 )
  1841.             {
  1842.                 printf("can not open %s file\n",
  1843.                     &namev[i][0]);
  1844.                 exit(1);
  1845.             }
  1846.             for(k=1; k<=4; k++)
  1847.             {
  1848.                 if( write(fdr,bufferr,5120) != 5120 )
  1849.                 {
  1850.                     printf("unable to write read buffer %3d\n",i);
  1851.                     exit(1);
  1852.                 }
  1853.             }
  1854.             close(fdr);
  1855.             printf("name = %s\n",&namev[i][0]);
  1856.         }
  1857.     }
  1858. }
  1859. SHAR_EOF
  1860. fi
  1861. if test -f 'rplot.c'
  1862. then
  1863.     echo shar: "will not over-write existing file 'rplot.c'"
  1864. else
  1865. cat << \SHAR_EOF > 'rplot.c'
  1866. #include <stdio.h>
  1867.  
  1868. static int noproc1,noproc2;
  1869. static int notty1,notty2,nodkr1,nodkr2,toggle;
  1870. static char screen[45][108],c[5],s1[101],s2[101];
  1871. static double xmax,xmin,ymax,ymin;
  1872. static int xi[10][50],yi[10][50];
  1873. static double x[10][50],y[10][50];
  1874. static int tagv,xv;
  1875. static char tagc[11] =
  1876. {"ABCEFGHIJK"};
  1877. static int flag = 1;
  1878. static int tagi[10] =
  1879. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  1880. static int tagh = -1;
  1881. static int tag[10] =
  1882. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  1883. static double xu,yu,xd,yd;
  1884. static float jobs1,jobs2;
  1885. FILE * stream1;
  1886. FILE * stream2;
  1887. static char ylab[11][8],xlab[10][8];
  1888. static char labtemp[10];
  1889. static char xaxis[92] = {
  1890. "+---------+---------+---------+---------+---------+---------+---------+---------+---------+"};
  1891. static char yaxis[42] = {
  1892. "+|||+|||+|||+|||+|||+|||+|||+|||+|||+|||+"};
  1893. static char letters[27] = {
  1894. "abcdefghijklmnopqrstuvwxyz"};
  1895. static char f = '\f';
  1896. static char var1[ ] =
  1897. {"           R = RATIO OF TWO SYSTEMS THROUGHPUT"};
  1898. static char var2[ ] =
  1899. {"           D = DISK READ + WRITE REQUEST PER JOB"};
  1900. static char var3[ ] =
  1901. {"           T = TTY WRITE REQUEST PER JOB"};
  1902.     static char title1[100],title2[100];
  1903.  
  1904. main(argc,argv)
  1905.     int argc;
  1906.     char * argv[ ];
  1907. {
  1908.     register int i,n,j,j1,j2,k;
  1909.  
  1910.     if( argc != 3 )
  1911.     {
  1912.         printf("incorect number of arguments\n");
  1913.         exit(1);
  1914.     }
  1915.     if( (stream1 = fopen(argv[1],"r")) == NULL )
  1916.     {
  1917.         printf("unable to open file %s\n",argv[1]);
  1918.         exit(2);
  1919.     }
  1920.     if( (stream2 = fopen(argv[2],"r")) == NULL )
  1921.     {
  1922.         printf("unable to open file %s\n",argv[2]);
  1923.         exit(2);
  1924.     }
  1925.     /* read in titles */
  1926.     if( fgets(title1,100,stream1) == NULL )
  1927.     {
  1928.         printf("The file %s is empty\n",argv[1]);
  1929.         exit(1);
  1930.     }
  1931.     if( fgets(title2,100,stream2) == NULL )
  1932.     {
  1933.         printf("The file %s is empty\n",argv[2]);
  1934.         exit(1);
  1935.     }
  1936.     if( fgets(s1,100,stream1) == NULL )
  1937.     {
  1938.         printf("The file %s is empty\n",argv[1]);
  1939.         exit(1);
  1940.     }
  1941.     sscanf(s1,"%d",&noproc1);
  1942.     if( fgets(s2,100,stream2) == NULL )
  1943.     {
  1944.         printf("The file %s is empty\n",argv[2]);
  1945.         exit(1);
  1946.     }
  1947.     sscanf(s2,"%d",&noproc2);
  1948.     n = strlen(title1);
  1949.     title1[n-1] = '\0';
  1950.     n = strlen(title2);
  1951.     title2[n-1] = '\0';
  1952.     /* clear screen */
  1953.     for(i=0; i<=44; i++)
  1954.     {
  1955.         for(j=0; j<=107; j++)
  1956.         {
  1957.             if( j == 107 )
  1958.                 screen[i][j] = '\0';
  1959.             else
  1960.                 screen[i][j] = ' ';
  1961.         }
  1962.     }
  1963.     /* put in x and y axis */
  1964.     j = 11;
  1965.     for(i=0; i<=40; i++)
  1966.     {
  1967.         screen[i][j] = yaxis[i];
  1968.     }
  1969.     i = 41;
  1970.     k = 0;
  1971.     j = 12;
  1972.     while( j <= 102 )
  1973.     {
  1974.         screen[i][j] = xaxis[k++];
  1975.         j++;
  1976.     }
  1977.     /* read in y and x values */
  1978.     i = 0;
  1979.     while( (fgets(s1,100,stream1) != NULL) &&
  1980.         (fgets(s2,100,stream2) != NULL) )
  1981.     {
  1982.         sscanf(s1,"%d  %d  %f",¬ty1,&nodkr1,&jobs1);
  1983.         sscanf(s2,"%d  %d  %f",¬ty2,&nodkr2,&jobs2);
  1984.         if( (notty1 != notty2) || (nodkr1 != nodkr2) )
  1985.         {
  1986.             printf("benchmark data files are out of sequence\n");
  1987.             exit(1);
  1988.         }
  1989.         if(flag)
  1990.         {
  1991.             tagv = notty1;
  1992.             xv = nodkr1;
  1993.         }
  1994.         else
  1995.         {
  1996.             tagv = nodkr1;
  1997.             xv = notty1;
  1998.         }
  1999.         for(i=0; i<=tagh; i++)
  2000.         {
  2001.             if(tagv == tag[i])
  2002.             {
  2003.                 j = i;
  2004.                 goto lab1;
  2005.             }
  2006.         }
  2007.         j = ++tagh;
  2008.         tag[j] = tagv;
  2009.     lab1:
  2010.         k = ++tagi[j];
  2011.         x[j][k] = (double)xv;
  2012.         y[j][k] = jobs1 / jobs2;
  2013.     }
  2014.     fclose(stream1);
  2015.     fclose(stream2);
  2016.     n = i - 1;
  2017.     xmax = xmin = x[0][0];
  2018.     ymax = ymin = y[0][0];
  2019.     /* find min and max of x and y */
  2020.     for(i=0; i<=tagh; i++)
  2021.     {
  2022.         for(j=0; j<=tagi[i]; j++)
  2023.         {
  2024.             if( x[i][j] > xmax ) xmax = x[i][j];
  2025.             if( x[i][j] < xmin ) xmin = x[i][j];
  2026.             if( y[i][j] > ymax ) ymax = y[i][j];
  2027.             if( y[i][j] < ymin ) ymin = y[i][j];
  2028.         }
  2029.     }
  2030.     yu = (ymax - ymin) / 40.0;
  2031.     xu = (xmax - xmin) / 90.0;
  2032.     /* find x,y value location on screen */
  2033.     for(i=0; i<=tagh; i++)
  2034.     {
  2035.         for(j=0; j<=tagi[i]; j++)
  2036.         {
  2037.             yd = (y[i][j] - ymin) / yu;
  2038.             xd = (x[i][j] - xmin) / xu;
  2039.             j1 = 40 - ((int)(yd + .5));
  2040.             j2 = (int)(xd + .5);
  2041.             yi[i][j] = j1;
  2042.             xi[i][j] = j2;
  2043.             j2 += 12;
  2044.             n = j2;
  2045.             k = 0;
  2046.             toggle = 1;
  2047.             while( screen[j1][j2] != ' ' )
  2048.             {
  2049.                 if(toggle)
  2050.                 {
  2051.                     toggle = 0;
  2052.                     j2 = n + (++k);
  2053.                 }
  2054.                 else
  2055.                 {
  2056.                     toggle = 1;
  2057.                     j2 = n - k;
  2058.                 }
  2059.             }
  2060.             screen[j1][j2] = tagc[i];
  2061.         }
  2062.     }
  2063.     /* generate label values for x and y axis */
  2064.     for(i=0; i<=10; i++)
  2065.     {
  2066.         yd = ( (double)i * 4.0 * yu) + ymin;
  2067.         sprintf(labtemp,"%8.3f",yd);
  2068.         for(j=0; j<=7; j++)
  2069.         {
  2070.             ylab[i][j] = labtemp[j];
  2071.         }
  2072.     }
  2073.     for(i=0; i<=9; i++)
  2074.     {
  2075.         xd = ((double)i * 10.0 * xu) + xmin;
  2076.         sprintf(labtemp,"%8.1f",xd);
  2077.         for(j=0; j<=7; j++)
  2078.         {
  2079.             xlab[i][j] = labtemp[j];
  2080.         }
  2081.     }
  2082.     /* place the axis label values on the screen */
  2083.     k = 40;
  2084.     for(i=0; i<=10; i++)
  2085.     {
  2086.         j1 = 0;
  2087.         for(j=3; j<=10; j++)
  2088.         {
  2089.             screen[k][j] = ylab[i][j1++];
  2090.         }
  2091.         k -= 4;
  2092.     }
  2093.     k = 42;
  2094.     j2 = 6;
  2095.     for(i=0; i<=9; i++)
  2096.     {
  2097.         j1 = j2;
  2098.         for(j=0; j<=7; j++)
  2099.         {
  2100.             screen[k][j1++] = xlab[i][j];
  2101.         }
  2102.         j2 += 10;
  2103.     }
  2104.     screen[20][2] = 'R';
  2105.     if(flag)
  2106.         screen[43][46] = 'D';
  2107.     else
  2108.         screen[43][46] = 'T';
  2109.     printf("\f");
  2110.     for(i=0; i<=43; i++)
  2111.     {
  2112.         printf("%s\n",&screen[i][0]);
  2113.     }
  2114.     printf("%s",var1);
  2115.     if(flag)
  2116.         printf("%s\n",var2);
  2117.     else
  2118.         printf("%s\n",var3);
  2119.     printf("                       CURVE SYMBOL    -    NUMBER OF TTY WRITE REQUEST PER JOB\n");
  2120.     printf("           ");
  2121.     for(i=0; i<=tagh; i++)
  2122.     {
  2123.         printf("CURVE %c %3d     ",tagc[i],tag[i]);
  2124.     }
  2125.     printf("\n           MULTIUSER LEVELS EQUAL %2d %2d\n",noproc1,noproc2);
  2126.     printf("           *** THE THROUGHPUT RATIO OF %s  VRS  %s ***\n",
  2127.         title1,title2);
  2128.     exit(0);
  2129. }
  2130. SHAR_EOF
  2131. fi
  2132. if test -f 'tplot.c'
  2133. then
  2134.     echo shar: "will not over-write existing file 'tplot.c'"
  2135. else
  2136. cat << \SHAR_EOF > 'tplot.c'
  2137. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  2138.  
  2139. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  2140. #include <stdio.h>
  2141.  
  2142. static int noproc;
  2143. static int notty,nodiskr,toggle;
  2144. static char screen[51][111],c[5],s[101],s1[100];
  2145. static double xmax,xmin,ymax,ymin;
  2146. static int xi[10][50],yi[10][50];
  2147. static double x[10][50],y[10][50];
  2148. static int tagv,xv;
  2149. static char tagc[11] =
  2150. {"DTABCEFGHI"};
  2151. static int flag = 1;
  2152. static int tagi[10] =
  2153. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  2154. static int tagh = -1;
  2155. static int tag[10] =
  2156. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  2157. static double xu,yu,xd,yd;
  2158. static float jobs;
  2159. FILE * stream;
  2160. static char ylab[11][8],xlab[10][8];
  2161. static char labtemp[10];
  2162. static char xaxis[92] = {
  2163. "+---------+---------+---------+---------+---------+---------+---------+---------+---------+"};
  2164. static char yaxis[42] = {
  2165. "+|||+|||+|||+|||+|||+|||+|||+|||+|||+|||+"};
  2166. static char letters[27] = {
  2167. "abcdefghijklmnopqrstuvwxyz"};
  2168. static char f = '\f';
  2169. static char var1[ ] =
  2170. {"             J = THROUGHPUT - JOBS PER MINUTE"};
  2171. static char var2[ ] =
  2172. {"           DISK = DISK READ + WRITE REQUEST PER JOB"};
  2173. static char var3[ ] =
  2174. {"           T = TTY WRITE REQUEST PER JOB"};
  2175. static char title[100];
  2176.  
  2177. main(argc,argv)
  2178.     int argc;
  2179.     char * argv[ ];
  2180. {
  2181.     register int i,n,j,j1,j2,k;
  2182.  
  2183.     if( argc != 2 )
  2184.     {
  2185.         printf("incorect number of arguments\n");
  2186.         exit(1);
  2187.     }
  2188.     if( (stream = fopen(argv[1],"r")) == NULL )
  2189.     {
  2190.         printf("unable to open file %s\n",argv[1]);
  2191.         exit(2);
  2192.     }
  2193.     /* read in title */
  2194.     if( fgets(title,100,stream) == NULL )
  2195.     {
  2196.         printf("The file %s is empty\n",argv[1]);
  2197.         exit(1);
  2198.     }
  2199.     n = strlen(title);
  2200.     title[n-1] = '\0';
  2201.     if( fgets(s,100,stream) == NULL )
  2202.     {
  2203.         printf("The file %s is empty\n",argv[1]);
  2204.         exit(1);
  2205.     }
  2206.     sscanf(s,"%d",&noproc);
  2207.     /* clear screen */
  2208.     for(i=0; i<=50; i++)
  2209.     {
  2210.         for(j=0; j<=110; j++)
  2211.         {
  2212.             screen[i][j] = ' ';
  2213.             if( (i==0) || (i==50) )
  2214.                 screen[i][j] = '*';
  2215.             if( (j==0) || (j==109) )
  2216.                 screen[i][j] = '*';
  2217.             if( j == 110 )
  2218.                 screen[i][j] = '\0';
  2219.         }
  2220.     }
  2221.     /* put in x and y axis */
  2222.     j = 13;
  2223.     j1 = 1;
  2224.     for(i=0; i<=40; i++)
  2225.     {
  2226.         screen[j1++][j] = yaxis[i];
  2227.     }
  2228.     i = 42;
  2229.     k = 0;
  2230.     j = 14;
  2231.     while( j <= 104 )
  2232.     {
  2233.         screen[i][j] = xaxis[k++];
  2234.         j++;
  2235.     }
  2236.     /* read in y and x values */
  2237.     i = 0;
  2238.     while( fgets(s,100,stream) != NULL )
  2239.     {
  2240.         sscanf(s,"%d %d %f",¬ty,&nodiskr,&jobs);
  2241.         if(flag)
  2242.         {
  2243.             tagv = notty;
  2244.             xv = nodiskr;
  2245.         }
  2246.         else
  2247.         {
  2248.             tagv = nodiskr;
  2249.             xv = notty;
  2250.         }
  2251.         for(i=0; i<=tagh; i++)
  2252.         {
  2253.             if(tagv == tag[i])
  2254.             {
  2255.                 j = i;
  2256.                 goto lab1;
  2257.             }
  2258.         }
  2259.         j = ++tagh;
  2260.         tag[j] = tagv;
  2261.     lab1:
  2262.         k = ++tagi[j];
  2263.         x[j][k] = (double)xv;
  2264.         y[j][k] = jobs;
  2265.     }
  2266.     fclose(stream);
  2267.     n = i - 1;
  2268.     xmax = xmin = x[0][0];
  2269.     ymax = ymin = y[0][0];
  2270.     /* find min and max of x and y */
  2271.     for(i=0; i<=tagh; i++)
  2272.     {
  2273.         for(j=0; j<=tagi[i]; j++)
  2274.         {
  2275.             if( x[i][j] > xmax ) xmax = x[i][j];
  2276.             if( x[i][j] < xmin ) xmin = x[i][j];
  2277.             if( y[i][j] > ymax ) ymax = y[i][j];
  2278.             if( y[i][j] < ymin ) ymin = y[i][j];
  2279.         }
  2280.     }
  2281.     yu = (ymax - ymin) / 40.0;
  2282.     xu = (xmax - xmin) / 90.0;
  2283.     /* find x,y value location on screen */
  2284.     for(i=0; i<=tagh; i++)
  2285.     {
  2286.         for(j=0; j<=tagi[i]; j++)
  2287.         {
  2288.             yd = (y[i][j] - ymin) / yu;
  2289.             xd = (x[i][j] - xmin) / xu;
  2290.             j1 = 41 - ((int)(yd + .5));
  2291.             j2 = (int)(xd + .5);
  2292.             yi[i][j] = j1;
  2293.             xi[i][j] = j2;
  2294.             j2 += 14;
  2295.             n = j2;
  2296.             k = 0;
  2297.             toggle = 1;
  2298.             while( screen[j1][j2] != ' ' )
  2299.             {
  2300.                 if(toggle)
  2301.                 {
  2302.                     toggle = 0;
  2303.                     j2 = n + (++k);
  2304.                 }
  2305.                 else
  2306.                 {
  2307.                     toggle = 1;
  2308.                     j2 = n - k;
  2309.                 }
  2310.             }
  2311.             screen[j1][j2] = tagc[i];
  2312.         }
  2313.     }
  2314.     /* generate label values for x and y axis */
  2315.     for(i=0; i<=10; i++)
  2316.     {
  2317.         yd = ( (double)i * 4.0 * yu) + ymin;
  2318.         sprintf(labtemp,"%8.3f",yd);
  2319.         for(j=0; j<=7; j++)
  2320.         {
  2321.             ylab[i][j] = labtemp[j];
  2322.         }
  2323.     }
  2324.     for(i=0; i<=9; i++)
  2325.     {
  2326.         xd = ((double)i * 10.0 * xu) + xmin;
  2327.         sprintf(labtemp,"%8.1f",xd);
  2328.         for(j=0; j<=7; j++)
  2329.         {
  2330.             xlab[i][j] = labtemp[j];
  2331.         }
  2332.     }
  2333.     /* place the axis label values on the screen */
  2334.     k = 41;
  2335.     for(i=0; i<=10; i++)
  2336.     {
  2337.         j1 = 0;
  2338.         for(j=4; j<=11; j++)
  2339.         {
  2340.             screen[k][j] = ylab[i][j1++];
  2341.         }
  2342.         k -= 4;
  2343.     }
  2344.     k = 43;
  2345.     j2 = 8;
  2346.     for(i=0; i<=9; i++)
  2347.     {
  2348.         j1 = j2;
  2349.         for(j=0; j<=7; j++)
  2350.         {
  2351.             screen[k][j1++] = xlab[i][j];
  2352.         }
  2353.         j2 += 10;
  2354.     }
  2355.     screen[21][2] = 'J';
  2356.     if(flag)
  2357.     {
  2358.         screen[44][48] = 'D';
  2359.         screen[44][49] = 'I';
  2360.         screen[44][50] = 'S';
  2361.         screen[44][51] = 'K';
  2362.     }
  2363.     else
  2364.         screen[44][48] = 'T';
  2365.     sprintf(s,"%s\0",var1);
  2366.     if(flag)
  2367.         sprintf(s1,"%s\0",var2);
  2368.     else
  2369.         sprintf(s1,"%s\0",var3);
  2370.     strcat(s,s1);
  2371.     scrcpy(45,s);
  2372.     sprintf(s,"                         CURVE SYMBOL    -    NUMBER OF TTY WRITE REQUEST PER JOB\0");
  2373.     scrcpy(46,s);
  2374.     sprintf(s,"             \0");
  2375.     for(i=2; i<=tagh; i++)
  2376.     {
  2377.         sprintf(s1,"CURVE %c %3d     \0",tagc[i],tag[i]);
  2378.         strcat(s,s1);
  2379.     }
  2380.     scrcpy(47,s);
  2381.     sprintf(s,"             I/O  ONLY --- CURVE T  TTY ONLY   CURVE D  DISK ONLY      MULTIUSER LEVEL EQUALS %2d\0",noproc);
  2382.     scrcpy(48,s);
  2383.     sprintf(s,"                    %s\0",title);
  2384.     scrcpy(49,s);
  2385.     printf("\f");
  2386.     for(i=0; i<=50; i++)
  2387.     {
  2388.         printf("%s\n",&screen[i][0]);
  2389.     }
  2390.     printf("\f");
  2391.     exit(0);
  2392. }
  2393.  
  2394. scrcpy(n,s)
  2395.     int n;
  2396.     char s[ ];
  2397. {
  2398.     register int i,j;
  2399.  
  2400.     i = n;
  2401.     j = 1;
  2402.     while( s[j] != '\0' )
  2403.     {
  2404.         screen[i][j] = s[j];
  2405.         j++;
  2406.     }
  2407.     return;
  2408. }
  2409. SHAR_EOF
  2410. fi
  2411. if test -f 'trun.c'
  2412. then
  2413.     echo shar: "will not over-write existing file 'trun.c'"
  2414. else
  2415. cat << \SHAR_EOF > 'trun.c'
  2416. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  2417.  
  2418. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  2419. #include "sys/types.h"
  2420. #include "sys/times.h"
  2421. #include "stdio.h"
  2422. #include "termio.h"
  2423. #define MAXPROC 64
  2424.  
  2425. #define NULL 0
  2426.  
  2427.  
  2428. static int ttyfd;
  2429. static double timex;
  2430. static struct termio ttystru;
  2431.  
  2432.  
  2433. static int noproc,maxjobs;
  2434. static int nomp,nottyc,nottycl;
  2435. static int count,itotal,status;
  2436. static int pid,cid,tagid;
  2437. static double stime;
  2438. static char tty[MAXPROC][14],s[100];
  2439. static int tablepid[MAXPROC];
  2440. static int notty,nochar,tnotty,tnochar,nodiskr,nouser;
  2441. static double jobs;
  2442. static long start,end,ftime;
  2443.  
  2444.  
  2445. FILE * stream;
  2446. static char line[32],buffer[1024],pbuffer[32],bufin[1024];
  2447. static char namev[8][80];
  2448. static double pcnt[8],sum;
  2449. static int novol,fsum,nfile[8],lng,len[8];
  2450. /* tty open */
  2451.  
  2452. ttyopen( )
  2453. {
  2454.     
  2455.     if( (ttyfd = open(&tty[tagid][0],1)) < 0 )
  2456.     {
  2457.         printf("can not open %s for tty write\n",&tty[tagid][0]);
  2458.         return;
  2459.     }
  2460.     ioctl(ttyfd,TCGETA,&ttystru);
  2461.     ttystru.c_cflag = B9600 | CS7 | CREAD | PARENB | CLOCAL;
  2462.     ttystru.c_oflag = OPOST | ONLCR | TAB3;
  2463.     ioctl(ttyfd,TCSETA,&ttystru);
  2464.     return;
  2465. }
  2466.  
  2467. main(argc,argv)
  2468.     int argc;
  2469.     char * argv[ ];
  2470. {
  2471.     register int i,j,k;
  2472.  
  2473.     if( argc != 3 )
  2474.     {
  2475.         printf("incorrect number of arguments for run\n");
  2476.         exit(1);
  2477.     }
  2478.     for(k=0; k<31; k++)
  2479.     {
  2480.         line[k] = 'A' + k % 10;
  2481.         pbuffer[k] = 'K' + k % 10;
  2482.     }
  2483.     line[31] = '\n';
  2484.     pbuffer[31] = '0';
  2485.     if( (stream = fopen("config","r")) == NULL )
  2486.     {
  2487.         printf("unable to open file config\n");
  2488.         exit(1);
  2489.     }
  2490.     i = 1;
  2491.     while( i <=3 )
  2492.     {
  2493.         if( fgets(s,100,stream) == NULL )
  2494.         {
  2495.             printf("comfig file is empty\n");
  2496.             exit(1);
  2497.         }
  2498.         if( s[0] == '#' ) continue;
  2499.         switch(i)
  2500.         {
  2501.         case 1:
  2502.             sscanf(s,"%d",&nomp);
  2503.             break;
  2504.         case 2:
  2505.             sscanf(s,"%d",&noproc);
  2506.             break;
  2507.         case 3:
  2508.             sscanf(s,"%d",&novol);
  2509.             break;
  2510.         }
  2511.         i++;
  2512.     }
  2513.     for(i=0; i<novol; i++)
  2514.     {
  2515.         lab2:
  2516.         if( fgets(s,100,stream) == NULL)
  2517.         {
  2518.             printf("not enough disk volume names\n");
  2519.             exit(1);
  2520.         }
  2521.         if( s[0] == '#' ) goto lab2;
  2522.         sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
  2523.     }
  2524.     i = 1;
  2525.     while( i <=2 )
  2526.     {
  2527.         if( fgets(s,100,stream) == NULL )
  2528.         {
  2529.             printf("comfig file is empty\n");
  2530.             exit(1);
  2531.         }
  2532.         if( s[0] == '#' ) continue;
  2533.         switch(i)
  2534.         {
  2535.         case 1:
  2536.             sscanf(s,"%d",¬tyc);
  2537.             break;
  2538.         case 2:
  2539.             sscanf(s,"%d",¬tycl);
  2540.             break;
  2541.         }
  2542.         i++;
  2543.     }
  2544.     j = 0;
  2545.     while( fgets(s,100,stream) != NULL )
  2546.     {
  2547.         if( s[0] == '#' ) continue;
  2548.         if( ++j > MAXPROC )
  2549.         {
  2550.             printf("too many entries in config file\n");
  2551.             exit(1);
  2552.         }
  2553.         sscanf(s,"%s",&tty[j][0]);
  2554.     }
  2555.     fclose(stream);
  2556.     sscanf(argv[1],"%d",¬ty);
  2557.     sscanf(argv[2],"%d",&nodiskr);
  2558.     maxjobs = 200;
  2559.     ptime(1);
  2560.     count = 0;
  2561.     itotal = 0;
  2562.     for(i=1; i<=noproc; i++)
  2563.     {
  2564.         tablepid[i] = 0;
  2565.     }
  2566.     i = -1;
  2567.     start = ptime(1);
  2568.     while( 1 )
  2569.     {
  2570.         i++;
  2571.         tagid = getid( );
  2572.         if( ( pid = fork( ) ) == 0 )
  2573.         {
  2574.             if( notty )
  2575.                 ttyopen( );
  2576.             for(i=1; i<=notty; i++)
  2577.             {
  2578.                 if( write(ttyfd,line,sizeof line) != sizeof line)
  2579.                 {
  2580.                     printf(" can not write %s on tty write\n",&tty[tagid][0]);
  2581.                     exit(1);
  2582.                 }
  2583.             }
  2584.             if( notty )
  2585.                 close(ttyfd);
  2586.             exit(0);
  2587.         }
  2588.         if( pid > 0 )
  2589.         {
  2590.             insert(pid);
  2591.             count++;
  2592.         }
  2593.         else
  2594.         {
  2595.             printf(" can not fork child process\n");
  2596.             exit(1);
  2597.         }
  2598.         if( count == noproc )
  2599.         {
  2600.             cid = wait(&status);
  2601.             count--;
  2602.             freeit(cid);
  2603.             if( ++itotal >= (maxjobs + 1 - noproc) )
  2604.             {
  2605.                 while( count > 0 )
  2606.                 {
  2607.                     cid = wait(&status);
  2608.                     count--;
  2609.                     itotal++;
  2610.                     freeit(cid);
  2611.                 }
  2612.                 goto ENDIT;
  2613.             }
  2614.         }
  2615.     }
  2616.     ENDIT:
  2617.     end = ptime(1);
  2618.     if( (stream = fopen("answers","a")) == NULL )
  2619.     {
  2620.         printf("unable to open file answers\n");
  2621.         exit(1);
  2622.     }
  2623.     ftime = end - start;
  2624.     timex = ( (double)ftime ) / 1000.0;
  2625.     jobs = ((double)maxjobs * 60.0) / timex;
  2626.     fprintf(stream,"%3d %3d %9.3f %9.3f\n",
  2627.         2000,0,jobs,timex);
  2628.     fclose(stream);
  2629.     if( nodiskr )
  2630.     {
  2631.         if( (stream = fopen("subele","a")) == NULL )
  2632.         {
  2633.             printf("unable to open file subele\n");
  2634.             exit(1);
  2635.         }
  2636.         nochar = notty * 32;
  2637.         tnotty = maxjobs * notty;
  2638.         tnochar = maxjobs * nochar;
  2639.         fprintf(stream,"\n  T T Y   S U B S Y S T E M\n");
  2640.         fprintf(stream," Total  Characters Written per Second %9.3f\n",
  2641.                 (double)tnochar / timex);
  2642.         fprintf(stream," Characters Written per Second per Line %9.3f\n",
  2643.                 (double)tnochar / ((double)noproc * timex ) );
  2644.         fprintf(stream," Total Characters Written %d request size %d \n",
  2645.                 tnochar,32);
  2646.         fprintf(stream," Total Time To Write Characters %9.3f Seconds\n",timex);
  2647.         fprintf(stream," Number of TTY Controllers %d\n",nottyc);
  2648.         fprintf(stream," Number of TTY Lines per Controller %d\n",nottycl);
  2649.         fprintf(stream," Number of TTY Lines Used in Run %d\n",noproc);
  2650.         fprintf(stream," Jobs per Minute %9.3f\n",(double)(60 * maxjobs) / timex);
  2651.         fclose(stream);
  2652.     }
  2653.     exit(0);
  2654. }
  2655.  
  2656. long
  2657. ptime(tflag)
  2658.     int tflag;
  2659. {
  2660.     static long tm[4];
  2661.     static int first = 1;
  2662.     static long tstart = 0;
  2663.     static long xtime = 0;
  2664.     long times( );
  2665.     register int i;
  2666.  
  2667.     if( tflag && first )
  2668.     {
  2669.         tstart = times(tm);
  2670.         first = 0;
  2671.         return(0);
  2672.     }
  2673.     xtime = times(tm);
  2674.     if( tflag )
  2675.     {
  2676.         xtime = (1000 * (xtime - tstart)) / 60;
  2677.     }
  2678.     else
  2679.     {
  2680.         xtime = (1000 * tm[0] ) / 60;
  2681.     }
  2682.     return(xtime);
  2683. }
  2684.  
  2685. insert(pid)
  2686.     int pid;
  2687. {
  2688.     register int j;
  2689.  
  2690.     for(j=1; j<=noproc; j++)
  2691.     {
  2692.         if( tablepid[j] == 0 )
  2693.         {
  2694.             tablepid[j] = pid;
  2695.             return(pid);
  2696.         }
  2697.     }
  2698.     printf("no free space on insert pid\N");
  2699.     return(0);
  2700. }
  2701.  
  2702. freeit(pid)
  2703.     int pid;
  2704. {
  2705.     register int j;
  2706.  
  2707.     for(j=1; j<=noproc; j++)
  2708.     {
  2709.         if( tablepid[j] == pid )
  2710.         {
  2711.             tablepid[j] = 0;
  2712.             return(j);
  2713.         }
  2714.     }
  2715.     printf("pid not found in table on free\n");
  2716.     return(0);
  2717. }
  2718.  
  2719. getid( )
  2720. {
  2721.     register int j;
  2722.  
  2723.     for(j=1; j<=noproc; j++)
  2724.     {
  2725.         if( tablepid[j] == 0 )
  2726.         {
  2727.             return(j);
  2728.         }
  2729.     }
  2730.     printf("no free space on getpid\n");
  2731.     return(0);
  2732. }
  2733. SHAR_EOF
  2734. fi
  2735. if test -f 'xrun.c'
  2736. then
  2737.     echo shar: "will not over-write existing file 'xrun.c'"
  2738. else
  2739. cat << \SHAR_EOF > 'xrun.c'
  2740. /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
  2741.  
  2742. static char _Version[] = "%W%  Compiled: %T% %H%  Delta Date: %U% %G%";
  2743. #include "sys/types.h"
  2744. #include "sys/times.h"
  2745. #include "stdio.h"
  2746. #include "termio.h"
  2747. #define MAXPROC 64
  2748.  
  2749. #define NULL 0
  2750.  
  2751.  
  2752. static int ttyfd,diskrfd,diskwfd,toggle;
  2753. static double timex;
  2754. static struct termio ttystru;
  2755.  
  2756.  
  2757. static int noproc,maxjobs;
  2758. static int nomp,nottyc,nottycl;
  2759. static int count,itotal,status;
  2760. static int pid,cid,tagid;
  2761. static double stime;
  2762. static char tty[MAXPROC][14],s[100];
  2763. static int tablepid[MAXPROC];
  2764. static int notty,nodiskw,nodiskr,nouser;
  2765. static double jobs;
  2766. static long start,end,ftime;
  2767.  
  2768.  
  2769. FILE * stream;
  2770. static char line[32],buffer[1024],pbuffer[32],bufin[1024];
  2771. static char namev[8][80];
  2772. static double pcnt[8],sum;
  2773. static int novol,fsum,nfile[8],lng,len[8];
  2774. static int total,ll[8],hl[8],cnt[8],vol,disk[200];
  2775. static int dist,sdist[8],oldf[8];
  2776. static int file1[200] =
  2777. {
  2778.     38,113,51,10,12,149,84,25,89,137,
  2779.     166,95,167,31,82,124,194,52,154,161,
  2780.     28,85,168,165,162,153,44,163,22,57,
  2781.     79,151,70,48,29,6,138,14,116,181,
  2782.     143,33,160,71,136,164,129,75,114,88,
  2783.     2,34,182,186,106,53,73,193,148,120,
  2784.     156,169,195,191,126,86,11,54,121,39,
  2785.     185,125,15,176,144,19,123,65,173,13,
  2786.     99,16,127,46,139,78,74,171,152,192,
  2787.     122,128,170,41,175,172,145,115,61,45,
  2788.     103,72,100,7,130,142,131,155,94,47,
  2789.     80,146,92,90,32,132,17,49,189,196,
  2790.     96,174,93,179,50,197,133,81,177,178,
  2791.     62,134,55,108,83,101,18,135,30,105,
  2792.     140,35,188,36,119,198,109,77,111,76,
  2793.     150,190,157,87,37,147,43,199,180,117,
  2794.     141,158,9,97,0,183,91,98,104,40,
  2795.     20,159,63,184,187,102,1,3,64,4,
  2796.     5,8,107,21,110,58,56,59,23,68,
  2797.     24,60,26,112,27,66,42,118,67,69
  2798. };
  2799. static int file2[200] =
  2800. {
  2801.     158,115,27,19,86,167,60,143,183,166,
  2802.     178,111,54,145,136,105,102,67,53,96,
  2803.     188,144,6,3,34,120,4,118,127,146,
  2804.     184,94,59,157,106,190,116,62,25,134,
  2805.     22,137,179,1,61,5,44,93,139,121,
  2806.     171,117,15,55,174,48,35,110,10,49,
  2807.     162,197,112,199,107,182,0,165,180,7,
  2808.     75,65,71,97,98,87,149,56,101,159,
  2809.     68,198,113,168,189,26,187,17,191,83,
  2810.     147,185,160,176,181,85,89,114,28,99,
  2811.     70,129,100,8,57,74,23,24,16,76,
  2812.     169,177,51,163,33,108,77,148,175,192,
  2813.     135,40,36,92,193,69,194,103,186,80,
  2814.     195,196,37,63,2,9,29,109,11,12,
  2815.     78,13,42,14,142,18,119,82,20,72,
  2816.     79,138,164,30,132,156,81,21,161,31,
  2817.     32,38,39,41,64,84,104,43,122,45,
  2818.     66,150,130,46,125,47,50,52,123,126,
  2819.     88,58,170,73,90,91,131,95,124,128,
  2820.     133,140,141,151,152,153,154,155,172,173
  2821. };
  2822. /* tty open */
  2823.  
  2824. ttyopen( )
  2825. {
  2826.     
  2827.     if( (ttyfd = open(&tty[tagid][0],1)) < 0 )
  2828.     {
  2829.         printf("can not open %s for tty write\n",&tty[tagid][0]);
  2830.         return;
  2831.     }
  2832.     ioctl(ttyfd,TCGETA,&ttystru);
  2833.     ttystru.c_cflag = B9600 | CS7 | CREAD | PARENB | CLOCAL;
  2834.     ttystru.c_oflag = OPOST | ONLCR | TAB3;
  2835.     ioctl(ttyfd,TCSETA,&ttystru);
  2836.     return;
  2837. }
  2838.  
  2839.  
  2840. /* disk open */
  2841.  
  2842. dkopen(n)
  2843.     int n;
  2844. {
  2845.     register int d,f1,f2,lng;
  2846.  
  2847.     d = disk[n];
  2848.     f1 = file1[n];
  2849.     f2 = file2[n];
  2850.     lng = len[d];
  2851.  
  2852.     sprintf(&namev[d][lng],"%03d",f1);
  2853.     if( (diskrfd = open(&namev[d][0],0)) < 0 )
  2854.     {
  2855.         printf("can not open %s for disk read\n",&namev[d][0]);
  2856.         return;
  2857.     }
  2858.     sprintf(&namev[d][lng],"%03d",f2);
  2859.     if( (diskwfd = open(&namev[d][0],1)) < 0 )
  2860.     {
  2861.         printf("can not open %$ for disk write\n",&namev[d][0]);
  2862.         return;
  2863.     }
  2864.     return;
  2865. }
  2866. main(argc,argv)
  2867.     int argc;
  2868.     char * argv[ ];
  2869. {
  2870.     register int i,dc,tc;
  2871.     static int k,j,n,nx;
  2872.     static double ddcnt,ttcnt;
  2873.     static double dstep,ddelta,tstep,tdelta;
  2874.  
  2875.     if( argc != 3 )
  2876.     {
  2877.         printf("incorrect number of arguments for run\n");
  2878.         exit(1);
  2879.     }
  2880.     for(k=0; k<31; k++)
  2881.     {
  2882.         line[k] = 'A' + k % 10;
  2883.         pbuffer[k] = 'K' + k % 10;
  2884.     }
  2885.     line[31] = '\n';
  2886.     pbuffer[31] = '0';
  2887.     for(k=0; k<1024; k++)
  2888.     {
  2889.         buffer[k] = 'A';
  2890.     }
  2891.     if( (stream = fopen("config","r")) == NULL )
  2892.     {
  2893.         printf("unable to open file config\n");
  2894.         exit(1);
  2895.     }
  2896.     i = 1;
  2897.     while( i <=3 )
  2898.     {
  2899.         if( fgets(s,100,stream) == NULL )
  2900.         {
  2901.             printf("comfig file is empty\n");
  2902.             exit(1);
  2903.         }
  2904.         if( s[0] == '#' ) continue;
  2905.         switch(i)
  2906.         {
  2907.         case 1:
  2908.             sscanf(s,"%d",&nomp);
  2909.             break;
  2910.         case 2:
  2911.             sscanf(s,"%d",&noproc);
  2912.             break;
  2913.         case 3:
  2914.             sscanf(s,"%d",&novol);
  2915.             break;
  2916.         }
  2917.         i++;
  2918.     }
  2919.     sum = 0.0;
  2920.     for(i=0; i<novol; i++)
  2921.     {
  2922.         lab2:
  2923.         if( fgets(s,100,stream) == NULL)
  2924.         {
  2925.             printf("not enough disk volume names\n");
  2926.             exit(1);
  2927.         }
  2928.         if( s[0] == '#' ) goto lab2;
  2929.         sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
  2930.         sum += pcnt[i];
  2931.     }
  2932.     i = 1;
  2933.     while( i <=2 )
  2934.     {
  2935.         if( fgets(s,100,stream) == NULL )
  2936.         {
  2937.             printf("comfig file is empty\n");
  2938.             exit(1);
  2939.         }
  2940.         if( s[0] == '#' ) continue;
  2941.         switch(i)
  2942.         {
  2943.         case 1:
  2944.             sscanf(s,"%d",¬tyc);
  2945.             break;
  2946.         case 2:
  2947.             sscanf(s,"%d",¬tycl);
  2948.             break;
  2949.         }
  2950.         i++;
  2951.     }
  2952.     j = 0;
  2953.     while( fgets(s,100,stream) != NULL )
  2954.     {
  2955.         if( s[0] == '#' ) continue;
  2956.         if( ++j > MAXPROC )
  2957.         {
  2958.             printf("too many entries in config file\n");
  2959.             exit(1);
  2960.         }
  2961.         sscanf(s,"%s",&tty[j][0]);
  2962.     }
  2963.     fclose(stream);
  2964.     sscanf(argv[1],"%d",¬ty);
  2965.     sscanf(argv[2],"%d",&nodiskr);
  2966.     maxjobs = 200;
  2967.     fsum = 0;
  2968.     for(i=0; i<novol; i++)
  2969.     {
  2970.         nfile[i] = (int)( ( (pcnt[i] * 200.0) / sum ) );
  2971.         fsum += nfile[i];
  2972.     }
  2973.     for(i=0; i<novol; i++)
  2974.     {
  2975.         if( fsum < 200 )
  2976.         {
  2977.             nfile[i]++;
  2978.             fsum++;
  2979.         }
  2980.         else
  2981.         {
  2982.             break;
  2983.         }
  2984.     }
  2985.     for(i=0; i<novol; i++)
  2986.     {
  2987.         lng = strlen(&namev[i][0]);
  2988.         if( namev[i][lng-1] != '/')
  2989.         {
  2990.             namev[i][lng++] = '/';
  2991.         }
  2992.         namev[i][lng++] = 'd';
  2993.         namev[i][lng++] = 'k';
  2994.         len[i] = lng;
  2995.         namev[i][lng+3] = '\0';
  2996.         sprintf(&namev[i][len[i]],"%03d",i);
  2997.     }
  2998.     total = 0;
  2999.     for(i=0; i<novol; i++)
  3000.     {
  3001.         cnt[i] = 0;
  3002.         oldf[i] = 0;
  3003.         sdist[i] = 0;
  3004.         ll[i] = total;
  3005.         total += nfile[i];
  3006.         hl[i] = total - 1;
  3007.     }
  3008.     for(j=0; j<200; j++)
  3009.     {
  3010.         k = rand( ) % 200;
  3011.         for(i=0; i<novol; i++)
  3012.         {
  3013.             if( (k>=ll[i]) && (k<=hl[i]) )
  3014.             {
  3015.                 vol = i;
  3016.                 break;
  3017.             }
  3018.         }
  3019.         disk[j] = vol;
  3020.     }
  3021.     ptime(1);
  3022.     count = 0;
  3023.     itotal = 0;
  3024.     for(i=1; i<=noproc; i++)
  3025.     {
  3026.         tablepid[i] = 0;
  3027.     }
  3028.     if( (stream = fopen("loopcount","r")) == NULL )
  3029.     {
  3030.         printf("unable to open file loopcount\n");
  3031.         exit(0);
  3032.     }
  3033.     fscanf(stream,"%d",&nx);
  3034.     fclose(stream);
  3035.     nx--;
  3036.     dc = 1;
  3037.     tc = 1;
  3038.     dstep = 0.0;
  3039.     ddelta = (double)nodiskr / (double)nx;
  3040.     tstep = 0.0;
  3041.     tdelta = (double)notty / (double)nx;
  3042.     nx++;
  3043.     k = 1;
  3044.     i = -1;
  3045.     start = ptime(1);
  3046.     while( 1 )
  3047.     {
  3048.         i++;
  3049.         tagid = getid( );
  3050.         if( ( pid = fork( ) ) == 0 )
  3051.         {
  3052.             if( notty )
  3053.                 ttyopen( );
  3054.             if( nodiskr )
  3055.                 dkopen(i);
  3056.             toggle = 1;
  3057.             for(i=1; i<=nx; i++)
  3058.             {
  3059.                 dstep += ddelta;
  3060.                 ddcnt = (double)dc;
  3061.                 if( dstep >= ddcnt )
  3062.                 {
  3063.                     dc++;
  3064.                     if( toggle )
  3065.                     {
  3066.                         if( read(diskrfd,bufin,sizeof bufin)
  3067.                             != sizeof bufin )
  3068.                         {
  3069.                             printf("can not read %s on disk read\n",&namev[disk[i]][0]);
  3070.                             exit(1);
  3071.                         }
  3072.                         toggle = 0;
  3073.                     }
  3074.                     else
  3075.                     {
  3076.                         if( write(diskwfd,buffer,sizeof buffer)
  3077.                             != sizeof buffer )
  3078.                         {
  3079.                             printf("can not write %s on on disk write\n",&namev[disk[i]][0]);
  3080.                             exit(1);
  3081.                         }
  3082.                         toggle = 1;
  3083.                     }
  3084.                 }
  3085.                 tstep += tdelta;
  3086.                 ttcnt = (double)tc;
  3087.                 if( tstep >= ttcnt )
  3088.                 {
  3089.                     tc++;
  3090.                     if( write(ttyfd,line,sizeof line) != sizeof line)
  3091.                     {
  3092.                         printf(" can not write %s on tty write\n",&tty[tagid][0]);
  3093.                         exit(1);
  3094.                     }
  3095.                 }
  3096.             }
  3097.             if( notty )
  3098.                 close(ttyfd);
  3099.             if( nodiskr )
  3100.             {
  3101.                 close(diskrfd);
  3102.                 close(diskwfd);
  3103.             }
  3104.             exit(0);
  3105.         }
  3106.         if( pid > 0 )
  3107.         {
  3108.             insert(pid);
  3109.             count++;
  3110.         }
  3111.         else
  3112.         {
  3113.             printf(" can not fork child process\n");
  3114.             exit(1);
  3115.         }
  3116.         if( count == noproc )
  3117.         {
  3118.             cid = wait(&status);
  3119.             count--;
  3120.             freeit(cid);
  3121.             if( ++itotal >= (maxjobs + 1 - noproc) )
  3122.             {
  3123.                 while( count > 0 )
  3124.                 {
  3125.                     cid = wait(&status);
  3126.                     count--;
  3127.                     itotal++;
  3128.                     freeit(cid);
  3129.                 }
  3130.                 goto ENDIT;
  3131.             }
  3132.         }
  3133.     }
  3134.     ENDIT:
  3135.     end = ptime(1);
  3136.     if( (stream = fopen("answers","a")) == NULL )
  3137.     {
  3138.         printf("unable to open file answers\n");
  3139.         exit(1);
  3140.     }
  3141.     ftime = end - start;
  3142.     timex = ( (double)ftime ) / 1000.0;
  3143.     jobs = ((double)maxjobs * 60.0) / timex;
  3144.     fprintf(stream,"%3d %3d %9.3f %9.3f\n",
  3145.         notty,nodiskr,jobs,timex);
  3146.     fclose(stream);
  3147.     exit(0);
  3148. }
  3149.  
  3150. long
  3151. ptime(tflag)
  3152.     int tflag;
  3153. {
  3154.     static long tm[4];
  3155.     static int first = 1;
  3156.     static long tstart = 0;
  3157.     static long xtime = 0;
  3158.     long times( );
  3159.     register int i;
  3160.  
  3161.     if( tflag && first )
  3162.     {
  3163.         tstart = times(tm);
  3164.         first = 0;
  3165.         return(0);
  3166.     }
  3167.     xtime = times(tm);
  3168.     if( tflag )
  3169.     {
  3170.         xtime = (1000 * (xtime - tstart)) / 60;
  3171.     }
  3172.     else
  3173.     {
  3174.         xtime = (1000 * tm[0] ) / 60;
  3175.     }
  3176.     return(xtime);
  3177. }
  3178.  
  3179. insert(pid)
  3180.     int pid;
  3181. {
  3182.     register int j;
  3183.  
  3184.     for(j=1; j<=noproc; j++)
  3185.     {
  3186.         if( tablepid[j] == 0 )
  3187.         {
  3188.             tablepid[j] = pid;
  3189.             return(pid);
  3190.         }
  3191.     }
  3192.     printf("no free space on insert pid\N");
  3193.     return(0);
  3194. }
  3195.  
  3196. freeit(pid)
  3197.     int pid;
  3198. {
  3199.     register int j;
  3200.  
  3201.     for(j=1; j<=noproc; j++)
  3202.     {
  3203.         if( tablepid[j] == pid )
  3204.         {
  3205.             tablepid[j] = 0;
  3206.             return(j);
  3207.         }
  3208.     }
  3209.     printf("pid not found in table on free\n");
  3210.     return(0);
  3211. }
  3212.  
  3213. getid( )
  3214. {
  3215.     register int j;
  3216.  
  3217.     for(j=1; j<=noproc; j++)
  3218.     {
  3219.         if( tablepid[j] == 0 )
  3220.         {
  3221.             return(j);
  3222.         }
  3223.     }
  3224.     printf("no free space on getpid\n");
  3225.     return(0);
  3226. }
  3227. SHAR_EOF
  3228. fi
  3229. exit 0
  3230. #    End of shell archive
  3231.  
  3232.  
  3233. -=-
  3234. Rich Kaul                         | "Every man is given the key to the door
  3235. kaul@icarus.eng.ohio-state.edu    |  of heaven; unfortunately, the same key
  3236. or ...!osu-cis!kaul          |  opens the door to hell."
  3237.