From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2532EBB81 for ; Wed, 8 Dec 2004 21:24:30 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iB8KOTOi028005 for ; Wed, 8 Dec 2004 21:24:29 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA23734 for ; Wed, 8 Dec 2004 21:24:29 +0100 (MET) Received: from kraid.nerim.net (smtp-103-wednesday.nerim.net [62.4.16.103]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iB8KOTPJ002923 for ; Wed, 8 Dec 2004 21:24:29 +0100 Received: from hector.lesours (ours.starynkevitch.net [62.212.121.80]) by kraid.nerim.net (Postfix) with ESMTP id 8C80941C89; Wed, 8 Dec 2004 21:24:27 +0100 (CET) Received: from basile by hector.lesours with local (Exim 4.34) id 1Cc8MO-0002aY-Ei; Wed, 08 Dec 2004 21:24:28 +0100 Date: Wed, 8 Dec 2004 21:24:28 +0100 To: Julien Cristau Cc: caml-list@inria.fr Subject: Re: [Caml-list] mmap() and strings Message-ID: <20041208202428.GA9878@ours.starynkevitch.net> References: <20041208200458.GC1840@ens-lyon.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20041208200458.GC1840@ens-lyon.fr> User-Agent: Mutt/1.5.6+20040907i From: Basile STARYNKEVITCH X-Miltered: at nez-perce with ID 41B762FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41B762FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 ecrivait:01 wrote:01 manipulates:01 buffer:01 buffer:01 iteration:01 ocaml:01 ocaml:01 jocaml:01 nerim:01 faiencerie:01 92340:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: Le Wed, Dec 08, 2004 at 09:04:59PM +0100, Julien Cristau écrivait/wrote: > Hello list, > > I'm wondering if somebody has an idea for the following problem: > > I'm working on a program which manipulates a buffer. A writer process > regularly changes this buffer, and reader processes have to work on it > after each change. Currently, the buffer is a string and is passed to > the readers trough pipes. However, this is costly because the buffer is > copied many times at each iteration. Actually, pipes perform quite well on Linux.... > We thought we could use mmap(2), > but there seems to be no easy solution > to mmap() a memory region and treat it as a string in ocaml. Use Bigarray-s for that. They can mmap files (on Unix & Linux) and are already in Ocaml 3.08 You might also use IPC shared memory segments, but there is no support in Ocaml for these (shmget & related system calls), so you'll probably need to code the C stub (for the Ocaml binding) yourself. Maybe you'll need JoCaml... (but I don't know if it is dead or not - it was designed for coding cooperative programs communicating thru channels). -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet aliases: basiletunesorg = bstarynknerimnet 8, rue de la Faïencerie, 92340 Bourg La Reine, France