|

Think of a single large blackboard, marked off so that all data elements have their own unique locations assigned, and all the members of a programming team are working together to test out a particular algorithmic design, all at the same time...this is an example of shared memory in action:
- The same memory is accessible to multiple processors
All processors associated with the same shared memory structure access the exact same storage, just as all the programmers in the above example used the same unique data-element location on the blackboard to record any changes in those values.
- Synchronization is achieved by tasks' reading from and writing to the shared memory.
In just the same way that the programmers would have to take turns writing into the blackboard locations, so the processors have to take turns accessing the shared memory cells. This makes it easy to implement synchronization among all of the tasks, by simply coding them all to watch particular locations in the shared memory, and not do anything until certain values appear...of course, you also have to arrange for those values to appear.
- A shared memory location must not be changed by one task while another, concurrent task is accessing it.
If one programmer is trying to use a value from the blackboard to calculate some other value, and sees another programmer begin to write over the one being copied, screams and shouts and thrown chalk and erasers can keep the needed value from being overwritten until it's no longer needed. Processors use more polite means of achieving the same ends, sometimes called guards or spin-locks: these are shared variables associated with the location in question, and a task can be programmed not to change the location before first gaining sole ownership of the guard; if all tasks have been programmed so that sole ownership of the guard is required before either reading or writing the associated location, this guarantees that no task will be attempting to read while another is busy changing that same value.
- Data sharing among tasks is fast (speed of memory access)
One of the most attractive features of shared memory, besides its conceptual simplicity, is that the time to communicate among the tasks is effectively a factor of a single fixed value, that being "the time it takes a single task to read a single location." There are, of course, limitations to this sharing...
- Disadvantage: scalability is limited by number of access pathways to memory
If you have more tasks than connections to memory, you have contention for access to the desired locations, and this amounts to increased latencies while all tasks obtain the required values. So the degree to which you can effectively scale a shared memory system is limited by the characteristics of the communication network coupling the processors to the memory units. See the Dining Philosophers problem for a discussion of this.
- User is responsible for specifying synchronization, e.g., locks
Any time resources are shared among multiple parties, whether these parties be human, canine, insect or computer, there will have to be some form of control imposed. In the case of shared memory, this "control" takes the form of different ways in which synchronization is established and enforced. Spin-locks, as previously described, are one common form of enforcing synchronization; others include barriers, mutexes, and system-specific entities. What is common to all of them is that their use is all under the control, and hence the responsibility, of the user.
- This model is often referred to as SMP, for Symmetric MultiProcessors, because a common implementation is for several processors of the same type ("symmetric") to access the same shared memory.
- Examples
A number of commonly encountered multi-processor systems implement a shared-memory programming model; examples include:
- NEC SX-5;
- SGI Power Onyx/ Origin 2000;
- Hewlett-Packard V2600/HyperPlex;
- SUN HPC 10000 400 MHz ;
- DELL PowerEdge 8450.
- Cache coherence and memory consistency are two of the issues that need to be understood when dealing with parallel computing.
|