From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id D6C98BC57 for ; Tue, 30 Nov 2010 09:10:37 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmUBAMA/9EzVSycHkWdsb2JhbACDUJEwjgsVAQEBAQkLCgcRAx+wLZEegSGDM3MEimGDDwY X-IronPort-AV: E=Sophos;i="4.59,279,1288566000"; d="scan'208";a="80950849" Received: from cpsmtpb-ews04.kpnxchange.com ([213.75.39.7]) by mail4-smtp-sop.national.inria.fr with ESMTP; 30 Nov 2010 09:10:37 +0100 Received: from cpbrm-ews34.kpnxchange.com ([10.94.84.165]) by cpsmtpb-ews04.kpnxchange.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 30 Nov 2010 09:10:36 +0100 Received: from CPSMTPM-EML107.kpnxchange.com ([195.121.3.11]) by cpbrm-ews34.kpnxchange.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 30 Nov 2010 09:10:36 +0100 Received: from [192.168.2.4] ([84.80.25.83]) by CPSMTPM-EML107.kpnxchange.com with Microsoft SMTPSVC(7.0.6002.18222); Tue, 30 Nov 2010 09:10:36 +0100 Message-ID: <4CF4B17C.7000703@planet.nl> Date: Tue, 30 Nov 2010 09:10:36 +0100 From: Stephan Houben User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 Newsgroups: fa.caml To: caml-list@yquem.inria.fr Subject: Re: Threading and SharedMem (Re: [Caml-list] Re: Is OCaml fast?) References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Nov 2010 08:10:36.0240 (UTC) FILETIME=[115A8500:01CB9066] X-RcptDomain: yquem.inria.fr X-Spam: no; 0.00; threading:01 ocaml:01 bandel:01 gerd:01 stolpmann:01 bandel:01 gerd:01 stolpmann:01 libs:01 ocaml:01 libs:01 bigarray:01 genarray:01 dims:01 rdwr:01 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. http://en.wikipedia.org/wiki//dev/zero Well, at least it works on Linux. Stephan