[Haskell-cafe] Re: I/O interface

Keean Schupke k.schupke at imperial.ac.uk
Thu Jan 13 04:31:13 EST 2005


Marcin 'Qrczak' Kowalczyk wrote:

>Ben Rudiak-Gould <Benjamin.Rudiak-Gould at cl.cam.ac.uk> writes:
>
>  
>
>>is there *any* way to get, without an exploitable race condition,
>>two filehandles to the same file which don't share a file pointer?
>>    
>>
In unix the traditional way to do this is to use a directory. Each 
process/thread
opens its own file... and you have some kind of master index/ordering 
file to
keep track of which file is doing what (for example Highly parallel mail 
software).

At the end of the day IO is serial by nature (to one device anyway), so 
the way to
do this into one file is to have one thread that reads and writes, and 
to 'send'
read and write requests over channels from the threads that need the work
done... Effectively the channels serialise the requests. This has the added
advantage that is guarantees the transactional itegrity of the IO (for 
example
database software)

    Keean.


More information about the Haskell-Cafe mailing list