Re: [linux-audio-dev] Multithreaded programming for a poll model?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Multithreaded programming for a poll model?
From: Daniel Schmitt (pnambic_AT_unu.nu)
Date: Thu Jun 17 2004 - 23:53:52 EEST


On Thursday 17 June 2004 21:24, Jesse Chappell wrote:
> Chris Cannam wrote on Thu, 17-Jun-2004:
> > [...]
> > This is pretty much what we're doing in Rosegarden 0.9.8, but now that
> > I describe it, I realise I don't know for absolutely sure whether
> > pthread_cond_signal is itself RT-safe. More information or better
> > alternatives are welcome.
>
> If you are using pthread_mutex_trylock() to lock the condition's
> mutex in the RT thread, then you are ok. If you can't aqcuire
> the lock (hence can't signal) that is usually OK because the other
> thread is already doing work anyway.

In fact, you don't need to own the mutex to signal or broadcast the condition.
The one thing you lose by doing that is the guarantee that the
highest-priority waiter will run immediately, since it will need to reacquire
the mutex, and some lower-priority thread that was not waiting could be
holding it. In this situation here, where there is exactly one thread
waiting, and that thread is the only potential owner of the mutex, that's of
course not an issue.

Ciao,

Daniel.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu Jun 17 2004 - 23:47:53 EEST