From: linux@horizon.com
To: davids@webmaster.com
Cc: linux-kernel@vger.kernel.org
Subject: RE: pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow)
Date: 30 Jan 2006 18:37:11 -0500 [thread overview]
Message-ID: <20060130233711.23743.qmail@science.horizon.com> (raw)
Thinking some more on my example, for SCHED_OTHER threads, it is possible
to define the problem away by making pthread_mutex_trylock behave
compatibly with pthread_mutex_lock. That is, threads in pthread_mutex_lock()
are actually descheduled just before waiting for the lock (SCHED_OTHER is
allowed to do that), and when the lock becomes available, the scheduler
then decides who to run through the acquisition code.
As long as pthread_mutex_trylock() succeeds in such a case, some may call
it weird, but it's conformant, and the performance arguments for the
"unfair" case might easily win the day.
This is assuming that SCHED_OTHER can block a process for an arbitrary
time for no good reason. Otherwise, if the lock holder is waiting for
device I/O and no other processes are competing for the CPU, perhaps
blocking on the edge like that for an unbounded time is illegal.
However, if you have priorities and can't redefine locking using creative
scheduling policies, it's less clear. If I have a couple of real-time
tasks, I can't decide arbitrarily to run one in lieu of the other.
For example, suppose that without priority inheritance, you have three
tasks, A (highest priority), B, and C (lowest).
There are three locks. Initially, A holds lock 1 and C holds lock 2.
Then A tries to acquire lock 2. A blocks, so B runs until it blocks trying
to get lock 1. Then C runs and drops lock 2. A gets it, then drops lock 1
and tries to re-acquire it.
It seems to me that the Posix spec mandates that B gets lock 1 (and A
must block) before A can re-acquire it.
(This can also be done with priority inheritance, although it's a bit
different. A version that works whether priority inheritance is
implemented or not is probably possible, too.)
I'm not saying that this is a good thing, but it's distinguishable, and I
don't have any language-lawyer way to escape the obligation.
next reply other threads:[~2006-01-30 23:37 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-30 23:37 linux [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-02-01 17:06 Lee Schermerhorn
2006-01-30 22:01 linux
2006-01-24 22:59 e100 oops on resume Stefan Seyfried
2006-01-24 23:21 ` Mattia Dongili
2006-01-25 9:02 ` Olaf Kirch
2006-01-25 12:11 ` Olaf Kirch
2006-01-25 13:51 ` sched_yield() makes OpenLDAP slow Howard Chu
2006-01-25 17:49 ` Christopher Friesen
2006-01-25 18:26 ` pthread_mutex_unlock (was Re: sched_yield() makes OpenLDAP slow) Howard Chu
2006-01-25 18:59 ` Nick Piggin
2006-01-25 19:32 ` Howard Chu
2006-01-26 8:51 ` Nick Piggin
2006-01-26 14:15 ` Kyle Moffett
2006-01-26 14:43 ` Howard Chu
2006-01-26 19:57 ` David Schwartz
2006-01-26 20:27 ` Howard Chu
2006-01-26 20:46 ` Nick Piggin
2006-01-26 21:32 ` Howard Chu
2006-01-26 21:41 ` Nick Piggin
2006-01-26 21:56 ` Howard Chu
2006-01-26 22:24 ` Nick Piggin
2006-01-27 8:08 ` Howard Chu
2006-01-27 19:25 ` Philipp Matthias Hahn
2006-02-01 12:31 ` Nick Piggin
2006-01-27 4:27 ` Steven Rostedt
2006-01-26 21:58 ` Christopher Friesen
2006-01-27 4:13 ` Steven Rostedt
2006-01-27 2:16 ` David Schwartz
2006-01-27 8:19 ` Howard Chu
2006-01-27 19:50 ` David Schwartz
2006-01-27 20:13 ` Howard Chu
2006-01-27 21:05 ` David Schwartz
2006-01-27 21:23 ` Howard Chu
2006-01-27 23:31 ` David Schwartz
2006-01-30 8:28 ` Helge Hafting
2006-01-26 10:38 ` Nikita Danilov
2006-01-30 8:35 ` Helge Hafting
2006-01-30 11:13 ` Nikita Danilov
2006-01-31 23:18 ` David Schwartz
2006-01-25 21:06 ` Lee Revell
2006-01-25 22:14 ` Howard Chu
2006-01-26 0:16 ` Robert Hancock
2006-01-26 0:49 ` Howard Chu
2006-01-26 1:04 ` Lee Revell
2006-01-26 1:31 ` Howard Chu
2006-01-26 2:05 ` David Schwartz
2006-01-26 2:48 ` Mark Lord
2006-01-26 3:30 ` David Schwartz
2006-01-26 3:49 ` Samuel Masham
2006-01-26 4:02 ` Samuel Masham
2006-01-26 4:53 ` Lee Revell
2006-01-26 6:14 ` Samuel Masham
2006-01-26 8:54 ` Nick Piggin
2006-01-26 14:24 ` Howard Chu
2006-01-26 14:54 ` Nick Piggin
2006-01-26 15:23 ` Howard Chu
2006-01-26 15:51 ` Nick Piggin
2006-01-26 16:44 ` Howard Chu
2006-01-26 17:34 ` linux-os (Dick Johnson)
2006-01-26 19:00 ` Nick Piggin
2006-01-26 19:14 ` linux-os (Dick Johnson)
2006-01-26 21:12 ` Nick Piggin
2006-01-26 21:31 ` linux-os (Dick Johnson)
2006-01-27 7:06 ` Valdis.Kletnieks
2006-01-30 8:44 ` Helge Hafting
2006-01-30 8:50 ` Howard Chu
2006-01-30 15:33 ` Kyle Moffett
2006-01-30 13:28 ` linux-os (Dick Johnson)
2006-01-30 15:15 ` Helge Hafting
2006-01-26 10:44 ` Nikita Danilov
2006-01-26 0:08 ` 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=20060130233711.23743.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=davids@webmaster.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
all inboxes | Powered by JetHome®