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 PAA02373; Wed, 12 May 2004 15:16:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 PAA02178 for ; Wed, 12 May 2004 15:16:39 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4CDGZSH030975 for ; Wed, 12 May 2004 15:16:35 +0200 Received: from localhost (akasha.ijm.jussieu.fr [134.157.173.57]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id i4CDGJMa089700 ; Wed, 12 May 2004 15:16:19 +0200 (CEST) X-Ids: 166 Date: Wed, 12 May 2004 15:16:08 +0200 (CEST) Message-Id: <20040512.151608.113530062.andrieu@ijm.jussieu.fr> To: caml-list@inria.fr Cc: will@exomi.com, alex@baretta.com, shawnw@speakeasy.org, ranjan.bagchi@frotz.com Subject: Re: [Caml-list] Best way to synchronize OS processes? From: Olivier Andrieu In-Reply-To: References: <20040511180933.GB595@speakeasy.org> <40A20A0F.2070809@baretta.com> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40A223B3.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 40A223A3.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 andrieu:01 andrieu:01 2004:99 baretta:01 lockf:01 lockf:01 implemented:01 posix:01 filesystems:01 api:01 lseek:01 pervasives:01 buffering:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ville-Pertti Keinonen [Wed, 12 May 2004]: > > On May 12, 2004, at 2:27 PM, Alex Baretta wrote: > > > 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. > > Actually flock is non-POSIX (it's BSD) and is missing from some > reasonably modern systems. > > It's entirely possible to lock the entire file using the fcntl used by > Unix.lockf, making it equivalent to flock. They are not *exactly* equivalent: flock does not work on NFS filesystems whereas fnctl does, and they have different behaviour with exec or dup I believe. > The problem is that the OCaml Unix module doesn't allow the > l_whence parameter to be set, which is a serious omission. Well, it follows the lockf API, which starts the lock at the current file position. You could use lseek to reposition it but this may confuse a Pervasives channel buffering this file. By the way, lockf can block, waiting for a lock. Shouldn't there be some enter_blocking_section()/leave_blocking_section() somewhere ? -- Olivier ------------------- 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