NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/38741: priority inversion in libpthread breaks apps that use SCHED_FIFO threads

>Number:         38741
>Category:       kern
>Synopsis:       priority inversion in libpthread breaks apps that use 
>SCHED_FIFO threads
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 25 14:05:00 +0000 2008
>Originator:     Andrew Doran
>Release:        4.99.62
The NetBSD Project
T1, low priority thread acquires a spinlock in libpthread. It's preempted
by T2, which is a realtime thread (SCHED_FIFO) with a high priority. The
system has a single CPU. T2 busywaits for the spinlock held by T1. T2
is much higher priority and does not have a fixed time quantum, so will
spin indefinitely. Because of T2's high priority, T1 will never get CPU 
time and so the spinlock will never be released.

Code inspection.
Short term: don't use spinlocks, use pthread_mutex_t wherever possible.

Longer term: for real-time threads, introduce kernel assisted mutexes & 
rwlocks that implement priority inheritance.

Home | Main Index | Thread Index | Old Index