On Jan 30, 2009, at 9:25 AM, fred ross-perry wrote:
OK, I have a system made of three applications running simultaneously, one of
them servicing a USB device, the other two are for UI.
They all send messages to one another, sometimes rapidly, using a shared
memory mechanism.
There is some flaw in my architecture that causes intermittent failure on
some multi-core systems, both Mac and PC (same 3-process architecture
is used there).
I worked around the issue on PCs by constraining the 3 processes to all
run on the same processor or core.
Is there a way to do this in OS X? Processor Affinity?
I'm afraid I don't know if there is, but...
this idea doesn't really work around the issue on any platform. You almost certainly still have a bug, it's just harder to observe because now the scheduler must perform a context switch at exactly the right (wrong?) time. All you've done is to reduce the probability of the event, rather than completely remove the possibility.
So you really should figure out the root cause and fix it. You say you're using shared memory for message passing. Most likely you need some extra use of synchronization primitives to ensure that writers and readers do not trip up over each other.