(http://node1.yo-linux.com/cgi-bin/man2html?cgi_command=pthread_mutex_lock).
Sorry, this page comes on a lively gray (RGB=192) background. I wonder whay
not green on brown, that would be even cooler.
which is an example of design by a commity (or design by a management). I
you cannot acquire it recursively (you'll deadlock). There is also
by wrong thread. Anybody tell me, why any other variants besides a recursive
You also cannot use pthread_mutex across processes. This is just a
CRITICAL_SECTION rough equivalent.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
Two weeks ago, I taught my Systems Programming Course, in which we use
mutexes in the lab
on Thursday. I also teach about critical sections. Last week I taught
our Device Driver
course, in which I taught what a mutex is. As well as spin locks, fast
mutexes, and
executive resources. I suspect I actually understand what a mutex is.
For example, you asked a question which clearly shows you do not undertand
recursive
acquisition semantics, one of the fundamental properties of a mutex. I
quote from your
post:
if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);
if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);
You got two message boxes, which is EXACTLY what you should see happen!
Now, if I say :"this would violate the fundamental design of a mutex to
have this
deadlock", and it is obvious that it does not deadlock, it is almost
certainly because I
understand how mutexes work. You are insisting that it *should* deadlock,
and this shows
you do *not* understand how a mutex works.
What you are asking violates the fundamental design of a mutex. I would
suggest that you
are the one who doesn't understand them. Of course, had you actually read
the
documentation on a mutex, you would have seen the paragraph that says (and
I have pasted
this from the MSDN documetation on CreateMutex):
================================
"The thread that owns a mutex can specify the same mutex in repeated wait
function calls
without blocking its execution. Typically, you would not wait repeatedly
for the same
mutex, but this mechanism prevents a thread from deadlocking itself while
waiting for a
mutex that it already owns. However, to release its ownership, the thread
must call
ReleaseMutex once for each time that the mutex satisfied a wait."
=================================
So you are asking how to create a situation that violates the fundamental
*documented*
design of a mutex, and I told you that your suggestion violates the
fundamental design of
a mutex; your response is that I have a limited understanding of what a
mutex is, so
please explain exactly what part of a mutex I don't understand?
joe
On Sun, 01 Jul 2007 01:40:28 -0700, Frank Cusack <fcusack@fcusack.com>
wrote:
On Sat, 30 Jun 2007 23:05:58 -0400 Joseph M. Newcomer
<newcomer@flounder.com> wrote:
You can't, it is impossible; it violates the fundamental design of a
mutex!!!!
You obviously are limited in your understanding of what a mutex is.
-frank
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm