* Question on Linux and SCHED_FIFO scheduling for POSIX threads
@ 2004-07-16 9:11 Eirik Nordbrøden
2004-07-16 9:29 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Eirik Nordbrøden @ 2004-07-16 9:11 UTC (permalink / raw)
To: linux-kernel; +Cc: Bård Laukvik
Hello
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?
PS We have also tested this with POSIX and System V semaphores in stead of the mutex with same behaviour.
Eirik Nordbrøden
moreCom A/S http://www.moreCom.no/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question on Linux and SCHED_FIFO scheduling for POSIX threads
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
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2004-07-16 9:29 UTC (permalink / raw)
To: Eirik Nordbroden; +Cc: linux-kernel, Ulrich Drepper
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-16 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox