From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 7A3377ED25 for ; Wed, 17 Jul 2013 12:54:09 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.126.187 as permitted sender) identity=helo; client-ip=212.227.126.187; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgYBAAh25lHU4367k2dsb2JhbABSCIM6g1W/RYEPFg4BAQEBBwsLCRQDJYIjAQEEASNWDgILGgImAgIbPAYTiAoKpBORQgSBIogihGQMgTYHglmBIQOOZI8bjj6Bbw X-IPAS-Result: AgYBAAh25lHU4367k2dsb2JhbABSCIM6g1W/RYEPFg4BAQEBBwsLCRQDJYIjAQEEASNWDgILGgImAgIbPAYTiAoKpBORQgSBIogihGQMgTYHglmBIQOOZI8bjj6Bbw X-IronPort-AV: E=Sophos;i="4.89,683,1367964000"; d="scan'208";a="26323609" Received: from moutng.kundenserver.de ([212.227.126.187]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Jul 2013 12:54:09 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-208-100.pools.arcor-ip.net [94.219.208.100]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0LwBkQ-1U4mS61oDO-0185df; Wed, 17 Jul 2013 12:54:08 +0200 Received: from [192.168.0.110] (ip-109-90-191-98.unitymediagroup.de [109.90.191.98]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 13536C00CF; Wed, 17 Jul 2013 12:54:08 +0200 (CEST) Message-ID: <1374058447.21437.37.camel@zotac> From: Gerd Stolpmann To: Chet Murthy Cc: caml-list@inria.fr Date: Wed, 17 Jul 2013 12:54:07 +0200 In-Reply-To: <5000924.vCd1HWCNpc@groupon> References: <5000924.vCd1HWCNpc@groupon> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Provags-ID: V02:K0:HJCHMPdBav0xahIeV7bKglM/nPgFJm/Z60kKwu/aFTt koiVSlZgumxYLsceyJ4Daq0d/32zABgKz5k0P6edx5atRMZtRb pmNwLlE72pNVKdUQWgh8a4km7NWxRJGecBlC9h7gpkWUm1/akg 5ZkW41r5yNQrryWWtMSqdCwFavghpf0bZSudiQ1bsrmCiW7ray RLIvgjXfeoNLpNi07/zDgFvwpSID5bPHkawyFT66d+M8LtxDsw 4vL5LfgBvzHkLPhxOkrAYfFtWk6wwdFnOKj4eIh1mshxbHG5nV PRShWgrBAmNGU/uOlY6XUhyEhs2/u508uKG3ogBAtV1l72tiVN G4BD3YV0tXCzas6DHnE7GkAuJWFN9OcVP8lNcmIW8 Subject: Re: [Caml-list] recursive mutexes in ocaml Am Mittwoch, den 17.07.2013, 00:28 -0700 schrieb Chet Murthy: > Recently I'm writing some multi-threaded code, and ended up wishing I > had recursive mutexes. Now .... I realize that this is a simple thing > to "get" -- just hack the code, maaaan. But before (or, erm > .... whilst) I do that, I figured I'd ask -why- ocaml's mutexes aren't > recursive. Or at least, why there isn't an option for recursive > mutexes? > > I realize that at some level, you can -always- eschew recursive > mutexes by passing along extra parameters so that code can know > whether it's locked a particular mutex. That said, it's (more than) a > bit of a pain, and surely complicates code .... > > Is there some other -reason- that recursive mutexes aren't > implemented? Or is it just a matter of taste? The multi-threading feature in ocaml is quite old. I guess there was some motivation to keep it as simple as possible, e.g. for maximizing portability, so you can also build ocaml on an OS that does not support such fancy features. Nowadays the OS landscape is quite different, of course, and such frugality can be seen as limitation. The demand for recursive mutexes is certainly low, because you can easily have your own little wrapper around Mutex to get them (there is normally an easy way to recognize the owner). It's just a counter after all. But yes, having this directly in Mutex would make it simpler. Maybe file a wish in the bugtracker? Gerd > > Thanks, > --chet-- > > P.S. I found Markus' email about this: > > >> I'd consider recursive lock acquisitions bad practice. There has > never been a case in numerous complex bindings where I would have > needed this feature. In mission-critical code I even prefer > error-checking mutexes that prevent me from acquiring locks twice > or releasing them once too often. As with everything multithreaded: > the simpler the better. It's hard enough to reason about the simple > case. > > and this is about the ocaml master lock. But it's the only instance I > find of somebody discussing recursive mutexes in ocaml. > > > -- ------------------------------------------------------------ Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------