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 NAA24272; Wed, 12 May 2004 13:26:41 +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 NAA25989 for ; Wed, 12 May 2004 13:26:40 +0200 (MET DST) Received: from alex.baretta.com ([213.255.109.130]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4CBQdSH015989 for ; Wed, 12 May 2004 13:26:39 +0200 Received: from baretta.com (localhost.localdomain [127.0.0.1]) by alex.baretta.com (8.12.8/8.12.8) with ESMTP id i4CBRBZd003083; Wed, 12 May 2004 13:27:12 +0200 Message-ID: <40A20A0F.2070809@baretta.com> Date: Wed, 12 May 2004 13:27:11 +0200 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Shawn Wagner CC: caml-list@inria.fr, ranjan.bagchi@frotz.com Subject: Re: [Caml-list] Best way to synchronize OS processes? References: <40A115E3.1060400@frotz.com> <20040511180933.GB595@speakeasy.org> In-Reply-To: <20040511180933.GB595@speakeasy.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40A209EF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; baretta:01 baretta:01 caml-list:01 2004:99 serialize:01 lockf:01 lockf:01 implemented:01 posix:01 pervasive:01 caml:01 0700,:01 alex:01 alex:01 descriptors:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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. I have written my own Flock module, which might be useful to Rajan. It supports locking Pervasive channels as well as locking the underlying file descriptors. I have sent it to Caml team as a contribution to the Unix module, but apparently it was not accepted. I'm willing to send it to anyone requesting it. Note that it is released under the GPL--not the LGPL--so licensing issues might arise. Alex ------------------- 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