Correct me if I'm wrong, but I'm surprised this hasn't been asked before on here ...
Correct me if I'm wrong, but I'm surprised this hasn't been asked before on here ...
The answers already given are informative, but most mention the idea that shared memory is faster than message passing, which is actually a pretty naïve statement. In any real system doing something useful, shared memory access needs locking mechanisms to control access from seperate threads, which almost always ends up SLOWER than implementing the same system using message passing.
The throughput of the message passing system may be too low for some applications that require fast responses time, but if you need higher speed or real time processing, then you can use a shared memory system.
Shared memory S/m require to communication process to share some variable . The processes as expected to exchange information through the use of these shared variables . In a shared memory scheme the responsibility for providing communication rests with the application programmers. The operating system only nNeeds to provide shared memory.
Did a test in a course at DTU calculating PI, and MPI(Message Passing) was generally better than pthreads or OpenMP(Share Memory) on our HPC.