0

I need several client programs (stereo DSP audio generators) to be able to continuously, bidirectionally communicate with an external peripheral on an I2C bus, at a data rate of around 16kB/s with updates occurring every 1ms, all running on a 700MHz CPU. The programs will need simultaneous access to read and write but I don't care about locking on write.

I'm envisaging a daemon to manage the raw I2C communication, with the client audio programs communicating with the daemon via one of the following IPC options:

  • DBUS
  • Berkeley/POSIX sockets
  • Memory mapped file

With DBUS I have performance concerns, and with Berkeley/POSIX sockets I'm not sure about handling multiple clients. It's also important that no locking occurs as the daemon communication has to happen in the same thread as the audio rendering.

Memory mapping appears to suit the task. 10 bytes should do it, I'd need 4 bytes for input, 4 bytes for output, some way of telling that daemon that it should write the output bytes now, and some way of telling the daemon that it should currently be continuously updating the input bytes. But as I understand it memory mapping relies on buffering by the operating system and so I'm not sure what would happen if my daemon updates the input bytes while my client app is in the middle of a read() operation.

What's the best option for inter-process communication in my scenario?

damian
  • 3,604
  • 1
  • 27
  • 46
  • 10 bytes at a time sounds extremely small. Do you absolutely have to have such low latency? Larger buffers would make things much simpler, and increase the chances of timing reliability without needing to resort to mechanisms which attempt to give real time guarantees. – Chris Stratton May 03 '12 at 17:25
  • Yes, latency as low as possible is important. This is for a digital synthesis module calculating audio blocks every ~1ms, that has to sit next to analog synthesis modules (which have no 'latency' so to speak). With a data rate of only 16kB/s I need to be pushing bytes to the clients as soon as they become available. – damian May 04 '12 at 12:06

0 Answers0