[LAD] Writing to an eventfd from a realtime thread
Clemens Ladisch
clemens at ladisch.de
Wed Sep 24 12:12:09 UTC 2014
William Light wrote:
> At the moment, when the audio thread (the JACK callback) needs to send a
> message over a channel to another thread, it follows the common codepath
> of appending the message to the channel's ring-buffer and then
> write()ing to the eventfd. I suspect this is not real-time safe, but is
> it something I should lose sleep over?
Well, you should know how your ring buffer behaves (i.e., if it drops
the message or blocks when it overflows).
As for the eventfd, it could block only if the counter value
exceeded 0xfffffffffffffffe. I'd guess your ring buffer cannot get
that big.
(With the ring buffer and the eventfd, you are implementing what looks
like a pipe. If you need to copy the data to the ring buffer anyway,
and if your messages and the entire buffer fit into the pipe limits
(4 KB and 1 MB), you could simply use a pipe to begin with; see
<http://man7.org/linux/man-pages/man7/pipe.7.html>.)
Regards,
Clemens
More information about the Linux-audio-dev
mailing list