Fun with Shared Memory Pipes

So I’ve got this sweet python daemon that uses stdin/stdout for IO. It occurred to me that using such operating system pipes would add a possible bottleneck when using ::read() and ::write(). That is not a good idea from within an audio thread, because the results could be unpredictable. I know pretty much *nothing* about shared memory, but it occurred to me that I could implement a pipe using a shared memory ring buffer to get around those possible performance penalties.

(Thanks unnamed dude at PyGameSF for the idea)

But, I have no idea how shared memory operations perform, how reliable that performance is, and how it differs on windows and mac. I have a hunch that it behaves just like using an OS mutex in your threaded code.

So if you moved python to a new process for multiprocessing, and used stdin/stdout to talk to it from your host app, is this a good idea? I would implement a simple ring buffer and just write my packets as char data to it, hopefully using some kind of cross-process lock to signal that data is available.

Time to start reading some man pages I guess.

By | 2010-03-19T20:35:00+00:00 March 19th, 2010|Uncategorized|0 Comments

Leave A Comment

− 2 = 7