CompuServe Messages

Reading a file

    04-Oct-89 11:42:01
Sb: #68222-Reading a file
Fm: M2S/Phil Camp 76004,2054
To: Khalid Aldoseri 75166,2531
A I've mentioned this before elsewhere, but the true fastest method for reading single characters from a file is the one used by the SingleCharDOS module supplied with M2Sprint. The module uses double-buffered asynchronous IO to achieve truely remarkable performance. Basically, there are two input buffers of equal size. When the file is first opened, a packet is sent to the file system requesting some data to fill up buffer #1. When the first call to read a character is made, this char is taken from the first buffer. At that time, a background request is sent to DOS to have it read some chars in the second buffer. While the program is busy processing the cvhars in the first buffer, the second buffer is being filled by background disk DMA. When all characters from the first buffer have been read, you then start reading fom the second buffer and send a request to DOS to start filling the first buffer again. This approach is tricky to implement, but it gives amazing results.