home *** CD-ROM | disk | FTP | other *** search
- From: kaul@icarus.eng.ohio-state.edu (Rich Kaul)
- Newsgroups: alt.sources
- Subject: NCR System Characterization Benchmark Part 2 of 4
- Message-ID: <KAUL.90Apr24093946@icarus.eng.ohio-state.edu>
- Date: 24 Apr 90 13:39:46 GMT
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute
- the file with /bin/sh (not csh) to create:
- # cpurun.c
- # crun.c
- # drun.c
- # makefiles.c
- # rplot.c
- # tplot.c
- # trun.c
- # xrun.c
- # This archive created: Mon Apr 14 09:43:34 1986
- export PATH; PATH=/bin:/usr/bin:$PATH
- if test -f 'cpurun.c'
- then
- echo shar: "will not over-write existing file 'cpurun.c'"
- else
- cat << \SHAR_EOF > 'cpurun.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include "stdio.h"
- #define MAXPROC 64
-
- #define NULL 0
-
- FILE * stream;
-
- static double timex,timey;
-
-
- static int noproc,maxjobs;
- static int nomp,nottyc,nottycl;
- static int count,itotal,status;
- static int pid,cid,tagid;
- static double stime;
- static int tablepid[MAXPROC];
- static int notty,nodiskw,nodiskr,nouser;
- static double jobs;
- static long start,end,ftime;
-
-
- main( )
- {
- register int i,dc,tc;
- static int k,j,n,nx;
- static double ddcnt,ttcnt;
- static double dstep,ddelta,tstep,tdelta;
-
- maxjobs = 200;
- ptime(1);
- count = 0;
- itotal = 0;
- noproc = 1;
- for(i=1; i<=noproc; i++)
- {
- tablepid[i] = 0;
- }
- if( (stream = fopen("loopcount","r")) == NULL )
- {
- printf("unable to open file loopcount\n");
- exit(0);
- }
- fscanf(stream,"%d",&nx);
- fclose(stream);
- nx--;
- notty = 30;
- nodiskr = 32;
- dc = 1;
- tc = 1;
- dstep = 0.0;
- ddelta = (double)nodiskr / (double)nx;
- tstep = 0.0;
- tdelta = (double)notty / (double)nx;
- nx++;
- i = -1;
- start = ptime(1);
- while( 1 )
- {
- i++;
- tagid = getid( );
- if( ( pid = fork( ) ) == 0 )
- {
- for(i=1; i<=nx; i++)
- {
- dstep += ddelta;
- ddcnt = (double)dc;
- if( dstep >= ddcnt )
- {
- dc++;
- }
- tstep += tdelta;
- ttcnt = (double)tc;
- if( tstep >= ttcnt )
- {
- tc++;
- }
- }
- exit(0);
- }
- if( pid > 0 )
- {
- insert(pid);
- count++;
- }
- else
- {
- printf(" can not fork child process\n");
- exit(1);
- }
- if( count == noproc )
- {
- cid = wait(&status);
- count--;
- freeit(cid);
- if( ++itotal >= (maxjobs + 1 - noproc) )
- {
- while( count > 0 )
- {
- cid = wait(&status);
- count--;
- itotal++;
- freeit(cid);
- }
- goto ENDIT;
- }
- }
- }
- ENDIT:
- end = ptime(1);
- ftime = end - start;
- timex = ( (double)ftime ) / 1000.0;
- count = 0;
- itotal = 0;
- noproc = 8;
- for(i=1; i<=noproc; i++)
- {
- tablepid[i] = 0;
- }
- nx--;
- notty = 30;
- nodiskr = 32;
- dc = 1;
- tc = 1;
- dstep = 0.0;
- ddelta = (double)nodiskr / (double)nx;
- tstep = 0.0;
- tdelta = (double)notty / (double)nx;
- nx++;
- i = -1;
- start = ptime(1);
- while( 1 )
- {
- i++;
- tagid = getid( );
- if( ( pid = fork( ) ) == 0 )
- {
- for(i=1; i<=nx; i++)
- {
- dstep += ddelta;
- ddcnt = (double)dc;
- if( dstep >= ddcnt )
- {
- dc++;
- }
- tstep += tdelta;
- ttcnt = (double)tc;
- if( tstep >= ttcnt )
- {
- tc++;
- }
- }
- exit(0);
- }
- if( pid > 0 )
- {
- insert(pid);
- count++;
- }
- else
- {
- printf(" can not fork child process\n");
- exit(1);
- }
- if( count == noproc )
- {
- cid = wait(&status);
- count--;
- freeit(cid);
- if( ++itotal >= (maxjobs + 1 - noproc) )
- {
- while( count > 0 )
- {
- cid = wait(&status);
- count--;
- itotal++;
- freeit(cid);
- }
- goto ENDIT2;
- }
- }
- }
- ENDIT2:
- end = ptime(1);
- ftime = end - start;
- timey = ( (double)ftime ) / 1000.0;
- if( (stream = fopen("subele","a")) == NULL )
- {
- printf("unable to open file subele\n");
- exit(1);
- }
- fprintf(stream," Effective CPU Processing Power %9.5f\n",timex / timey);
- fclose(stream);
- exit(0);
- }
-
- long
- ptime(tflag)
- int tflag;
- {
- static long tm[4];
- static int first = 1;
- static long tstart = 0;
- static long xtime = 0;
- long times( );
- register int i;
-
- if( tflag && first )
- {
- tstart = times(tm);
- first = 0;
- return(0);
- }
- xtime = times(tm);
- if( tflag )
- {
- xtime = (1000 * (xtime - tstart)) / 60;
- }
- else
- {
- xtime = (1000 * tm[0] ) / 60;
- }
- return(xtime);
- }
-
- insert(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- tablepid[j] = pid;
- return(pid);
- }
- }
- printf("no free space on insert pid\N");
- return(0);
- }
-
- freeit(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == pid )
- {
- tablepid[j] = 0;
- return(j);
- }
- }
- printf("pid not found in table on free\n");
- return(0);
- }
-
- getid( )
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- return(j);
- }
- }
- printf("no free space on getpid\n");
- return(0);
- }
- SHAR_EOF
- fi
- if test -f 'crun.c'
- then
- echo shar: "will not over-write existing file 'crun.c'"
- else
- cat << \SHAR_EOF > 'crun.c'
- #include "sys/types.h"
- #include "sys/times.h"
- #include "stdio.h"
-
- #define NOTEST 23
- #define NULL 0
-
- FILE * stream;
-
- /* add short test */
-
- adds(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register int s = 0;
-
- j = s + 1;
- sa = s + 5;
- sb = s + 10;
- sy = s + 4;
- sx = s + 5;
- asx[1] = s + 7;
- asy[1] = s + 3;
- s1 = s;
- s2 = s + 9;
- as1[1] = s + 8;
- as2[1] = s + 7;
-
- psx = &sx;
- psb = &sy;
-
- while(n--)
- {
- s1 = s1 + sb + sx + sy + sa + sb + sx + sy + sa + sb + sx + sy
- + sa + sb + sx + sy + sa + sb + sx + sy + sa + sb + s2
- + sa + sa + sb + s2 + (*psb) + asx[j] + asy[j] + as1[j]
- + as2[j] + (*psx);
- }
- return(s1);
- }
-
- /* substract short test */
-
- subs(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register s = 0;
-
- j = s + 1;
- sa = s + 5;
- sb = s + 3;
- sy = s + 5;
- sx = s + 6;
- asx[1] = s + 7;
- asy[1] = s + 4;
- s1 = s + 32000;
- s2 = s + 2;
- as1[1] = s + 3;
- as2[1] = s + 7;
-
- psx = &sx;
- psb = &sy;
-
- while(n--)
- {
- s1 = s1 - sb - sx - sy - sa - sb - sx - sy - sa - sb - sx - sy
- - sa - sb - sx - sy - sa - sb - sx - sy - sa - sb - s2
- - sa - sa - sb - s2 - (*psb) - asx[j] - asy[j] - as1[j]
- - as2[j] - (*psx);
- }
- return(s1);
- }
-
- /* multiply short */
-
- muls(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register int s = 0;
-
- j = s + 1;
- sa = 2;
- sb = s + 3;
- sx = s + 2;
- sy = s + 5;
- s2 = s + 4;
- asx[1] = s + 1;
- as1[1] = s + 7;
- asy[1] = s + 6;
- as2[1] = s + 8;
- s1 = s + 1;
-
- psx = &sx;
- psb = &sy;
-
- while(n--)
- {
- s1 = sa * sb * sx * sy * (1+(s2 >> 12)) * (*psb) * asx[j] * as1[j] * (1+(s1 >> 12));
- s2 = sa * as2[j] * asy[j] * (*psx) * sy * sx * (1+(s1 >> 12)) * ++s2 * sb;
- s1 = sa * sb * sx * sy * (1+(s2 >> 12)) * (*psb) * asx[j] * as1[j] * (1+(s1 >> 12));
- s2 = sa * as2[j] * asy[j] * (*psx) * sy * sx * (1+(s1 >> 12)) * ++s2 * sb;
- }
- return(s2);
- }
-
- /* divide short test */
-
- divs(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register int s = 0;
-
- j = s + 1;
- sa = 32000;
- sb = s + 3;
- sx = s + 2;
- sy = s + 5;
- s2 = s + 4;
- asx[1] = s + 1;
- as1[1] = s + 7;
- asy[1] = s + 6;
- as2[1] = s + 8;
- s1 = s + 1;
-
- psx = &sx;
- psb = &sy;
-
- while(n--)
- {
- s1 = sa / sb / sx / sy / ++s2 / (*psb) / asx[j] / as1[j] / ++s1;
- s2 = sa / as2[j] / asy[j] / (*psx) / sy / sx / ++s1 / ++s2 / sb;
- s1 = sa / sb / sx / sy / ++s2 / (*psb) / asx[j] / as1[j] / ++s1;
- s2 = sa / as2[j] / asy[j] / (*psx) / sy / sx / ++s1 / ++s2 / sb;
- }
- return(s2);
- }
-
- /* assign short test */
-
- asgns(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register int s = 0;
-
- j = s + 1;
- sa = s + 5;
- sb = s + 10;
- sy = s + 15;
- sx = s + 19;
- asx[1] = s + 21;
- asy[1] = s + 27;
- s1 = s + 9;
- s2 = s + 17;
- as1[1] = s + 13;
- as2[1] = s + 217;
-
- psx = &sx;
- psb = &sy;
-
- while(n--)
- {
- sa = s2; sx = sa; sy = sx; s2 = sx; s1 = s2;
- sb = s1; sa = sb; sx = sa; sy = sx; sb = sy;
- *psb = sb; sa = *psb; asx[j] = sa; sx = asx[j];
- asy[j] = sx; sb = asy[j]; *psx = sb; s2 = *psx;
- s1 = s2;
- sb = s1; sa = sb; sx = sa; sy = sx; sb = sy;
- *psb = sb; sa = *psb; asx[j] = sa; sx = asx[j];
- asy[j] = sx; sb = asy[j]; *psx = sb; s2 = *psx;
- }
- return(s2);
- }
-
- /* compare short test */
-
- cmps(n)
- int n;
- {
- register short sa,sb,*psa,*psb;
- short sx,sy,asx[32],asy[32],*psx,*psy;
- static short s1,s2,as1[32],as2[32],*ps1,*ps2;
- register int j;
- register int s = 0;
-
- sb = sy =s2 = asy[1] = as2[1] = n - 1;
- j = s + 1;
-
- psx = &sx;
- psa = &sy;
-
- while(n--)
- {
- sa = sx = s1 = asx[1] = as1[1] = n;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sa == sb ) s++;
- if( sx == sy ) s++;
- if( sx == sy ) s++;
- if( sx == sy ) s++;
- if( sx == sy ) s++;
- if( s1 == s2 ) s++;
- if( *psa == *psx ) s++;
- if( asx[j] == as1[j] ) s++;
- sb = sy =s2 = asy[1] = as2[1] = n - 1;
- if( sa != sb ) s++;
- if( sa != sb ) s++;
- if( sx != sy ) s++;
- if( sx != sy ) s++;
- if( asx[j] != asy[j] ) s++;
- if( s1 != s2 ) s++;
- if( sb < sa ) s++;
- if( sb < sa ) s++;
- if( sy < sx ) s++;
- if( sy < sx ) s++;
- if( sa > sb ) s++;
- if( sx > sy ) s++;
- if( sb <= sx ) s++;
- if( sb <= sx ) s++;
- if( sa >= sb ) s++;
- if( sa >= sb ) s++;
- if( sx >= sy ) s++;
- if( sx >= sy ) s++;
- }
- return(s);
- }
-
-
- /* add long test */
-
- addl(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- j = i + 1;
- ia = i + 5;
- ib = i + 10;
- iy = i + 15;
- ix = i + 19;
- aix[1] = i + 21;
- aiy[1] = i + 27;
- i1 = i;
- i2 = i + 17;
- ai1[1] = i + 13;
- ai2[1] = i + 7;
-
- pix = &ix;
- pib = &iy;
-
- while(n--)
- {
- i1 = i1 + ib + ix + iy + ia + ib + ix + iy + ia + ib + ix + iy
- + ia + ib + ix + iy + ia + ib + ix + iy + ia + ib + i2
- + ia + ia + ib + i2 + (*pib) + aix[j] + aiy[j] + ai1[j]
- + ai2[j] + (*pix);
- }
- return(i1);
- }
-
- /* substract long test */
-
- subl(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- j = i + 1;
- ia = i + 5;
- ib = i + 10;
- iy = i + 15;
- ix = i + 19;
- aix[1] = i + 21;
- aiy[1] = i + 27;
- i1 = i + 917672934;
- i2 = i + 17;
- ai1[1] = i + 13;
- ai2[1] = i + 7;
-
- pix = &ix;
- pib = &iy;
-
- while(n--)
- {
- i1 = i1 - ib - ix - iy - ia - ib - ix - iy - ia - ib - ix - iy
- - ia - ib - ix - iy - ia - ib - ix - iy - ia - ib - i2
- - ia - ia - ib - i2 - (*pib) - aix[j] - aiy[j] - ai1[j]
- - ai2[j] - (*pix);
- }
- return(i);
- }
-
- /* multiply long test */
-
- mull(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- j = i + 1;
- ia = 2;
- ib = i + 3;
- ix = i + 2;
- iy = i + 5;
- i2 = i + 4;
- aix[1] = i + 1;
- ai1[1] = i + 7;
- aiy[1] = i + 6;
- ai2[1] = i + 8;
- i1 = i + 1;
-
- pix = &ix;
- pib = &iy;
-
- while(n--)
- {
- i1 = ia * ib * ix * iy * (1+(i2 >> 12)) * (*pib) * aix[j] * ai1[j] * (1+(i1 >> 12 ));
- i2 = ia * ai2[j] * aiy[j] * (*pix) * iy * ix * (1+(i1 >> 12)) * (1+(i2 >> 12)) * ib;
- i1 = ia * ib * ix * iy * (1+(i2 >> 12)) * (*pib) * aix[j] * ai1[j] * (1+(i1 >> 12 ));
- i2 = ia * ai2[j] * aiy[j] * (*pix) * iy * ix * (1+(i1 >> 12)) * (1+(i2 >> 12)) * ib;
- }
- return(i2);
- }
-
- /* divide long test */
-
- divl(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- j = i + 1;
- ia = 2072397218;
- ib = i + 3;
- ix = i + 2;
- iy = i + 5;
- i2 = i + 4;
- aix[1] = i + 1;
- ai1[1] = i + 7;
- aiy[1] = i + 6;
- ai2[1] = i + 8;
- i1 = i + 1;
-
- pix = &ix;
- pib = &iy;
-
- while(n--)
- {
- i1 = ia / ib / ix / iy / ++i2 / (*pib) / aix[j] / ai1[j] / ++i1;
- i2 = ia / ai2[j] / aiy[j] / (*pix) / iy / ix / ++i1 / ++i2 / ib;
- i1 = ia / ib / ix / iy / ++i2 / (*pib) / aix[j] / ai1[j] / ++i1;
- i2 = ia / ai2[j] / aiy[j] / (*pix) / iy / ix / ++i1 / ++i2 / ib;
- }
- return(i2);
- }
-
- /* assign long test */
-
- asgnl(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- j = i + 1;
- ia = i + 5;
- ib = i + 10;
- iy = i + 15;
- ix = i + 19;
- aix[1] = i + 21;
- aiy[1] = i + 27;
- i1 = i + 9;
- i2 = i + 17;
- ai1[1] = i + 13;
- ai2[1] = i + 217;
-
- pix = &ix;
- pib = &iy;
-
- while(n--)
- {
- ia = i2; ix = ia; iy = ix; i2 = ix; i1 = i2;
- ib = i1; ia = ib; ix = ia; iy = ix; ib = iy;
- *pib = ib; ia = *pib; aix[j] = ia; ix = aix[j];
- aiy[j] = ix; ib = aiy[j]; *pix = ib; i2 = *pix;
- i1 = i2;
- ib = i1; ia = ib; ix = ia; iy = ix; ib = iy;
- *pib = ib; ia = *pib; aix[j] = ia; ix = aix[j];
- aiy[j] = ix; ib = aiy[j]; *pix = ib; i2 = *pix;
- }
- return(i2);
- }
-
- /* compare long test */
-
- cmpl(n)
- int n;
- {
- register int i = 0;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j;
-
- ib = iy =i2 = aiy[1] = ai2[1] = n - 1;
- j = i + 1;
-
- pix = &ix;
- pia = &iy;
-
- while(n--)
- {
- ia = ix = i1 = aix[1] = ai1[1] = n;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ia == ib ) i++;
- if( ix == iy ) i++;
- if( ix == iy ) i++;
- if( ix == iy ) i++;
- if( ix == iy ) i++;
- if( i1 == i2 ) i++;
- if( *pia == *pix ) i++;
- if( aix[j] == ai1[j] ) i++;
- ib = iy =i2 = aiy[1] = ai2[1] = n - 1;
- if( ia != ib ) i++;
- if( ia != ib ) i++;
- if( ix != iy ) i++;
- if( ix != iy ) i++;
- if( aix[j] != aiy[j] ) i++;
- if( i1 != i2 ) i++;
- if( ib < ia ) i++;
- if( ib < ia ) i++;
- if( iy < ix ) i++;
- if( iy < ix ) i++;
- if( ia > ib ) i++;
- if( ix > iy ) i++;
- if( ib <= ix ) i++;
- if( ib <= ix ) i++;
- if( ia >= ib ) i++;
- if( ia >= ib ) i++;
- if( ix >= iy ) i++;
- if( ix >= iy ) i++;
- }
- return(i);
- }
-
- /* bit long test */
-
- bitl(n)
- int n;
- {
- register int i;
- register long ia,ib,*pia,*pib;
- long ix,iy,aix[32],aiy[32],*pix,*piy;
- static long i1,i2,ai1[32],ai2[32],*pi1,*pi2;
- register int j = 1;
-
- i = j + 7;
- ia = i + 5;
- ib = i + 10;
- iy = i + 15;
- ix = i + 19;
- aix[1] = i + 21;
- aiy[1] = i + 27;
- i1 = i + 9;
- i2 = i + 17;
- ai1[1] = i + 13;
- ai2[1] = i + 217;
-
- pix = pia = pi1 = &ix;
- piy = pib = pi2 = &iy;
-
- while(n--)
- {
- i = 2;
- while(i--)
- i1 = ia & ib | (ix >> 1) & (~iy) | (i1 << 2) & i2 |
- (*pia) & (*pib) | aix[j] | aiy[j] |
- *pix | *piy | (~(*pix));
- }
- return(i1);
- }
-
- /* logical and or not test */
-
- logical(n)
- int n;
- {
- register int i = 0;
- register long ia,ib;
- long ix,iy;
- static long i1,i2;
-
- i1 = ib =ix =iy = i + 1;
- i2 = ia = ++i;
- while(n--)
- {
- i = 2;
- while(i--)
- i1 = ia && ib || ix && iy || ia && ib ||
- (!i1) && (!i2) || ix && iy || ia && ix
- && iy && (!i1);
- }
- return(i1);
- }
-
- /* character assign test */
-
- asgnc(n)
- int n;
- {
- register int i = 0;
- register char ca,cb,*pca,*pcb;
- char cx,cy,acx[32],acy[32],*pcx,*pcy;
- static char ac1[32],ac2[32],*pc1,*pc2;
- static char c1 = 'a';
- static char c2 = 'b';
- register int j;
-
- pca = pcx = pc1 = &c1;
- pcb = pcy = pc2 = &c2;
- ca = acx[1] = ac1[1] = c2;
- cb = acy[1] = ac2[1] = c1;
- j = i + 1;
-
- while(n--)
- {
- *pca = c1; *pcb = *pca; *pcx = *pcb; *pcy = *pcx;
- *pc1 = *pcy; *pc2 = *pc1; acx[j] = *pc2; acy[j] = acx[j];
- ac1[j] = acy[j]; ac2[j] = ac1[j]; ca = ac2[j]; cb = ca;
- cx = cb; cy = cx; *pca = cy; *pcb = *pca; *pcx = *pcb;
- *pcy = *pcx; *pc1 = *pcy; acx[j] = *pc1; acy[j] = acx[j];
- ac1[j] = acy[j]; ac2[j] = ac1[j];
- *pcx = ac2[j]; *pcb = *pcx;
- acx[j] = *pcb; acy[j] = acx[j]; *pca = acy[j]; *pcb = *pca;
- ca = *pcb; *pca = ca; c1 = *pca;
- }
- return((int)c1);
- }
-
- /* character compare test */
-
- cmpc(n)
- int n;
- {
- register int i = 0;
- register char ca,cb,*pca,*pcb;
- char cx,cy,acx[32],acy[32],*pcx,*pcy;
- static char ac1[32],ac2[32],*pc1,*pc2;
- static char c1 = 'a';
- static char c2 = 'a';
- register int j;
-
- j = i + 1;
- pca = pcx = pc1 = &c1;
- pcb = pcy = pc2 = &c2;
- cb = acy[1] = ac2[1] = c1;
-
- while(n--)
- {
- ca = acx[1] = ac1[1] = c1 = c2;
- if( ca == cb ) i++;
- if( cx == cy ) i++;
- if( acx[j] == acy[j] ) i++;
- if( acx[j] == acy[j] ) i++;
- if( acx[j] == acy[j] ) i++;
- if( ac1[j] == ac2[j] ) i++;
- if( ac1[j] == ac2[j] ) i++;
- if( *pca == *pcb ) i++;
- if( *pca == *pcb ) i++;
- if( *pca == *pcb ) i++;
- if( *pca == *pcb ) i++;
- if( *pcx == *pcy ) i++;
- if( *pcx == *pcy ) i++;
- ca = acx[1] = ac1[1] = c1 = 'b';
- if( ca != cb ) i++;
- if( acx[j] != acy[j] ) i++;
- if( ac1[j] != ac2[j] ) i++;
- if( *pca != *pcb ) i++;
- if( *pca != *pcb ) i++;
- if( *pcx != *pcy ) i++;
- if( cb < ca ) i++;
- if( ac2[j] < ac1[j] ) i++;
- if( *pcb < *pca ) i++;
- if( *pcy < *pcx ) i++;
- if( acx[j] > ac2[j] ) i++;
- if( *pca > *pcb ) i++;
- if( *pcb <= *pcx ) i++;
- if( acx[j] >= acy[j] ) i++;
- if( *pca >= *pcb ) i++;
- if( *pca > *pc2 ) i++;
- if( *pcx >= *pcb ) i++;
- }
- return(i);
- }
-
- /* character bit test */
-
- bitc(n)
- int n;
- {
- register int i;
- register char ca,cb,*pca,*pcb;
- char cx,cy,acx[32],acy[32],*pcx,*pcy;
- static char ac1[32],ac2[32],*pc1,*pc2;
- static char c1 = 'A';
- static char c2 = 'B';
- register int j = 1;
-
- pca = pcx = pc1 = &c1;
- pcb = pcy = pc2 = &c2;
- ca = cx = acx[1] = ac1[1] = c1;
- cb = cy = acy[1] = ac2[1] = c2;
- c2 = ca;
-
- while(n--)
- {
- c1 = ca & cb & cx
- & acx[j] & acy[j] & cy
- & *pca & *pcb & *pcx
- & *pcy & *pc1 & *pc2
- | ca | cb
- | cx | cy | acx[j]
- | acy[j] | ac1[j] | ac2[j]
- | *pca | *pcb | *pcx
- | *pcy | *pc1 | *pc2
- | (ca << 1) | (cb >> 2) | ~c2
- | c1 ;
- }
- return((int)c1);
- }
-
- /* function call no parameters */
-
- funct0(n)
- int n;
- {
- register int i,j;
-
- j = 0;
- while (n--)
- {
- i = 2;
- while(i--)
- {
- j += func0( ); j += func0( ); j += func0( ); j += func0( );
- j += func0( ); j += func0( ); j += func0( ); j += func0( );
- j += func0( ); j += func0( ); j += func0( ); j += func0( );
- j += func0( ); j += func0( ); j += func0( ); j += func0( );
- }
- }
- return(j);
- }
- func0()
- {
- static int j = 0;
- return(++j);
- }
-
- /* function call one parameter test */
-
- funct1(n)
- int n;
- {
- register int i,j;
-
- j = 0;
- while (n--)
- {
- i = 2;
- while(i--)
- {
- j += func1(n); j += func1(n); j += func1(n); j += func1(n);
- j += func1(n); j += func1(n); j += func1(n); j += func1(n);
- j += func1(n); j += func1(n); j += func1(n); j += func1(n);
- j += func1(n); j += func1(n); j += func1(n); j += func1(n);
- }
- }
- return(j);
- }
- func1(n)
- int n;
- {
- return(++n);
- }
-
- /* function call two prameters test */
-
- funct2(n)
- int n;
- {
- register int i,j;
-
- j = 0;
- while (n--)
- {
- i = 2;
- while(i--)
- {
- j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
- j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
- j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
- j += func2(i,n); j += func2(i,n); j += func2(i,n); j += func2(i,n);
- }
- }
- return(j);
- }
- func2(i,j)
- int i,j;
- {
- return(i+j);
- }
-
-
- /* fork test */
-
- sys1(n)
- int n;
- {
- register int c;
- int status;
-
- while(n--)
- {
- c = fork( );
- if( c == 0 )
- _exit(0);
- if( c < 0 )
- {
- printf("unable to perform fork\n");
- return;
- }
- if( c != wait(&status) )
- {
- printf("wait does not return the correct child process id\n");
- return;
- }
- }
- }
-
- /* getpid test */
-
- sys3(n)
- int n;
- {
- register int i;
- while(n--)
- i = getpid( );
- return(i);
- }
-
- /* sbrk test */
-
- sys4(n)
- int n;
- {
- register int i;
- while(n--)
- i = sbrk(0);
- return(i);
- }
- sys5(n)
- int n;
- {
- register int i;
- while(n--)
- i = umask(0);
- return(i);
- }
- static long start,end;
- static double stime,ltime,factor;
- static double ddelta,dstep,ddcnt;
- static double tdelta,tstep,ttcnt;
- static int nd,nt,nl,dd,td,i,ddcount,ttcount,lflag;
- struct teststru
- {
- int nops;
- int (*funcall)( );
- };
- static struct teststru test[NOTEST] =
- {
- 117,adds,
- 93,subs,
- 11,muls,
- 5,divs,
- 189,asgns,
- 141,cmps,
- 949,addl,
- 751,subl,
- 91,mull,
- 43,divl,
- 1521,asgnl,
- 1135,cmpl,
- 689,bitl,
- 465,logical,
- 878,asgnc,
- 655,cmpc,
- 354,bitc,
- 593,funct0,
- 976,funct1,
- 344,funct2,
- 1,sys3,
- 1,sys4,
- 1,sys5
- };
- main( )
- {
- static char machine[100],s[100];
- static int noproc;
- static int nomp,novol;
- {
- register int j,n,i;
-
- if( (stream = fopen("config","r")) == NULL )
- {
- printf("unable to open file config\n");
- exit(0);
- }
- i = 1;
- while( i <=3 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",&nomp);
- break;
- case 2:
- sscanf(s,"%d",&noproc);
- break;
- case 3:
- sscanf(s,"%d",&novol);
- break;
- }
- i++;
- }
- fclose(stream);
- readmac:
- printf("ENTER THE NAME OR DESCRIPTION OF THIS MACHINE (5 TO 40 CHARTERS)\n$");
- gets(machine);
- if( (strlen(machine) < 5) || (strlen(machine) > 40) )
- {
- printf("THE MACHINE NAME OR DESCRIPTION HAS AN INCORRECT LENGTH\n");
- goto readmac;
- }
- if( (stream = fopen("answers","w")) == NULL )
- {
- printf("unable to open file answers\n");
- exit(1);
- }
- fprintf(stream,"%s\n",machine);
- fprintf(stream,"%d\n",noproc);
- fclose(stream);
- ptime(1);
- start = ptime(1);
- for(j=0; j<NOTEST; j++)
- {
- n = test[j].nops;
- (*test[j].funcall)(n);
- }
- end = ptime(1);
- stime = (double)(end - start) / 60.0;
- if( (stream = fopen("crunout","w")) == NULL )
- {
- printf("unable to open file crunout\n");
- exit(1);
- }
- fprintf(stream,"%s\n",machine);
- fprintf(stream,"TESTTIME = %9.5f\n",stime);
- }
- {
- register int dc,tc,i;
- nl = 1000;
- nt = 30;
- nd = 32;
- lflag = 1;
- loop:
- dc = 1;
- tc = 1;
- ddcount = 0;
- ttcount = 0;
- dstep = 0.0;
- ddelta = (double)nd / (double)nl;
- tstep = 0.0;
- tdelta = (double)nt / (double)nl;
- factor = 2.100;
- nl++;
- start = ptime(1);
- for(i=1; i<=nl; i++)
- {
- dstep += ddelta;
- ddcnt = (double)dc;
- if( dstep >= ddcnt )
- {
- dc++;
- }
- tstep += tdelta;
- ttcnt = (double)tc;
- if( tstep >= ttcnt )
- {
- tc++;
- }
- }
- end = ptime(1);
- ltime = (double)(end - start) / 60.0;
- fprintf(stream,"nl = %d ",nl);
- fprintf(stream,"ltime = %9.5f dcount = %d tcount = %d\n",ltime,dc,tc);
- if( lflag )
- {
- nl = (int)( (double)nl * (stime / (ltime * factor) ) );
- lflag = 0;
- goto loop;
- }
- fclose(stream);
- if( (stream = fopen("loopcount","w")) == NULL )
- {
- printf("unable to open file loopcount\n");
- exit(1);
- }
- fprintf(stream,"%d\n",nl);
- fclose(stream);
- if( (stream = fopen("subele","a")) == NULL )
- {
- printf("unable to open file subele\n");
- exit(1);
- }
- fprintf(stream,"\f\n\n");
- fprintf(stream," S Y S T E M U N D E R T E S T %s\n\n\n",machine);
- fprintf(stream,"\n C P U S U B S Y S T E M \n");
- fprintf(stream," Time to Execute CRUN %9.3f\n",stime);
- fprintf(stream," Realative speed of a Single CPU %9.3f\n", factor / stime );
- fprintf(stream," Number of Main CPU Processors %d\n",nomp);
- fclose(stream);
- }
- if( nomp > 1 )
- {
- if( execl("cpurun","cpurun",NULL) < 0 )
- {
- printf(" unable to execute cpurun \n");
- }
- }
- exit(0);
- }
-
- long
- ptime(tflag)
- int tflag;
- {
- static long tm[4];
- static int first = 1;
- static long tstart = 0;
- static long xtime = 0;
- long times( );
-
- if( tflag && first )
- {
- tstart = times(tm);
- first = 0;
- return(0);
- }
- xtime = times(tm);
- if( tflag )
- {
- xtime = xtime - tstart;
- }
- else
- {
- xtime = tm[0];
- }
- return(xtime);
- }
-
- SHAR_EOF
- fi
- if test -f 'drun.c'
- then
- echo shar: "will not over-write existing file 'drun.c'"
- else
- cat << \SHAR_EOF > 'drun.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include "sys/types.h"
- #include "sys/times.h"
- #include "stdio.h"
- #define MAXPROC 64
-
- #define NULL 0
-
-
- static int diskrfd,diskwfd,toggle;
- static double timex;
-
-
- static int noproc,maxjobs;
- static int nomp;
- static int count,itotal,status;
- static int pid,cid,tagid;
- static double stime;
- static char s[100];
- static int tablepid[MAXPROC];
- static int notty,nodiskw,nodiskr,nouser;
- static double jobs;
- static long start,end,ftime;
-
-
- FILE * stream;
- static char line[32],buffer[1024],pbuffer[32],bufin[1024];
- static char namev[8][80];
- static float pcnt[8],sum;
- static int novol,fsum,nfile[8],lng,len[8];
- static int total,ll[8],hl[8],cnt[8],vol,disk[200];
- static int dist,sdist[8],oldf[8];
- static int file1[200] =
- {
- 38,113,51,10,12,149,84,25,89,137,
- 166,95,167,31,82,124,194,52,154,161,
- 28,85,168,165,162,153,44,163,22,57,
- 79,151,70,48,29,6,138,14,116,181,
- 143,33,160,71,136,164,129,75,114,88,
- 2,34,182,186,106,53,73,193,148,120,
- 156,169,195,191,126,86,11,54,121,39,
- 185,125,15,176,144,19,123,65,173,13,
- 99,16,127,46,139,78,74,171,152,192,
- 122,128,170,41,175,172,145,115,61,45,
- 103,72,100,7,130,142,131,155,94,47,
- 80,146,92,90,32,132,17,49,189,196,
- 96,174,93,179,50,197,133,81,177,178,
- 62,134,55,108,83,101,18,135,30,105,
- 140,35,188,36,119,198,109,77,111,76,
- 150,190,157,87,37,147,43,199,180,117,
- 141,158,9,97,0,183,91,98,104,40,
- 20,159,63,184,187,102,1,3,64,4,
- 5,8,107,21,110,58,56,59,23,68,
- 24,60,26,112,27,66,42,118,67,69
- };
- static int file2[200] =
- {
- 158,115,27,19,86,167,60,143,183,166,
- 178,111,54,145,136,105,102,67,53,96,
- 188,144,6,3,34,120,4,118,127,146,
- 184,94,59,157,106,190,116,62,25,134,
- 22,137,179,1,61,5,44,93,139,121,
- 171,117,15,55,174,48,35,110,10,49,
- 162,197,112,199,107,182,0,165,180,7,
- 75,65,71,97,98,87,149,56,101,159,
- 68,198,113,168,189,26,187,17,191,83,
- 147,185,160,176,181,85,89,114,28,99,
- 70,129,100,8,57,74,23,24,16,76,
- 169,177,51,163,33,108,77,148,175,192,
- 135,40,36,92,193,69,194,103,186,80,
- 195,196,37,63,2,9,29,109,11,12,
- 78,13,42,14,142,18,119,82,20,72,
- 79,138,164,30,132,156,81,21,161,31,
- 32,38,39,41,64,84,104,43,122,45,
- 66,150,130,46,125,47,50,52,123,126,
- 88,58,170,73,90,91,131,95,124,128,
- 133,140,141,151,152,153,154,155,172,173
- };
-
- /* disk open */
-
- dkopen(n)
- int n;
- {
- register int d,f1,f2,lng;
-
- d = disk[n];
- f1 = file1[n];
- f2 = file2[n];
- lng = len[d];
-
- sprintf(&namev[d][lng],"%03d",f1);
- if( (diskrfd = open(&namev[d][0],0)) < 0 )
- {
- printf("can not open %s for disk read\n",&namev[d][0]);
- return;
- }
- sprintf(&namev[d][lng],"%03d",f2);
- if( (diskwfd = open(&namev[d][0],1)) < 0 )
- {
- printf("can not open %$ for disk write\n",&namev[d][0]);
- return;
- }
- return;
- }
- main(argc,argv)
- int argc;
- char * argv[ ];
- {
- register int i,j,k;
-
- if( argc != 3 )
- {
- printf("incorrect number of arguments for run\n");
- exit(1);
- }
- for(k=0; k<1024; k++)
- {
- buffer[k] = 'A';
- }
- if( (stream = fopen("config","r")) == NULL )
- {
- printf("unable to open file config\n");
- exit(1);
- }
- i = 1;
- while( i <=3 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",&nomp);
- break;
- case 2:
- sscanf(s,"%d",&noproc);
- break;
- case 3:
- sscanf(s,"%d",&novol);
- break;
- }
- i++;
- }
- sum = 0.0;
- for(i=0; i<novol; i++)
- {
- lab2:
- if( fgets(s,100,stream) == NULL)
- {
- printf("not enough disk volume names\n");
- exit(1);
- }
- if( s[0] == '#' ) goto lab2;
- sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
- sum += pcnt[i];
- }
- fclose(stream);
- sscanf(argv[1],"%d",¬ty);
- sscanf(argv[2],"%d",&nodiskr);
- maxjobs = 200;
- fsum = 0;
- for(i=0; i<novol; i++)
- {
- nfile[i] = (int)( ( (pcnt[i] * 200.0) / sum ) );
- fsum += nfile[i];
- }
- for(i=0; i<novol; i++)
- {
- if( fsum < 200 )
- {
- nfile[i]++;
- fsum++;
- }
- else
- {
- break;
- }
- }
- for(i=0; i<novol; i++)
- {
- lng = strlen(&namev[i][0]);
- if( namev[i][lng-1] != '/')
- {
- namev[i][lng++] = '/';
- }
- namev[i][lng++] = 'd';
- namev[i][lng++] = 'k';
- len[i] = lng;
- namev[i][lng+3] = '\0';
- sprintf(&namev[i][len[i]],"%03d",i);
- }
- total = 0;
- for(i=0; i<novol; i++)
- {
- cnt[i] = 0;
- oldf[i] = 0;
- sdist[i] = 0;
- ll[i] = total;
- total += nfile[i];
- hl[i] = total - 1;
- }
- for(j=0; j<200; j++)
- {
- k = rand( ) % 200;
- for(i=0; i<novol; i++)
- {
- if( (k>=ll[i]) && (k<=hl[i]) )
- {
- vol = i;
- break;
- }
- }
- disk[j] = vol;
- }
- ptime(1);
- count = 0;
- itotal = 0;
- for(i=1; i<=noproc; i++)
- {
- tablepid[i] = 0;
- }
- start = ptime(1);
- i = -1;
- while( 1 )
- {
- i++;
- tagid = getid( );
- if( ( pid = fork( ) ) == 0 )
- {
- if( nodiskr )
- dkopen(i);
- toggle = 1;
- for(i=1; i<=nodiskr; i++)
- {
- if( toggle )
- {
- if( read(diskrfd,bufin,sizeof bufin)
- != sizeof bufin )
- {
- printf("can not read %s on disk read\n",&namev[disk[i]][0]);
- exit(1);
- }
- toggle = 0;
- }
- else
- {
- if( write(diskwfd,buffer,sizeof buffer)
- != sizeof buffer )
- {
- printf("can not write %s on on disk write\n",&namev[disk[i]][0]);
- exit(1);
- }
- toggle = 1;
- }
- }
- if( nodiskr )
- {
- close(diskrfd);
- close(diskwfd);
- }
- exit(0);
- }
- if( pid > 0 )
- {
- insert(pid);
- count++;
- }
- else
- {
- printf(" can not fork child process\n");
- exit(1);
- }
- if( count == noproc )
- {
- cid = wait(&status);
- count--;
- freeit(cid);
- if( ++itotal >= (maxjobs + 1 - noproc) )
- {
- while( count > 0 )
- {
- cid = wait(&status);
- count--;
- itotal++;
- freeit(cid);
- }
- goto ENDIT;
- }
- }
- }
- ENDIT:
- end = ptime(1);
- if( (stream = fopen("answers","a")) == NULL )
- {
- printf("unable to open file answers\n");
- exit(1);
- }
- ftime = end - start;
- timex = ( (double)ftime ) / 1000.0;
- jobs = ((double)maxjobs * 60.0) / timex;
- fprintf(stream,"%3d %3d %9.3f %9.3f\n",
- 1000,nodiskr,jobs,timex);
- fclose(stream);
- if( notty )
- {
- if( (stream = fopen("subele","a")) == NULL )
- {
- printf("unable to open file subele\n");
- exit(1);
- }
- fprintf(stream,"\n D I S K S U B S Y S T E M \n");
- fprintf(stream," Effective Disk System rate %9.4f K bytes per Second\n",
- (double)(nodiskr * maxjobs) / timex);
- fprintf(stream," Average Time per Disk Request %9.5f Seconds\n",
- timex / ( (double) (nodiskr * maxjobs) ) );
- fprintf(stream," Total Disk Request %d",nodiskr * maxjobs);
- fprintf(stream," Request Size %d K bytes\n",1);
- fprintf(stream," Time for All Disk Request %9.3f Seconds\n",timex);
- fprintf(stream," Number of Disk Units %d\n",novol);
- for(i=0; i<novol; i++)
- {
- fprintf(stream," Disk Unit %d Percent %9.3f\n",i+1,pcnt[i]);
- }
- fprintf(stream," Disk Request per Job %d\n",nodiskr);
- fprintf(stream," Jobs per Minute %9.3f\n",jobs);
- fclose(stream);
- }
- exit(0);
- }
-
- long
- ptime(tflag)
- int tflag;
- {
- static long tm[4];
- static int first = 1;
- static long tstart = 0;
- static long xtime = 0;
- long times( );
- register int i;
-
- if( tflag && first )
- {
- tstart = times(tm);
- first = 0;
- return(0);
- }
- xtime = times(tm);
- if( tflag )
- {
- xtime = (1000 * (xtime - tstart)) / 60;
- }
- else
- {
- xtime = (1000 * tm[0] ) / 60;
- }
- return(xtime);
- }
-
- insert(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- tablepid[j] = pid;
- return(pid);
- }
- }
- printf("no free space on insert pid\N");
- return(0);
- }
-
- freeit(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == pid )
- {
- tablepid[j] = 0;
- return(j);
- }
- }
- printf("pid not found in table on free\n");
- return(0);
- }
-
- getid( )
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- return(j);
- }
- }
- printf("no free space on getpid\n");
- return(0);
- }
- SHAR_EOF
- fi
- if test -f 'makefiles.c'
- then
- echo shar: "will not over-write existing file 'makefiles.c'"
- else
- cat << \SHAR_EOF > 'makefiles.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include <stdio.h>
-
- FILE * stream;
-
- static char bufferw[5120],bufferr[5120];
- static char s[100],namev[8][80];
- static double pcnt[8];
- static int fdr,novol,lng;
- static int nomp,noproc;
-
- main( )
- {
- register int i,k,j;
- register char * pw;
- register char * pr;
-
- pw = bufferw;
- pr = bufferr;
- for(i=0; i<5120; i++);
- {
- *pw++ = 'w';
- *pr++ = 'r';
- }
- if( (stream = fopen("config","r")) == NULL )
- {
- printf("unable to open file config\n");
- exit(1);
- }
- i = 1;
- while( i <=3 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",&nomp);
- break;
- case 2:
- sscanf(s,"%d",&noproc);
- break;
- case 3:
- sscanf(s,"%d",&novol);
- break;
- }
- i++;
- }
- for(i=0; i<novol; i++)
- {
- lab2:
- if( fgets(s,100,stream) == NULL)
- {
- printf("not enough disk volume names\n");
- exit(1);
- }
- if( s[0] == '#' ) goto lab2;
- sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
- }
- fclose(stream);
- for(i=0; i<novol; i++)
- {
- lng = strlen(&namev[i][0]);
- if( namev[i][lng-1] != '/')
- {
- namev[i][lng++] = '/';
- }
- namev[i][lng++] = 'd';
- namev[i][lng++] = 'k';
- namev[i][lng+3] = '\0';
- for(j=0; j<=199; j++)
- {
- sprintf(&namev[i][lng],"%03d",j);
- if( (fdr = creat(&namev[i][0],0666)) < 0 )
- {
- printf("can not open %s file\n",
- &namev[i][0]);
- exit(1);
- }
- for(k=1; k<=4; k++)
- {
- if( write(fdr,bufferr,5120) != 5120 )
- {
- printf("unable to write read buffer %3d\n",i);
- exit(1);
- }
- }
- close(fdr);
- printf("name = %s\n",&namev[i][0]);
- }
- }
- }
- SHAR_EOF
- fi
- if test -f 'rplot.c'
- then
- echo shar: "will not over-write existing file 'rplot.c'"
- else
- cat << \SHAR_EOF > 'rplot.c'
- #include <stdio.h>
-
- static int noproc1,noproc2;
- static int notty1,notty2,nodkr1,nodkr2,toggle;
- static char screen[45][108],c[5],s1[101],s2[101];
- static double xmax,xmin,ymax,ymin;
- static int xi[10][50],yi[10][50];
- static double x[10][50],y[10][50];
- static int tagv,xv;
- static char tagc[11] =
- {"ABCEFGHIJK"};
- static int flag = 1;
- static int tagi[10] =
- {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
- static int tagh = -1;
- static int tag[10] =
- {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
- static double xu,yu,xd,yd;
- static float jobs1,jobs2;
- FILE * stream1;
- FILE * stream2;
- static char ylab[11][8],xlab[10][8];
- static char labtemp[10];
- static char xaxis[92] = {
- "+---------+---------+---------+---------+---------+---------+---------+---------+---------+"};
- static char yaxis[42] = {
- "+|||+|||+|||+|||+|||+|||+|||+|||+|||+|||+"};
- static char letters[27] = {
- "abcdefghijklmnopqrstuvwxyz"};
- static char f = '\f';
- static char var1[ ] =
- {" R = RATIO OF TWO SYSTEMS THROUGHPUT"};
- static char var2[ ] =
- {" D = DISK READ + WRITE REQUEST PER JOB"};
- static char var3[ ] =
- {" T = TTY WRITE REQUEST PER JOB"};
- static char title1[100],title2[100];
-
- main(argc,argv)
- int argc;
- char * argv[ ];
- {
- register int i,n,j,j1,j2,k;
-
- if( argc != 3 )
- {
- printf("incorect number of arguments\n");
- exit(1);
- }
- if( (stream1 = fopen(argv[1],"r")) == NULL )
- {
- printf("unable to open file %s\n",argv[1]);
- exit(2);
- }
- if( (stream2 = fopen(argv[2],"r")) == NULL )
- {
- printf("unable to open file %s\n",argv[2]);
- exit(2);
- }
- /* read in titles */
- if( fgets(title1,100,stream1) == NULL )
- {
- printf("The file %s is empty\n",argv[1]);
- exit(1);
- }
- if( fgets(title2,100,stream2) == NULL )
- {
- printf("The file %s is empty\n",argv[2]);
- exit(1);
- }
- if( fgets(s1,100,stream1) == NULL )
- {
- printf("The file %s is empty\n",argv[1]);
- exit(1);
- }
- sscanf(s1,"%d",&noproc1);
- if( fgets(s2,100,stream2) == NULL )
- {
- printf("The file %s is empty\n",argv[2]);
- exit(1);
- }
- sscanf(s2,"%d",&noproc2);
- n = strlen(title1);
- title1[n-1] = '\0';
- n = strlen(title2);
- title2[n-1] = '\0';
- /* clear screen */
- for(i=0; i<=44; i++)
- {
- for(j=0; j<=107; j++)
- {
- if( j == 107 )
- screen[i][j] = '\0';
- else
- screen[i][j] = ' ';
- }
- }
- /* put in x and y axis */
- j = 11;
- for(i=0; i<=40; i++)
- {
- screen[i][j] = yaxis[i];
- }
- i = 41;
- k = 0;
- j = 12;
- while( j <= 102 )
- {
- screen[i][j] = xaxis[k++];
- j++;
- }
- /* read in y and x values */
- i = 0;
- while( (fgets(s1,100,stream1) != NULL) &&
- (fgets(s2,100,stream2) != NULL) )
- {
- sscanf(s1,"%d %d %f",¬ty1,&nodkr1,&jobs1);
- sscanf(s2,"%d %d %f",¬ty2,&nodkr2,&jobs2);
- if( (notty1 != notty2) || (nodkr1 != nodkr2) )
- {
- printf("benchmark data files are out of sequence\n");
- exit(1);
- }
- if(flag)
- {
- tagv = notty1;
- xv = nodkr1;
- }
- else
- {
- tagv = nodkr1;
- xv = notty1;
- }
- for(i=0; i<=tagh; i++)
- {
- if(tagv == tag[i])
- {
- j = i;
- goto lab1;
- }
- }
- j = ++tagh;
- tag[j] = tagv;
- lab1:
- k = ++tagi[j];
- x[j][k] = (double)xv;
- y[j][k] = jobs1 / jobs2;
- }
- fclose(stream1);
- fclose(stream2);
- n = i - 1;
- xmax = xmin = x[0][0];
- ymax = ymin = y[0][0];
- /* find min and max of x and y */
- for(i=0; i<=tagh; i++)
- {
- for(j=0; j<=tagi[i]; j++)
- {
- if( x[i][j] > xmax ) xmax = x[i][j];
- if( x[i][j] < xmin ) xmin = x[i][j];
- if( y[i][j] > ymax ) ymax = y[i][j];
- if( y[i][j] < ymin ) ymin = y[i][j];
- }
- }
- yu = (ymax - ymin) / 40.0;
- xu = (xmax - xmin) / 90.0;
- /* find x,y value location on screen */
- for(i=0; i<=tagh; i++)
- {
- for(j=0; j<=tagi[i]; j++)
- {
- yd = (y[i][j] - ymin) / yu;
- xd = (x[i][j] - xmin) / xu;
- j1 = 40 - ((int)(yd + .5));
- j2 = (int)(xd + .5);
- yi[i][j] = j1;
- xi[i][j] = j2;
- j2 += 12;
- n = j2;
- k = 0;
- toggle = 1;
- while( screen[j1][j2] != ' ' )
- {
- if(toggle)
- {
- toggle = 0;
- j2 = n + (++k);
- }
- else
- {
- toggle = 1;
- j2 = n - k;
- }
- }
- screen[j1][j2] = tagc[i];
- }
- }
- /* generate label values for x and y axis */
- for(i=0; i<=10; i++)
- {
- yd = ( (double)i * 4.0 * yu) + ymin;
- sprintf(labtemp,"%8.3f",yd);
- for(j=0; j<=7; j++)
- {
- ylab[i][j] = labtemp[j];
- }
- }
- for(i=0; i<=9; i++)
- {
- xd = ((double)i * 10.0 * xu) + xmin;
- sprintf(labtemp,"%8.1f",xd);
- for(j=0; j<=7; j++)
- {
- xlab[i][j] = labtemp[j];
- }
- }
- /* place the axis label values on the screen */
- k = 40;
- for(i=0; i<=10; i++)
- {
- j1 = 0;
- for(j=3; j<=10; j++)
- {
- screen[k][j] = ylab[i][j1++];
- }
- k -= 4;
- }
- k = 42;
- j2 = 6;
- for(i=0; i<=9; i++)
- {
- j1 = j2;
- for(j=0; j<=7; j++)
- {
- screen[k][j1++] = xlab[i][j];
- }
- j2 += 10;
- }
- screen[20][2] = 'R';
- if(flag)
- screen[43][46] = 'D';
- else
- screen[43][46] = 'T';
- printf("\f");
- for(i=0; i<=43; i++)
- {
- printf("%s\n",&screen[i][0]);
- }
- printf("%s",var1);
- if(flag)
- printf("%s\n",var2);
- else
- printf("%s\n",var3);
- printf(" CURVE SYMBOL - NUMBER OF TTY WRITE REQUEST PER JOB\n");
- printf(" ");
- for(i=0; i<=tagh; i++)
- {
- printf("CURVE %c %3d ",tagc[i],tag[i]);
- }
- printf("\n MULTIUSER LEVELS EQUAL %2d %2d\n",noproc1,noproc2);
- printf(" *** THE THROUGHPUT RATIO OF %s VRS %s ***\n",
- title1,title2);
- exit(0);
- }
- SHAR_EOF
- fi
- if test -f 'tplot.c'
- then
- echo shar: "will not over-write existing file 'tplot.c'"
- else
- cat << \SHAR_EOF > 'tplot.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include <stdio.h>
-
- static int noproc;
- static int notty,nodiskr,toggle;
- static char screen[51][111],c[5],s[101],s1[100];
- static double xmax,xmin,ymax,ymin;
- static int xi[10][50],yi[10][50];
- static double x[10][50],y[10][50];
- static int tagv,xv;
- static char tagc[11] =
- {"DTABCEFGHI"};
- static int flag = 1;
- static int tagi[10] =
- {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
- static int tagh = -1;
- static int tag[10] =
- {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
- static double xu,yu,xd,yd;
- static float jobs;
- FILE * stream;
- static char ylab[11][8],xlab[10][8];
- static char labtemp[10];
- static char xaxis[92] = {
- "+---------+---------+---------+---------+---------+---------+---------+---------+---------+"};
- static char yaxis[42] = {
- "+|||+|||+|||+|||+|||+|||+|||+|||+|||+|||+"};
- static char letters[27] = {
- "abcdefghijklmnopqrstuvwxyz"};
- static char f = '\f';
- static char var1[ ] =
- {" J = THROUGHPUT - JOBS PER MINUTE"};
- static char var2[ ] =
- {" DISK = DISK READ + WRITE REQUEST PER JOB"};
- static char var3[ ] =
- {" T = TTY WRITE REQUEST PER JOB"};
- static char title[100];
-
- main(argc,argv)
- int argc;
- char * argv[ ];
- {
- register int i,n,j,j1,j2,k;
-
- if( argc != 2 )
- {
- printf("incorect number of arguments\n");
- exit(1);
- }
- if( (stream = fopen(argv[1],"r")) == NULL )
- {
- printf("unable to open file %s\n",argv[1]);
- exit(2);
- }
- /* read in title */
- if( fgets(title,100,stream) == NULL )
- {
- printf("The file %s is empty\n",argv[1]);
- exit(1);
- }
- n = strlen(title);
- title[n-1] = '\0';
- if( fgets(s,100,stream) == NULL )
- {
- printf("The file %s is empty\n",argv[1]);
- exit(1);
- }
- sscanf(s,"%d",&noproc);
- /* clear screen */
- for(i=0; i<=50; i++)
- {
- for(j=0; j<=110; j++)
- {
- screen[i][j] = ' ';
- if( (i==0) || (i==50) )
- screen[i][j] = '*';
- if( (j==0) || (j==109) )
- screen[i][j] = '*';
- if( j == 110 )
- screen[i][j] = '\0';
- }
- }
- /* put in x and y axis */
- j = 13;
- j1 = 1;
- for(i=0; i<=40; i++)
- {
- screen[j1++][j] = yaxis[i];
- }
- i = 42;
- k = 0;
- j = 14;
- while( j <= 104 )
- {
- screen[i][j] = xaxis[k++];
- j++;
- }
- /* read in y and x values */
- i = 0;
- while( fgets(s,100,stream) != NULL )
- {
- sscanf(s,"%d %d %f",¬ty,&nodiskr,&jobs);
- if(flag)
- {
- tagv = notty;
- xv = nodiskr;
- }
- else
- {
- tagv = nodiskr;
- xv = notty;
- }
- for(i=0; i<=tagh; i++)
- {
- if(tagv == tag[i])
- {
- j = i;
- goto lab1;
- }
- }
- j = ++tagh;
- tag[j] = tagv;
- lab1:
- k = ++tagi[j];
- x[j][k] = (double)xv;
- y[j][k] = jobs;
- }
- fclose(stream);
- n = i - 1;
- xmax = xmin = x[0][0];
- ymax = ymin = y[0][0];
- /* find min and max of x and y */
- for(i=0; i<=tagh; i++)
- {
- for(j=0; j<=tagi[i]; j++)
- {
- if( x[i][j] > xmax ) xmax = x[i][j];
- if( x[i][j] < xmin ) xmin = x[i][j];
- if( y[i][j] > ymax ) ymax = y[i][j];
- if( y[i][j] < ymin ) ymin = y[i][j];
- }
- }
- yu = (ymax - ymin) / 40.0;
- xu = (xmax - xmin) / 90.0;
- /* find x,y value location on screen */
- for(i=0; i<=tagh; i++)
- {
- for(j=0; j<=tagi[i]; j++)
- {
- yd = (y[i][j] - ymin) / yu;
- xd = (x[i][j] - xmin) / xu;
- j1 = 41 - ((int)(yd + .5));
- j2 = (int)(xd + .5);
- yi[i][j] = j1;
- xi[i][j] = j2;
- j2 += 14;
- n = j2;
- k = 0;
- toggle = 1;
- while( screen[j1][j2] != ' ' )
- {
- if(toggle)
- {
- toggle = 0;
- j2 = n + (++k);
- }
- else
- {
- toggle = 1;
- j2 = n - k;
- }
- }
- screen[j1][j2] = tagc[i];
- }
- }
- /* generate label values for x and y axis */
- for(i=0; i<=10; i++)
- {
- yd = ( (double)i * 4.0 * yu) + ymin;
- sprintf(labtemp,"%8.3f",yd);
- for(j=0; j<=7; j++)
- {
- ylab[i][j] = labtemp[j];
- }
- }
- for(i=0; i<=9; i++)
- {
- xd = ((double)i * 10.0 * xu) + xmin;
- sprintf(labtemp,"%8.1f",xd);
- for(j=0; j<=7; j++)
- {
- xlab[i][j] = labtemp[j];
- }
- }
- /* place the axis label values on the screen */
- k = 41;
- for(i=0; i<=10; i++)
- {
- j1 = 0;
- for(j=4; j<=11; j++)
- {
- screen[k][j] = ylab[i][j1++];
- }
- k -= 4;
- }
- k = 43;
- j2 = 8;
- for(i=0; i<=9; i++)
- {
- j1 = j2;
- for(j=0; j<=7; j++)
- {
- screen[k][j1++] = xlab[i][j];
- }
- j2 += 10;
- }
- screen[21][2] = 'J';
- if(flag)
- {
- screen[44][48] = 'D';
- screen[44][49] = 'I';
- screen[44][50] = 'S';
- screen[44][51] = 'K';
- }
- else
- screen[44][48] = 'T';
- sprintf(s,"%s\0",var1);
- if(flag)
- sprintf(s1,"%s\0",var2);
- else
- sprintf(s1,"%s\0",var3);
- strcat(s,s1);
- scrcpy(45,s);
- sprintf(s," CURVE SYMBOL - NUMBER OF TTY WRITE REQUEST PER JOB\0");
- scrcpy(46,s);
- sprintf(s," \0");
- for(i=2; i<=tagh; i++)
- {
- sprintf(s1,"CURVE %c %3d \0",tagc[i],tag[i]);
- strcat(s,s1);
- }
- scrcpy(47,s);
- sprintf(s," I/O ONLY --- CURVE T TTY ONLY CURVE D DISK ONLY MULTIUSER LEVEL EQUALS %2d\0",noproc);
- scrcpy(48,s);
- sprintf(s," %s\0",title);
- scrcpy(49,s);
- printf("\f");
- for(i=0; i<=50; i++)
- {
- printf("%s\n",&screen[i][0]);
- }
- printf("\f");
- exit(0);
- }
-
- scrcpy(n,s)
- int n;
- char s[ ];
- {
- register int i,j;
-
- i = n;
- j = 1;
- while( s[j] != '\0' )
- {
- screen[i][j] = s[j];
- j++;
- }
- return;
- }
- SHAR_EOF
- fi
- if test -f 'trun.c'
- then
- echo shar: "will not over-write existing file 'trun.c'"
- else
- cat << \SHAR_EOF > 'trun.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include "sys/types.h"
- #include "sys/times.h"
- #include "stdio.h"
- #include "termio.h"
- #define MAXPROC 64
-
- #define NULL 0
-
-
- static int ttyfd;
- static double timex;
- static struct termio ttystru;
-
-
- static int noproc,maxjobs;
- static int nomp,nottyc,nottycl;
- static int count,itotal,status;
- static int pid,cid,tagid;
- static double stime;
- static char tty[MAXPROC][14],s[100];
- static int tablepid[MAXPROC];
- static int notty,nochar,tnotty,tnochar,nodiskr,nouser;
- static double jobs;
- static long start,end,ftime;
-
-
- FILE * stream;
- static char line[32],buffer[1024],pbuffer[32],bufin[1024];
- static char namev[8][80];
- static double pcnt[8],sum;
- static int novol,fsum,nfile[8],lng,len[8];
- /* tty open */
-
- ttyopen( )
- {
-
- if( (ttyfd = open(&tty[tagid][0],1)) < 0 )
- {
- printf("can not open %s for tty write\n",&tty[tagid][0]);
- return;
- }
- ioctl(ttyfd,TCGETA,&ttystru);
- ttystru.c_cflag = B9600 | CS7 | CREAD | PARENB | CLOCAL;
- ttystru.c_oflag = OPOST | ONLCR | TAB3;
- ioctl(ttyfd,TCSETA,&ttystru);
- return;
- }
-
- main(argc,argv)
- int argc;
- char * argv[ ];
- {
- register int i,j,k;
-
- if( argc != 3 )
- {
- printf("incorrect number of arguments for run\n");
- exit(1);
- }
- for(k=0; k<31; k++)
- {
- line[k] = 'A' + k % 10;
- pbuffer[k] = 'K' + k % 10;
- }
- line[31] = '\n';
- pbuffer[31] = '0';
- if( (stream = fopen("config","r")) == NULL )
- {
- printf("unable to open file config\n");
- exit(1);
- }
- i = 1;
- while( i <=3 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",&nomp);
- break;
- case 2:
- sscanf(s,"%d",&noproc);
- break;
- case 3:
- sscanf(s,"%d",&novol);
- break;
- }
- i++;
- }
- for(i=0; i<novol; i++)
- {
- lab2:
- if( fgets(s,100,stream) == NULL)
- {
- printf("not enough disk volume names\n");
- exit(1);
- }
- if( s[0] == '#' ) goto lab2;
- sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
- }
- i = 1;
- while( i <=2 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",¬tyc);
- break;
- case 2:
- sscanf(s,"%d",¬tycl);
- break;
- }
- i++;
- }
- j = 0;
- while( fgets(s,100,stream) != NULL )
- {
- if( s[0] == '#' ) continue;
- if( ++j > MAXPROC )
- {
- printf("too many entries in config file\n");
- exit(1);
- }
- sscanf(s,"%s",&tty[j][0]);
- }
- fclose(stream);
- sscanf(argv[1],"%d",¬ty);
- sscanf(argv[2],"%d",&nodiskr);
- maxjobs = 200;
- ptime(1);
- count = 0;
- itotal = 0;
- for(i=1; i<=noproc; i++)
- {
- tablepid[i] = 0;
- }
- i = -1;
- start = ptime(1);
- while( 1 )
- {
- i++;
- tagid = getid( );
- if( ( pid = fork( ) ) == 0 )
- {
- if( notty )
- ttyopen( );
- for(i=1; i<=notty; i++)
- {
- if( write(ttyfd,line,sizeof line) != sizeof line)
- {
- printf(" can not write %s on tty write\n",&tty[tagid][0]);
- exit(1);
- }
- }
- if( notty )
- close(ttyfd);
- exit(0);
- }
- if( pid > 0 )
- {
- insert(pid);
- count++;
- }
- else
- {
- printf(" can not fork child process\n");
- exit(1);
- }
- if( count == noproc )
- {
- cid = wait(&status);
- count--;
- freeit(cid);
- if( ++itotal >= (maxjobs + 1 - noproc) )
- {
- while( count > 0 )
- {
- cid = wait(&status);
- count--;
- itotal++;
- freeit(cid);
- }
- goto ENDIT;
- }
- }
- }
- ENDIT:
- end = ptime(1);
- if( (stream = fopen("answers","a")) == NULL )
- {
- printf("unable to open file answers\n");
- exit(1);
- }
- ftime = end - start;
- timex = ( (double)ftime ) / 1000.0;
- jobs = ((double)maxjobs * 60.0) / timex;
- fprintf(stream,"%3d %3d %9.3f %9.3f\n",
- 2000,0,jobs,timex);
- fclose(stream);
- if( nodiskr )
- {
- if( (stream = fopen("subele","a")) == NULL )
- {
- printf("unable to open file subele\n");
- exit(1);
- }
- nochar = notty * 32;
- tnotty = maxjobs * notty;
- tnochar = maxjobs * nochar;
- fprintf(stream,"\n T T Y S U B S Y S T E M\n");
- fprintf(stream," Total Characters Written per Second %9.3f\n",
- (double)tnochar / timex);
- fprintf(stream," Characters Written per Second per Line %9.3f\n",
- (double)tnochar / ((double)noproc * timex ) );
- fprintf(stream," Total Characters Written %d request size %d \n",
- tnochar,32);
- fprintf(stream," Total Time To Write Characters %9.3f Seconds\n",timex);
- fprintf(stream," Number of TTY Controllers %d\n",nottyc);
- fprintf(stream," Number of TTY Lines per Controller %d\n",nottycl);
- fprintf(stream," Number of TTY Lines Used in Run %d\n",noproc);
- fprintf(stream," Jobs per Minute %9.3f\n",(double)(60 * maxjobs) / timex);
- fclose(stream);
- }
- exit(0);
- }
-
- long
- ptime(tflag)
- int tflag;
- {
- static long tm[4];
- static int first = 1;
- static long tstart = 0;
- static long xtime = 0;
- long times( );
- register int i;
-
- if( tflag && first )
- {
- tstart = times(tm);
- first = 0;
- return(0);
- }
- xtime = times(tm);
- if( tflag )
- {
- xtime = (1000 * (xtime - tstart)) / 60;
- }
- else
- {
- xtime = (1000 * tm[0] ) / 60;
- }
- return(xtime);
- }
-
- insert(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- tablepid[j] = pid;
- return(pid);
- }
- }
- printf("no free space on insert pid\N");
- return(0);
- }
-
- freeit(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == pid )
- {
- tablepid[j] = 0;
- return(j);
- }
- }
- printf("pid not found in table on free\n");
- return(0);
- }
-
- getid( )
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- return(j);
- }
- }
- printf("no free space on getpid\n");
- return(0);
- }
- SHAR_EOF
- fi
- if test -f 'xrun.c'
- then
- echo shar: "will not over-write existing file 'xrun.c'"
- else
- cat << \SHAR_EOF > 'xrun.c'
- /* Copyright 1985 NCR Corporation - Dayton, Ohio, USA */
-
- static char _Version[] = "%W% Compiled: %T% %H% Delta Date: %U% %G%";
- #include "sys/types.h"
- #include "sys/times.h"
- #include "stdio.h"
- #include "termio.h"
- #define MAXPROC 64
-
- #define NULL 0
-
-
- static int ttyfd,diskrfd,diskwfd,toggle;
- static double timex;
- static struct termio ttystru;
-
-
- static int noproc,maxjobs;
- static int nomp,nottyc,nottycl;
- static int count,itotal,status;
- static int pid,cid,tagid;
- static double stime;
- static char tty[MAXPROC][14],s[100];
- static int tablepid[MAXPROC];
- static int notty,nodiskw,nodiskr,nouser;
- static double jobs;
- static long start,end,ftime;
-
-
- FILE * stream;
- static char line[32],buffer[1024],pbuffer[32],bufin[1024];
- static char namev[8][80];
- static double pcnt[8],sum;
- static int novol,fsum,nfile[8],lng,len[8];
- static int total,ll[8],hl[8],cnt[8],vol,disk[200];
- static int dist,sdist[8],oldf[8];
- static int file1[200] =
- {
- 38,113,51,10,12,149,84,25,89,137,
- 166,95,167,31,82,124,194,52,154,161,
- 28,85,168,165,162,153,44,163,22,57,
- 79,151,70,48,29,6,138,14,116,181,
- 143,33,160,71,136,164,129,75,114,88,
- 2,34,182,186,106,53,73,193,148,120,
- 156,169,195,191,126,86,11,54,121,39,
- 185,125,15,176,144,19,123,65,173,13,
- 99,16,127,46,139,78,74,171,152,192,
- 122,128,170,41,175,172,145,115,61,45,
- 103,72,100,7,130,142,131,155,94,47,
- 80,146,92,90,32,132,17,49,189,196,
- 96,174,93,179,50,197,133,81,177,178,
- 62,134,55,108,83,101,18,135,30,105,
- 140,35,188,36,119,198,109,77,111,76,
- 150,190,157,87,37,147,43,199,180,117,
- 141,158,9,97,0,183,91,98,104,40,
- 20,159,63,184,187,102,1,3,64,4,
- 5,8,107,21,110,58,56,59,23,68,
- 24,60,26,112,27,66,42,118,67,69
- };
- static int file2[200] =
- {
- 158,115,27,19,86,167,60,143,183,166,
- 178,111,54,145,136,105,102,67,53,96,
- 188,144,6,3,34,120,4,118,127,146,
- 184,94,59,157,106,190,116,62,25,134,
- 22,137,179,1,61,5,44,93,139,121,
- 171,117,15,55,174,48,35,110,10,49,
- 162,197,112,199,107,182,0,165,180,7,
- 75,65,71,97,98,87,149,56,101,159,
- 68,198,113,168,189,26,187,17,191,83,
- 147,185,160,176,181,85,89,114,28,99,
- 70,129,100,8,57,74,23,24,16,76,
- 169,177,51,163,33,108,77,148,175,192,
- 135,40,36,92,193,69,194,103,186,80,
- 195,196,37,63,2,9,29,109,11,12,
- 78,13,42,14,142,18,119,82,20,72,
- 79,138,164,30,132,156,81,21,161,31,
- 32,38,39,41,64,84,104,43,122,45,
- 66,150,130,46,125,47,50,52,123,126,
- 88,58,170,73,90,91,131,95,124,128,
- 133,140,141,151,152,153,154,155,172,173
- };
- /* tty open */
-
- ttyopen( )
- {
-
- if( (ttyfd = open(&tty[tagid][0],1)) < 0 )
- {
- printf("can not open %s for tty write\n",&tty[tagid][0]);
- return;
- }
- ioctl(ttyfd,TCGETA,&ttystru);
- ttystru.c_cflag = B9600 | CS7 | CREAD | PARENB | CLOCAL;
- ttystru.c_oflag = OPOST | ONLCR | TAB3;
- ioctl(ttyfd,TCSETA,&ttystru);
- return;
- }
-
-
- /* disk open */
-
- dkopen(n)
- int n;
- {
- register int d,f1,f2,lng;
-
- d = disk[n];
- f1 = file1[n];
- f2 = file2[n];
- lng = len[d];
-
- sprintf(&namev[d][lng],"%03d",f1);
- if( (diskrfd = open(&namev[d][0],0)) < 0 )
- {
- printf("can not open %s for disk read\n",&namev[d][0]);
- return;
- }
- sprintf(&namev[d][lng],"%03d",f2);
- if( (diskwfd = open(&namev[d][0],1)) < 0 )
- {
- printf("can not open %$ for disk write\n",&namev[d][0]);
- return;
- }
- return;
- }
- main(argc,argv)
- int argc;
- char * argv[ ];
- {
- register int i,dc,tc;
- static int k,j,n,nx;
- static double ddcnt,ttcnt;
- static double dstep,ddelta,tstep,tdelta;
-
- if( argc != 3 )
- {
- printf("incorrect number of arguments for run\n");
- exit(1);
- }
- for(k=0; k<31; k++)
- {
- line[k] = 'A' + k % 10;
- pbuffer[k] = 'K' + k % 10;
- }
- line[31] = '\n';
- pbuffer[31] = '0';
- for(k=0; k<1024; k++)
- {
- buffer[k] = 'A';
- }
- if( (stream = fopen("config","r")) == NULL )
- {
- printf("unable to open file config\n");
- exit(1);
- }
- i = 1;
- while( i <=3 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",&nomp);
- break;
- case 2:
- sscanf(s,"%d",&noproc);
- break;
- case 3:
- sscanf(s,"%d",&novol);
- break;
- }
- i++;
- }
- sum = 0.0;
- for(i=0; i<novol; i++)
- {
- lab2:
- if( fgets(s,100,stream) == NULL)
- {
- printf("not enough disk volume names\n");
- exit(1);
- }
- if( s[0] == '#' ) goto lab2;
- sscanf(s,"%f %s",&pcnt[i],&namev[i][0]);
- sum += pcnt[i];
- }
- i = 1;
- while( i <=2 )
- {
- if( fgets(s,100,stream) == NULL )
- {
- printf("comfig file is empty\n");
- exit(1);
- }
- if( s[0] == '#' ) continue;
- switch(i)
- {
- case 1:
- sscanf(s,"%d",¬tyc);
- break;
- case 2:
- sscanf(s,"%d",¬tycl);
- break;
- }
- i++;
- }
- j = 0;
- while( fgets(s,100,stream) != NULL )
- {
- if( s[0] == '#' ) continue;
- if( ++j > MAXPROC )
- {
- printf("too many entries in config file\n");
- exit(1);
- }
- sscanf(s,"%s",&tty[j][0]);
- }
- fclose(stream);
- sscanf(argv[1],"%d",¬ty);
- sscanf(argv[2],"%d",&nodiskr);
- maxjobs = 200;
- fsum = 0;
- for(i=0; i<novol; i++)
- {
- nfile[i] = (int)( ( (pcnt[i] * 200.0) / sum ) );
- fsum += nfile[i];
- }
- for(i=0; i<novol; i++)
- {
- if( fsum < 200 )
- {
- nfile[i]++;
- fsum++;
- }
- else
- {
- break;
- }
- }
- for(i=0; i<novol; i++)
- {
- lng = strlen(&namev[i][0]);
- if( namev[i][lng-1] != '/')
- {
- namev[i][lng++] = '/';
- }
- namev[i][lng++] = 'd';
- namev[i][lng++] = 'k';
- len[i] = lng;
- namev[i][lng+3] = '\0';
- sprintf(&namev[i][len[i]],"%03d",i);
- }
- total = 0;
- for(i=0; i<novol; i++)
- {
- cnt[i] = 0;
- oldf[i] = 0;
- sdist[i] = 0;
- ll[i] = total;
- total += nfile[i];
- hl[i] = total - 1;
- }
- for(j=0; j<200; j++)
- {
- k = rand( ) % 200;
- for(i=0; i<novol; i++)
- {
- if( (k>=ll[i]) && (k<=hl[i]) )
- {
- vol = i;
- break;
- }
- }
- disk[j] = vol;
- }
- ptime(1);
- count = 0;
- itotal = 0;
- for(i=1; i<=noproc; i++)
- {
- tablepid[i] = 0;
- }
- if( (stream = fopen("loopcount","r")) == NULL )
- {
- printf("unable to open file loopcount\n");
- exit(0);
- }
- fscanf(stream,"%d",&nx);
- fclose(stream);
- nx--;
- dc = 1;
- tc = 1;
- dstep = 0.0;
- ddelta = (double)nodiskr / (double)nx;
- tstep = 0.0;
- tdelta = (double)notty / (double)nx;
- nx++;
- k = 1;
- i = -1;
- start = ptime(1);
- while( 1 )
- {
- i++;
- tagid = getid( );
- if( ( pid = fork( ) ) == 0 )
- {
- if( notty )
- ttyopen( );
- if( nodiskr )
- dkopen(i);
- toggle = 1;
- for(i=1; i<=nx; i++)
- {
- dstep += ddelta;
- ddcnt = (double)dc;
- if( dstep >= ddcnt )
- {
- dc++;
- if( toggle )
- {
- if( read(diskrfd,bufin,sizeof bufin)
- != sizeof bufin )
- {
- printf("can not read %s on disk read\n",&namev[disk[i]][0]);
- exit(1);
- }
- toggle = 0;
- }
- else
- {
- if( write(diskwfd,buffer,sizeof buffer)
- != sizeof buffer )
- {
- printf("can not write %s on on disk write\n",&namev[disk[i]][0]);
- exit(1);
- }
- toggle = 1;
- }
- }
- tstep += tdelta;
- ttcnt = (double)tc;
- if( tstep >= ttcnt )
- {
- tc++;
- if( write(ttyfd,line,sizeof line) != sizeof line)
- {
- printf(" can not write %s on tty write\n",&tty[tagid][0]);
- exit(1);
- }
- }
- }
- if( notty )
- close(ttyfd);
- if( nodiskr )
- {
- close(diskrfd);
- close(diskwfd);
- }
- exit(0);
- }
- if( pid > 0 )
- {
- insert(pid);
- count++;
- }
- else
- {
- printf(" can not fork child process\n");
- exit(1);
- }
- if( count == noproc )
- {
- cid = wait(&status);
- count--;
- freeit(cid);
- if( ++itotal >= (maxjobs + 1 - noproc) )
- {
- while( count > 0 )
- {
- cid = wait(&status);
- count--;
- itotal++;
- freeit(cid);
- }
- goto ENDIT;
- }
- }
- }
- ENDIT:
- end = ptime(1);
- if( (stream = fopen("answers","a")) == NULL )
- {
- printf("unable to open file answers\n");
- exit(1);
- }
- ftime = end - start;
- timex = ( (double)ftime ) / 1000.0;
- jobs = ((double)maxjobs * 60.0) / timex;
- fprintf(stream,"%3d %3d %9.3f %9.3f\n",
- notty,nodiskr,jobs,timex);
- fclose(stream);
- exit(0);
- }
-
- long
- ptime(tflag)
- int tflag;
- {
- static long tm[4];
- static int first = 1;
- static long tstart = 0;
- static long xtime = 0;
- long times( );
- register int i;
-
- if( tflag && first )
- {
- tstart = times(tm);
- first = 0;
- return(0);
- }
- xtime = times(tm);
- if( tflag )
- {
- xtime = (1000 * (xtime - tstart)) / 60;
- }
- else
- {
- xtime = (1000 * tm[0] ) / 60;
- }
- return(xtime);
- }
-
- insert(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- tablepid[j] = pid;
- return(pid);
- }
- }
- printf("no free space on insert pid\N");
- return(0);
- }
-
- freeit(pid)
- int pid;
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == pid )
- {
- tablepid[j] = 0;
- return(j);
- }
- }
- printf("pid not found in table on free\n");
- return(0);
- }
-
- getid( )
- {
- register int j;
-
- for(j=1; j<=noproc; j++)
- {
- if( tablepid[j] == 0 )
- {
- return(j);
- }
- }
- printf("no free space on getpid\n");
- return(0);
- }
- SHAR_EOF
- fi
- exit 0
- # End of shell archive
-
-
- -=-
- Rich Kaul | "Every man is given the key to the door
- kaul@icarus.eng.ohio-state.edu | of heaven; unfortunately, the same key
- or ...!osu-cis!kaul | opens the door to hell."
-