[Haskell-cafe]
Re: Memory-mapped arrays? (IArray interfaces, slices, and so on)
Aaron Denney
wnoise at ofb.net
Thu Nov 8 17:42:31 EST 2007
On 2007-11-08, David Roundy <droundy at darcs.net> wrote:
> On Wed, Nov 07, 2007 at 10:10:16PM +0000, Jules Bean wrote:
>> Joel Reymont wrote:
>> >Is there such a thing as memory-mapped arrays in GHC?
>>
>> In principle, there could be an IArray instance to memory-mapped files.
>>
>> (There could also be a mutable version, but just the IArray version
>> would be useful).
>
> The IArray instance would be unsafe, however, because the contents of the
> file could change after you opened it, breaking referential transparency.
Or even crashing, if the size becomes smaller than the mapped area.
> I don't know what all is possible with file open modes, but I don't think
> you can guarantee that once you've opened a file it won't change (unless
> you unlink it, and know that noone else has an opened file handle to it).
File open modes won't do it, and I don't think any thing else will do
it using just POSIX behavior, either. Linux's mmap() used to support a
DENY_WRITE flag, but it enabled DoS attacks, so it's gone.
> It may be that by opening it in write mode you could ensure that noone else
> modifies it (although I don't think this would work e.g. on nfs),
It doesn't even work locally.
--
Aaron Denney
-><-
More information about the Haskell-Cafe
mailing list