From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 54E1C7ED25 for ; Wed, 17 Jul 2013 19:33:47 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of Xavier.Leroy@inria.fr) identity=pra; client-ip=212.27.42.2; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="Xavier.Leroy@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of Xavier.Leroy@inria.fr) identity=mailfrom; client-ip=212.27.42.2; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="Xavier.Leroy@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp2-g21.free.fr) identity=helo; client-ip=212.27.42.2; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="Xavier.Leroy@inria.fr"; x-sender="postmaster@smtp2-g21.free.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigBAIPU5lHUGyoClGdsb2JhbABagzrDJYEQFg4BAQEBBw0JCRQDJYIjAQEEAVMlAQULCyEWDwkDAgECAUUGDQEHAQGIBgoItWOOMoFIB4N7A5dcgSmEeo4+cAE X-IPAS-Result: AigBAIPU5lHUGyoClGdsb2JhbABagzrDJYEQFg4BAQEBBw0JCRQDJYIjAQEEAVMlAQULCyEWDwkDAgECAUUGDQEHAQGIBgoItWOOMoFIB4N7A5dcgSmEeo4+cAE X-IronPort-AV: E=Sophos;i="4.89,686,1367964000"; d="scan'208";a="21492245" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail3-smtp-sop.national.inria.fr with ESMTP; 17 Jul 2013 19:33:46 +0200 Received: from [192.168.1.2] (unknown [82.237.71.191]) by smtp2-g21.free.fr (Postfix) with ESMTP id 47A854B001B; Wed, 17 Jul 2013 19:33:42 +0200 (CEST) Message-ID: <51E6D575.9010406@inria.fr> Date: Wed, 17 Jul 2013 19:33:41 +0200 From: Xavier Leroy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Chet Murthy CC: caml-list@inria.fr References: <5000924.vCd1HWCNpc@groupon> In-Reply-To: <5000924.vCd1HWCNpc@groupon> X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] recursive mutexes in ocaml Hi Chet, > I figured I'd ask -why- ocaml's mutexes aren't recursive. Or at > least, why there isn't an option for recursive mutexes? Dave Butenhof, one of the main authors of POSIX threads, makes rather strong points against recursive mutexes: http://tinyurl.com/butenhof-recursive-mutexes The killer issue in my opinion is how to make recursive mutexes play well with pthread_cond_wait() / Condition.wait: POSIX's pthread_cond_wait() only releases the mutex once, which leads to all sorts of deadlock if it's been acquired N>1 times. I believe Java has a more useful behavior, whereas the mutex is released N times, then reacquired N times. But this cannot be implemented easily on top of POSIX threads. And don't get me started on Win32 threads... It might make sense to have recursive mutexes as a separate type, different from ordinary mutexes, so that it's not usable in conjunction with Condition.wait. Apparently, Batteries has/had that. - Xavier Leroy