Re: Sub-optimal libc's read-ahead buffering behaviour

From: Peter Jeremy <PeterJeremy_at_optushome.com.au>
Date: Fri, 5 Aug 2005 05:04:32 +1000
On Thu, 2005-Aug-04 10:26:37 +0100, David Malone wrote:
>On Thu, Aug 04, 2005 at 05:57:11PM +1000, Peter Jeremy wrote:
>> That said, I've seen similar behaviour on other systems so it could be
>> a subtle side-effect of POSIX.
>
>There are some magic things about fseek in the C standard - I wonder
>if this could be related to them. For example (from C99) in the
>commentry on fopen:
[read/write switching]

I don't see anything there that mandates the existing behaviour.  The
existing behaviour may be a simple way to implement the requirements
but a more efficient way would seem to be to use flags to allow
read/write switching and only reload the buffer if the next I/O
operation specifies a different direction to the previous one.

>Could what stdio is doing be related to flushing ungetc?

The ungetc buffer is separate to the normal I/O buffer.  Flushing it
shouldn't require the normal I/O buffer to be re-read.

-- 
Peter Jeremy
Received on Thu Aug 04 2005 - 17:04:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:40 UTC