public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Seigh <jseigh_02@xemaps.com>
To: linux-kernel@vger.kernel.org
Subject: Re: any fairness in NTPL pthread mutexes?
Date: Mon, 31 Oct 2005 14:09:03 -0500	[thread overview]
Message-ID: <dk5q3m$tmq$1@sea.gmane.org> (raw)
In-Reply-To: <43665B08.6040005@nortel.com>

Christopher Friesen wrote:
> 
> I'm using NPTL.
> 
> If I have a pthread mutex currently owned by a task, and two other tasks 
> try to lock it, when the mutex is unlocked, are there any rules about 
> the order in which the waiting tasks get the mutex (ie priority, FIFO, 
> etc.)?
> 

SCHED_OTHER.

If there are any waiting tasks when the mutex is unlocked, one of the waiting
tasks is woken up but not given lock ownership.  It has to acquire the mutex
on its own.  If it fails because another thread got the mutex first, then it
goes back to waiting.   It's sometimes called an adaptive mutex.  It's a little
faster than a FIFO mutex.  It recovers from intermittent contention better.
With heavier contention, some threads in theory could starve, something that
wouldn't happen with a FIFO mutex.

--
Joe Seigh


  parent reply	other threads:[~2005-10-31 19:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-31 17:57 any fairness in NTPL pthread mutexes? Christopher Friesen
2005-10-31 18:06 ` Lee Revell
2005-10-31 22:09   ` Lee Revell
2005-10-31 19:09 ` Joe Seigh [this message]
2005-11-02 17:47 ` James Courtier-Dutton
2005-11-02 18:47   ` Lee Revell
     [not found] <53M7O-7Se-33@gated-at.bofh.it>
2005-11-01  3:52 ` Robert Hancock

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='dk5q3m$tmq$1@sea.gmane.org' \
    --to=jseigh_02@xemaps.com \
    --cc=linux-kernel@vger.kernel.org \
    /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