Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: Threading and SharedMem (Re: [Caml-list] Re: Is OCaml fast?)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-11-30 (08:10)
From: Stephan Houben <stephanh@p...>
Subject: Re: Threading and SharedMem (Re: [Caml-list] Re: Is OCaml fast?)
On 11/29/2010 04:33 PM, Oliver Bandel wrote:
> Zitat von "Gerd Stolpmann" <>:
>> Am Montag, den 29.11.2010, 17:12 +0100 schrieb Oliver Bandel:
>>> Zitat von "Gerd Stolpmann" <>:

>>> You use shared mem(?), but you link only to *.ml files,
>>> and I see no *.c there.

>>> How can this be done?
>>> At least not via the libs that are shipped with OCaml?!

Actually it can be done using the libs that ship with OCaml
(Unix and Bigarray), although it is not 100% POSIX :

let create_shared_genarray kind layout dims =
   let fd = Unix.openfile "/dev/zero" [Unix.O_RDWR] 0
   in let ar = Bigarray.Genarray.map_file fd kind layout true dims
   in Unix.close fd; ar

The resulting bigarray object is shared among subsequent forks.
This relies on the fact that mmap-ing /dev/zero is equivalent
to an anonymous mmap.

Well, at least it works on Linux.