Google Groups Home
Help | Sign in
Message from discussion recursive mutexes
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Giancarlo Niccolai  
View profile
 More options Jul 16 2004, 5:32 am
Newsgroups: comp.programming.threads, comp.unix.programmer
Followup-To: comp.programming.threads
From: Giancarlo Niccolai <no...@nothing.it>
Date: Fri, 16 Jul 2004 11:32:32 +0200
Local: Fri, Jul 16 2004 5:32 am
Subject: Re: recursive mutexes

red floyd wrote:
> Alexander Terekhov wrote:
>> red floyd wrote: ...

>> Don't use recursive mutexes. It's akin to sex with used condoms. ;-)

>> regards,
>> alexander.

> May I ask why?

Other than Mr. Schwartz reply (which I consider absolutely good), I may add
also that recursive mutexes are slower (they must check if they are locked
or not) and brings you to program less carefully about shared resource
usage. If you stop to think twice about that, you'll realize that when you
want to lock a resource, you just want to know that you are the owner of
that, and not that you've been entitled to be the owner N times...

The only reason I can see for recursive mutexes is to call recursive
functions, where the locks are so complex that writing a wrapper is not a
viable way, or to create "onion peel" like libraries where the lower levels
are completely obscure and abstracted to the higher ones, and there is
sometimes the need to "extend" the mutex locking also to some function in
the higher levels; but in both the cases there are probably better ways to
deal with the problem with a non recursive mutex, with a little more
cleaner design effort.

Giancarlo.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google