Le 31 oct. 05 à 02:18, fons adriaensen a écrit :
On Mon, Oct 31, 2005 at 01:44:45AM +0100, Florian
Schmidt wrote:
Btw: i just discovered that pthread mutexes and
condvars can have a
"process shared" flag which makes it possiblo to synchronize threads
across processes as it seems. Could be useful for jack, no?
pthread_condvar_setpshared()
pthread_mutexattr_setpshared()
Or do i misread that manpage?
Manpages sometimes document things that are not (yet) implemented.
Maybe it is now (in 2.6) but I'm quite sure it was not in 2.4.
For jack, all you need is the futexes (which are system wide,
I tested that). I'm pretty sure that all of jack can be written
without requiring a mutex shared with the client threads.
A big advantage of using futexes in shared memory would be
that they don't have to be recreated each time the callback
order changes - unlike the pipes, they are not bound to a
process, and to modify the 'trigger chain' all you need is
to change some pointers.
In Jackdmp we have tested 2 system for inter-process synchronization:
fifo (the way it was done in regular jackd) and POSIX named semaphore
(which are built on top of futex on recent system version)
In both cases, each already running client get access to the
synchronization primitive (fifo or POSIX named sema) defined by a new
coming client. The synchronization primitive is "opened" once when a
new client appears and is "closed" when the client quits. The
synchronization primitive that has to be signaled then depends of the
graph topology.
But ISTR that OSX only has named shared futexes (i.e.
accessed
via a file descriptor), and then of course the problem remains.
On OSX, on can use Mach semaphore (internal and non portable...)
POSIX named semaphore or fifo.
Stephane