[LAD] non-blocking intra-process messaging

Stephen Sinclair radarsat1 at gmail.com
Thu Aug 9 19:20:18 UTC 2007


I have some multi-threaded audio software that passes data around
using pointers to data structures.  However, I'd like a more
generalized message passing system.  The only requirements are that it
cannot block the sender or receiver (they are considered soft
'real-time'), and also that multiple senders should be able to send a
message to the same receiver at the same time (which makes
non-blocking circular buffers a difficult approach).  I'm thinking of
designing something that uses atomic_ops to implement quick locking of
portions of a message queue.

Anyways, my idea is to use something like OSC for message passing, but
without the "path" part of the OSC address.  (That is, the path is
already resolved, since threads share memory..)

Does anyone know if something like this has been done previously?

Ideally it would easily scale to inter-process communication, if in
the future I wanted to turn my threads into processes.  (Another
reason for basing it on OSC..)

Does any of this make sense?

Basically I've been running into a lot of shared-memory threading
problems, which in retrospect should have been expected and avoidable
if I'd spent more time designing my message passing system.  (At the
time I hadn't heard of the atomic_ops library.)

I might have designed the whole system to use timers instead of
threads and avoided a lot of headaches, but I wanted the threads to be
splittable across CPU cores.  (Which arguably is a good reason to use
processes.. admittedly the whole thing is starting to point me towards
the "threads are a bad idea" camp.)


More information about the Linux-audio-dev mailing list