From: Jakub Jelinek <jakub@redhat.com>
To: Eirik Nordbroden <eirik.nordbroden@morecom.no>
Cc: linux-kernel@vger.kernel.org, Ulrich Drepper <drepper@redhat.com>
Subject: Re: Question on Linux and SCHED_FIFO scheduling for POSIX threads
Date: Fri, 16 Jul 2004 05:29:23 -0400 [thread overview]
Message-ID: <20040716092923.GO21264@devserv.devel.redhat.com> (raw)
In-Reply-To: <40FB8221D224C44393B0549DDB7A5CE8378C37@tor.lokal.lan>
On Fri, Jul 16, 2004 at 11:11:54AM +0200, Eirik Nordbr?den wrote:
> Can anybody clarify how SCHED_FIFO scheduling and thread priorities works
> on Linux? We are novices in this field in the Linux environment and needs
> help to understand how it works. To verify the behaviour we made up a
> small test program consisting of four threads and a mutex. We have run the
> program on both the 2.6.5 and 2.6.7 kernels with same behaviour.
>
> Program:
>
> T-MAIN: scheduling policy=SCHED_FIFO, priority=1
> T-LP: scheduling policy=SCHED_FIFO, priority=10
> T-MP: scheduling policy=SCHED_FIFO, priority=20
> T-HP: scheduling policy=SCHED_FIFO, priority=30
>
> The program runs like this:
>
> T-MAIN locks mutex => T-MAIN runs.
> T-MAIN creates T-LP => T-LP runs.
> T-LP waits for mutex => T-MAIN runs.
> T-MAIN creates T-MP => T-MP runs.
> T-MP waits for mutex => T-MAIN runs.
> T-MAIN creates T-HP => T-HP runs.
> T-HP waits for mutex => T-MAIN runs.
> T-MAIN waits 3 seconds and unlocks mutex => T-LP runs.
> T-LP waits 3 seconds and unlocks mutex => T-MP runs.
> T-MP waits 3 seconds and unlocks mutex => T-HP runs.
> :
> :
>
> For us this is unexpected behaviour. We would expect that the thread with
> the highest priority would be scheduled to run when a number of threads is
> waiting for a mutex and the mutex is unlocked. Can anyone clarify this?
> Have we missed something?
NPTL locking is implemented on top of futex(2).
futex(2) queues are ATM FIFOs, not priority based queues.
Check http://developer.osdl.org/dev/robustmutexes/
for some patches which introduce priority based queues for futexes (well,
AFAIK they introduce new syscalls and call the primitive fusyn instead).
Jakub
prev parent reply other threads:[~2004-07-16 9:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-16 9:11 Question on Linux and SCHED_FIFO scheduling for POSIX threads Eirik Nordbrøden
2004-07-16 9:29 ` Jakub Jelinek [this message]
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=20040716092923.GO21264@devserv.devel.redhat.com \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=eirik.nordbroden@morecom.no \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.