From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 1C3B5BCA7 for ; Wed, 16 Feb 2005 19:49:17 +0100 (CET) Received: from mail.hybrid.fi ([195.170.158.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1GInGEs012071 for ; Wed, 16 Feb 2005 19:49:16 +0100 Received: from charon ([195.170.158.21]:55355 "EHLO imap.hybrid.fi") by hybrid.fi with ESMTP id ; Wed, 16 Feb 2005 20:49:09 +0200 Received: from [127.0.0.1] ([195.170.158.34]) (authenticated user janne@hybrid.fi) by imap.hybrid.fi (Kerio MailServer 6.0.2) for caml-list@yquem.inria.fr; Wed, 16 Feb 2005 20:49:08 +0200 Message-ID: <421395A4.3030909@hybrid.fi> Date: Wed, 16 Feb 2005 20:49:08 +0200 From: Janne Hellsten User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: interprocess mutex Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 421395AC.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; interprocess:01 ocaml's:01 interprocess:01 ocaml:01 doable:01 invocations:01 unix:01 module:03 mutex:03 mutex:03 library:03 library:03 dbm:04 dbm:04 blocking:04 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Hello, I need to sequentialize two processes accessing the same GDBM database (OCaml's dbm library). Since GDBM allows for only one writer at a time, I need a way to block until the previous writer has finished. I think there is a way to do this with the original GDBM library since it claims to handle the file lockings properly -- I could block based on the returned error codes. However, this functionality does not appear to be exposed through the Dbm module. Of course I can implement this blocking myself with an interprocess mutex. But how can I implement such a mutex in OCaml? I couldn't find anything from the standard library that would resemble my problem. Is it easily doable or do I need to go and start hacking C code? I've never done it on Unix but I know it's easily done on Windows. Thanks in advance, Janne P.S. I'm using GDBM merely as a cache between process invocations, so using a more heavyweight DB is out of the question.