[En-Nut-Discussion] Feature Request 1572837: mutex API nesting level info
duane ellis
ethernut at duaneellis.com
Wed Jul 23 02:46:19 CEST 2008
I've not been following this entire conversation about recursive mutexes
in detail.
>> [about recursive mutexes]
>> That's exactly the point: they are bad because they encourage you to
do the wrong stuff
There is nothing wrong with recursive mutexes.
There is an old saying:
If your only tool is a hammer, everything is a nail.
I have smashed my fingers with that proverbial hammer a few times.
Sometimes - it was the only type of nail I had to build my project.
Sometimes - I did not know any better - and I learned. Smashing fingers
hurt. At times I decided to *never* use that type of nail again. Over
time - I learned how to use that type of nail properly and changed my
mind. In your home, I bet there are over 20 different types and sizes of
nails. The skilled builder who built your home knew when and where to
use each type of nail. (let us hope he was a skilled builder!)
Mutexes are like nails they are building tools, a skilled
craftsmen(person) knows how to choose right one.
The tool box (ethernut) is missing a few other types of nails that
others need.
-------
About the "David Butenhof" - article that somebody linked to:
http://www.zaval.org/resources/library/butenhof1.html
his basic thesis is this:
Recursive locks are so easy - to get wrong - that you should never
use them.
People are lazy - and do not properly study the situation at hand
and choose badly.
Put another way:
It is easy to smash your finger with that type of nail.
So - NEVER use that type of nail.
Period. Full Stop. End of Story.
There should be laws against that type of nail.
You know what?
A scalpel (surgeons knife) has the same property. Either it is in
the hands of an idiot, or a skilled surgeon.
As David Butenhof says:
Recursive mutexes are a hack. There's nothing wrong
with using them, but they're a crutch. Got a broken leg
or library? Fine, use the crutch. But at least be aware
that you're using a crutch, and why;
yes, he goes on, I cut him off - he mentions a a doctor.. To paraphrase
him a bit -
Maybe - given the situation at hand...
recursive mutexes are exactly what the skilled surgeon ordered.
I like to think most of us are of the "skilled surgeon" type.
-Duane.
More information about the En-Nut-Discussion
mailing list