[Haskell-cafe] Re: Hugs vs GHC
(again)was: Re: Somerandomnewbiequestions
John Meacham
john at repetae.net
Fri Jan 14 22:54:08 EST 2005
On Wed, Jan 12, 2005 at 12:21:25AM +0000, Aaron Denney wrote:
> On 2005-01-11, Simon Marlow <simonmar at microsoft.com> wrote:
> > On 11 January 2005 14:15, Gracjan Polak wrote:
> >
> >> Simon Marlow wrote:
> >> > There's a big lock on File. If you want to do truly concurrent
> >> reading, > you can make multiple FileInputStreams, each of which has
> >> its own file > descriptor (the Unix implementation uses dup(2)).
> >> >
> >>
> >> Original and descriptor returned by dup or dup2 share file pointer.
> >
> > *blink*
> >
> > You're right! Serves me right for assuming that POSIX would have
> > sensible semantics. Perhaps this API isn't implementable, in its
> > current state.
>
> Others have pointed out pread() and pwrite(); Perhaps we can stick
> this function in an extension package. (Though it is required for
> Unix 98 conformance, so anything reasonable will have it. Hmm.
> Does open("/dev/fd/n") or ("/proc/self/fd/n") act as dup() or a fresh
> open() to underlying file?)
Actually, If I were writing new haskell libraries, I would use mmap
whenever I could for accessing files. not only does it make the file
pointer problem go away, but it can be drastically more efficient.
of course, this can only be done on a limited type of file on some
architectures, so it should be an optimization under the hood rather
than an exposed interface.
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-Cafe
mailing list