[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pipes & ptys



Fselect() provides a way to sleep for less than 1 second (to sleep for n
milliseconds, do Fselect(n, 0L, 0L, 0L)).

The other thing you can do to speed up pipe I/O is to always try to
Fread() and process more than 1 byte at a time. Usually there will be more
than 1 byte written into the pipe at once (e.g. in a window system the
caller will write a window command and some arguments all in one block).
If you have the flags set appropriately,
   r = Fread(pipefd, bufsiz, buffer);
will read either "bufsiz" bytes, or as many as are available, whichever
is smaller. This can be a very big win. If you're only reading 1 byte
at a time, then effectively the entire system gets slowed down to 1 character
at a time I/O (since even if a program tries to write 4K bytes at once, only
1 character will typically manage to get into the pipe buffer at a time).

Regards,
Eric