Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Aug 2005 05:04:32 +1000
From:      Peter Jeremy <PeterJeremy@optushome.com.au>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        Dan Nelson <dnelson@allantgroup.com>, Maxim.Sobolev@portaone.com, "current@freebsd.org" <current@freebsd.org>
Subject:   Re: Sub-optimal libc's read-ahead buffering behaviour
Message-ID:  <20050804190432.GA2104@cirb503493.alcatel.com.au>
In-Reply-To: <20050804092637.GA12561@walton.maths.tcd.ie>
References:  <42F0CCD5.9090200@portaone.com> <20050803150117.GD93405@dan.emsphone.com> <42F0E9B2.9080208@portaone.com> <20050804060251.GA21228@nagual.pp.ru> <20050804063908.GA21871@nagual.pp.ru> <20050804075711.GB271@cirb503493.alcatel.com.au> <20050804092637.GA12561@walton.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050804190432.GA2104>