these two method are often used in OS and parallel and distributed system and many other place in computer.
one example of shared memory is http://blog.163.com/zhe_wang_2009/blog/static/172282121201174486887/
And, Message passing is a way of invoking behavior through some intermediary service or infrastructure. Rather than directly invoke a process, subroutine, or function by name as in conventional programming, message passing sends a message to a process (which may be an actor or object) and relies on the process and the supporting infrastructure to select and invoke the actual code to run.Message passing is used ubiquitously in modern computer software. It is used as a way for the objects that make up a program to work with each other and as a way for objects and systems running on different computers (e.g., the Internet) to interact. Message passing may be implemented by various mechanisms, including channels.