[linux-audio-dev] Locks or no locks?

Nedko Arnaudov nedko at arnaudov.name
Fri Jan 12 13:19:11 UTC 2007

"nick thomas" <jesuswaffle at gmail.com> writes:

> I apologize if this has been discussed previously on the list; Google
> didn't seem to be turning anything up from the list archives.
> I'm writing my first DSP program for JACK. My problem is this: I've
> got a high-priority audio synthesis thread, and a low-priority user
> interface thread, and they need to communicate: the UI thread needs to
> tell the synthesis thread to respond to the user twisting knobs and
> moving sliders in the interface, and the the synthesis thread needs to
> tell the UI thread what it's doing, so that the UI thread can update
> its monitoring widgets. I'm sure that this is an extremely common
> situation for JACK programs, and I was wondering how to handle it.
> I know of two possible approaches: using locks and shared memory, or
> using FIFOs and no shared memory. Vanilla pthreads provides direct
> support for the former approach, and JACK's ringbuffer interface seems
> to provide the necessary primitives to implement the latter approach.
> A lock-based system would probably be substantially simpler to
> implement than a lock-free one; however, I can imagine some possible
> priority inversion issues with a lock-based system. I don't know if
> that is ever a problem in practice, with real-time scheduling enabled.
> Anyway, there's my question: which approach (lock-based or lock-free)
> is generally favored for JACK programs? Thanks for helping a newbie
> out!

Recently I had very similar/same problem for the lv2 dynparam extension
support libraries. Since I missed article explaining all possible
approaches with pros and cons I tried to make one. It available here:


I plan to move it to our lad wiki once it is up, so anybody can
contribute to it.

This really a *draft* document, but I made it with hope that someone will
find it helpful.

Nedko Arnaudov <GnuPG KeyID: DE1716B0>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20070112/869c194c/attachment.pgp>

More information about the Linux-audio-dev mailing list