I read a lot of articles about differences between message queue and shared memory. But still not clear which one is good for achieving good performance.
Like shared mem
Message queue has inherent synchronization overhead, guarantee of safety at cost of performance. Shared memory has no safeguards - if two threads access it simultaneously, they will possibly conflict (write inconsistent data) unless you assure thread safety yourself. This may be insignificant in case minor errors are allowed (say, the data goes to analog output and some noise is acceptable), so you can skip error checking altogether, and go along with "good enough" approach at quite high performance gain. Also, shared memory allows for exchange of big pieces of data and common and persistent storage of data common to several apps saving memory storage. Message queues are for lower throughput - you can for example utilize them for safeguarding access to shared memory.