public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: "Scott McCaskill" <scott@magruder.org>
To: "Ye Liu" <yliu@tibco.com>
Cc: <pthreads-win32@sourceware.cygnus.com>
Subject: Re: critical section
Date: Tue, 31 Jul 2001 15:52:00 -0000	[thread overview]
Message-ID: <019101c11a13$7a067970$3e0f020a@hand.local> (raw)
In-Reply-To: <3B6732F5.2EE3990F@tibco.com>

----- Original Message -----
From: "Ye Liu" <yliu@tibco.com>
To: "Scott McCaskill" <scott@magruder.org>
Cc: <pthreads-win32@sourceware.cygnus.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
locked."
>
> My previous understanding is "a mutex cannot be locked twice", which
obviously
> is wrong.
>
> If I use a non-recursive mutex, when a thread try to lock the mutex which
is
> already locked by another one, what happens to the calling thread? Spin or
> yield?
>

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?


  reply	other threads:[~2001-07-31 15:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-31 14:31 Ye Liu
2001-07-31 15:22 ` Scott McCaskill
2001-07-31 15:39   ` Ye Liu
2001-07-31 15:52     ` Scott McCaskill [this message]
2001-08-05 21:31       ` catch (...) Ye Liu
2001-08-05 22:07         ` Scott McCaskill
2001-08-05 22:12           ` Ye Liu
2001-08-06 20:38           ` Ross Johnson
2001-08-07  8:49             ` reentrant
2001-08-07 20:52               ` Ross Johnson
2001-07-31 16:08 critical section Eli Ofenstein
2001-07-31 20:24 ` Ye Liu
2001-07-31 22:47 ` Ross Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='019101c11a13$7a067970$3e0f020a@hand.local' \
    --to=scott@magruder.org \
    --cc=pthreads-win32@sourceware.cygnus.com \
    --cc=yliu@tibco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).