[Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

Keean Schupke k.schupke at imperial.ac.uk
Fri Jan 21 07:42:56 EST 2005


Ben Rudiak-Gould wrote:

>
> If you're reading from a random-access file, there's no way it can 
> tell you when the file data is buffered, because it doesn't know which 
> part of the file you plan to read. The OS may try to guess for 
> readahead purposes, but select()'s behavior can't depend on that guess.
>
But surely it does! read only reads the next block... to skip randomly 
you must seek... therefore
the following sequence does this:

       seek
       select
       read

The select should block until one disk block from the file is in memory, 
read is defined
such that it will return if some data is ready even if it is not as much 
as you requested.
So in this case if you ask for a complete file, you may just get one 
block... or more.

In other words the API restricts reads to the 'next' block - so seek 
knows which block
needs to be read into memory...

I can see no reason why is couldn't work like this even if some unixes 
might not.

    Keean.


More information about the Haskell-Cafe mailing list