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 JAA17184; Wed, 12 May 2004 09:11:36 +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 JAA17317 for ; Wed, 12 May 2004 09:11:35 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4C7BYEV011107 for ; Wed, 12 May 2004 09:11:34 +0200 Received: from pc8-123 (pc8-123 [129.175.8.123]) by lri.lri.fr (8.12.10/jtpda-5.4) with ESMTP id i4C71oCr029488 ; Wed, 12 May 2004 09:01:54 +0200 (MEST) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 1BNnkU-0006cd-00; Wed, 12 May 2004 09:01:50 +0200 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <16545.52190.503968.109730@gargle.gargle.HOWL> Date: Wed, 12 May 2004 09:01:50 +0200 To: Ranjan Bagchi Cc: Shawn Wagner , caml-list@inria.fr Subject: Re: [Caml-list] Best way to synchronize OS processes? In-Reply-To: <40A11A46.5020704@frotz.com> References: <40A115E3.1060400@frotz.com> <20040511180933.GB595@speakeasy.org> <40A11A46.5020704@frotz.com> X-Mailer: VM 7.03 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-MailScanner: Found to be clean X-Miltered: at nez-perce with ID 40A1CE26.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 caml-list:01 openfile:01 wronly:01 creat:01 lockf:01 printf:01 printexc:01 lockf:01 lri:01 filliatr:01 synchronize:01 writes:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ranjan Bagchi writes: > Cool - I was playing with that call today, although I'm getting > occasional EDEADLK exceptions thrown though. Is there an example of > correct use? I use it like this (bd_lock is the lock file) : ====================================================================== ... (* START OF CRITICAL SECTION *) let fd_lock = try let fd = openfile bd_lock [O_WRONLY; O_CREAT] 0o666 in lockf fd F_LOCK 0; fd with e -> printf "%s" (Printexc.to_string e); exit 0 ...CRITICAL SECTION GOES HERE... let _ = lockf fd_lock F_ULOCK 0; close fd_lock (* END OF CRITICAL SECTION *) ... ====================================================================== Hope this helps, -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr) ------------------- 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