From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA00538; Wed, 12 May 2004 14:53:46 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA32673 for ; Wed, 12 May 2004 14:53:44 +0200 (MET DST) Received: from mail.npc.de (fw.npc.de [62.225.140.214]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4CCrhEV019385 for ; Wed, 12 May 2004 14:53:43 +0200 Received: from styx.ffm.npc.de (lion.npc.de [192.168.129.1]) by mail.npc.de (Postfix) with ESMTP id 900BE181A; Wed, 12 May 2004 14:53:42 +0200 (CEST) Received: from hera.ffm.npc.de (hera.ffm.npc.de [192.168.130.8]) by styx.ffm.npc.de (Postfix STYX NPC GmbH) with ESMTP id AB9A1C437; Wed, 12 May 2004 14:53:41 +0200 (CEST) Received: from ares.ffm.npc.de (ares.ffm.npc.de [192.168.130.32]) by hera.ffm.npc.de (Postfix HERA NPC GmbH) with ESMTP id 56746159C9; Wed, 12 May 2004 14:53:41 +0200 (CEST) Received: from ares.ffm.npc.de (ares.ffm.npc.de [192.168.130.32]) by ares.ffm.npc.de (Postfix ARES NPC GmbH) with ESMTP id 255B11855; Wed, 12 May 2004 14:53:41 +0200 (CEST) Subject: Re: [Caml-list] Best way to synchronize OS processes? From: Gerd Stolpmann To: Alex Baretta Cc: Shawn Wagner , caml-list@inria.fr, ranjan.bagchi@frotz.com In-Reply-To: <40A20A0F.2070809@baretta.com> References: <40A115E3.1060400@frotz.com> <20040511180933.GB595@speakeasy.org> <40A20A0F.2070809@baretta.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 May 2004 14:53:40 +0200 Message-Id: <1084366421.20597.12.camel@ares> Mime-Version: 1.0 X-Miltered: at nez-perce with ID 40A21E57.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 gerd:01 stolpmann:01 2004:99 baretta:01 2004:99 serialize:01 lockf:01 lockf:01 implemented:01 posix:01 mutexes:01 gerd:01 stolpmann:01 viktoriastr:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Am Mit, 2004-05-12 um 13.27 schrieb Alex Baretta: > Shawn Wagner wrote: > > On Tue, May 11, 2004 at 11:05:23AM -0700, Ranjan Bagchi wrote: > > > >>Hi -- > >> > >>I'm writing some code which will end up executing concurrently on > >>several OS processes. I'd like to serialize access to some specific OS > >>resources (for instance, writing to a single file). The Unix module > >>doesn't appear to offer anything like a critical section or an OS > >>mutex. Is there a preferred way to do this? > > > > > > File locking with Unix.lockf? > > I disagree. I faced the same problem and found that it cannot be easily > solved with lockf. Unix.lockf locks specific regions in a file, whereas > Ranjan seems to need the equivalent of a mutex, which should be > implemented as a lock over the entire file. This is done by the flock > primitive in Posix systems. Unluckily, flock has not been included in > the Unix module. And this is good. flock is not as portable as lockf. flock usually does not work over NFS, whereas lockf works. Normally, you need flock only to synchronize with third-party BSD programs such as sendmail. lockf does not lock regions of a file. It just locks abstract byteranges, whether you interpret them as file regions is up to you. That means, you can lock byteranges that do not exist in the file. If you like, you can view an empty lockf-locked file as 2^32 potential mutexes (or whatever the maximum file size is). Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners