On Sun, Apr 24, 2005 at 03:59:17PM -0700, Ken McMillan wrote:
>
> I've been puzzling over something that I thought
> someone on this list
> might have a good solution for. I need to make a low
> priority
> (non-real time) thread wait for a real time thread to
> do something. I
> can't use a semaphore or condition variable for this,
> because that
> would mean the low priority thread must briefly take a
> lock while
> examining the condition variable or sempahore. If it
> were to be
> pre-empted while holding this lock, the RT thread
> could block waiting
> to obtain the lock in order to signal the condition or
> modify the
> semaphore.
>
This problem is called priority inversion.
> I could prevent this by raising the priority of the
> low priority
> thread before taking the lock, but I don't know how to
> do this in
> a portable way (i.e., I want my app to port to windows
> and mac, but
> even on "posix compliant" systems, getting RT
> privileges seems to
> be pretty system-dependent).
>
This kind of solution to priority inversion is called priority inheritance.
AFAIK it is in POSIX, but Linux does not implement it (I think neither do
MacOS or Windows).
It actually seems to be implemented in Ingos realtime-preempt patch, but only
in kernel space. There also exists the robust mutex project from
Intel which features a patched kernel and NPTL.
http://developer.osdl.org/dev/mutexes/
http://developer.osdl.org/dev/robustmutexes/
One fine day these may make RT programming on Linux a lot easier, but
right now this is purely experimental, and also not portable to Systems
that are not fully POSIX compliant in this particular area. (Still assuming
that this stuff actually is in POSIX. I'd ask where to get the specs, but
then next thing you know I'll be writing my own operating system from scratch,
and I just don't have time for that :-D )
cheers,
Christian
Received on Mon Apr 25 08:15:04 2005
This archive was generated by hypermail 2.1.8 : Mon Apr 25 2005 - 08:15:05 EEST