nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) (03/10/90)
Assumptions: The following is running on LAN Manager 1.1. I am to build a graphic image (in Laserjet PCL) and then send it to the printer as fast as the printer can accept it. Using the code sample below the throughput was measured to be 25 seconds per page. However, if I was to build the buffer into files and then replace "PART 1 code" with "PART 1 alternate" below, such that I have two .exe's running concurently. One exe to build buffers and queue them in files and another that reads the files and writes to the device. The throughput is measured to be 20 seconds per page. Why this 5 seconds improvement? I am not able to understand this, does it have to do with how OS/2 assigns time-slices to processes? Note: letting LM spooler do the printing instead of my second exe lead also to 20 seconds. Previous inline timing statements in ComputeAndBuildBuffer() showed that it takes approx. 5 seconds to compute and build a buffer for the WHOLE image. My question is how can I delay buidling the buffer until just before printing (to avoid cluttering disk-space) and still achieve a throughput of 20 seconds per page all in one *single* exe? A friend tried to use DosWriteAsync() using two buffers instead of the DosWrite() in the "Part 2" however without much improvements.?? Computing and printing small buffer (say 512 bytes) instead of the whole buffer seems to lead some tiny improvements. How, can I make use of OS/2 multitasking features (threads, etc...) to simulate parallel computing and printing, so that 5 second computation is almost transparent? Should ComputeAndBuildBuffer be a separate thread? Thanks for any info. for (;;) { usErrStat = PRJOB_ERROR | PRJOB_NOTIFY; // PART 1 usBytesBuild = ComputeAndBuildBuffer( buf, NBUFSIZE ) ; /* Done? */ if (usBytesBuild == 0) break; // PART 2 /* Write a block*/ while( DosWrite( hfDestination, buf, usBytesRead, & usTemp) ) { DosSemSet( & SEMpause ) ; usResult = DosPrintDestStatus( pDevname, vJob_id, usErrStat, "write error" ) ; DosSemRequest( & SEMpause, 7000L ) ; usErrStat &= ~ PRJOB_NOTIFY; /* clear bit */ } } // PART 1 Alternate to substitute for PART 1 above // hfJobDate is a handle to file contained the read to send buffer /* Read a block */ for (; ;) { usRC = DosRead( hfJobData, buf, NBUFSIZE, & usBytesRead ); if (!usRC) break; DosSemSet( & SEMpause ) ; usResult = DosPrintDestStatus( pDevname, vJob_id, usErrStat | PRJOB_DESTPAUSED, "Read error" ) ; DosSemRequest( & SEMpause, 7000L ) ; } /* Eof? */ if (usBytesRead == 0) break; Thank you. --Abdenacer (nacer@hpmcaa.mcm.hp.COM)