This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: critical section
----- Original Message -----
From: "Ye Liu" <firstname.lastname@example.org>
To: "Scott McCaskill" <email@example.com>
Sent: Tuesday, July 31, 2001 5:36 PM
Subject: Re: critical section
> In the book of "Programming with POSIX Threads", the author metioned
> "You cannot lock a mutex when the calling thread already has that mutex
> My previous understanding is "a mutex cannot be locked twice", which
> is wrong.
> If I use a non-recursive mutex, when a thread try to lock the mutex which
> already locked by another one, what happens to the calling thread? Spin or
I don't know for sure, but I would expect it to yield. It seems like the
spinning that your code is doing would be purely wasteful unless the
spinning thread and the mutex-holding thread are on different processors.
Can you give us a better idea of what you're trying to accomplish that
pthread_mutex won't do for you?