What are the ways to achieve shared memory?

Embedded C Interview Question

What are the ways to achieve shared memory?

Answer

Computers using shared memory usually have some kind of local cache on each processor to reduce the number of accesses to shared memory. This requires a cache consistency protocol to ensure that one processor's cached copy of a shared memory location is invalidated when another processor writes to that location. 

The alternative to shared memory is message passing where all memory is private to some particular processor and processors communicate by sending messages down special links. This is usually slower than shared memory but it avoids the problems of contention for memory and can be implemented more cheaply.