Shared memory

Shared memory

In computing, shared memory is a memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Depending on context, programs may run on a single processor or on multiple separate processors. Using memory for communication inside a single program, for example among its multiple threads, is generally not referred to as "shared memory".

In hardware

In computer hardware, shared memory refers to a (typically) large block of random access memory that can be accessed by several different central processing units (CPUs) in a multiple-processor computer system.

A shared memory system is relatively easy to program since all processors share a single view of data and the communication between processors can be as fast as memory accesses to a same location.

The issue with shared memory systems is that many CPUs need fast access to memory and will likely cache memory, which has two complications:
* CPU-to-memory connection becomes a bottleneck. Shared memory computers can not scale very well. Most of them have only ten processors.
* Cache coherence: Whenever one cache is updated with information that may be used by other processors, the change needs to be reflected to the other processors, otherwise the different processors will be working with incoherent data (see cache coherence and memory coherence). Such coherence protocols can, when they work well, provide extremely high-performance access to shared information between multiple processors. On the other hand they can sometimes become overloaded and become a bottleneck to performance.

The alternatives to shared memory are distributed memory and distributed shared memory, each having a similar set of issues. See also Non-Uniform Memory Access.

In software

In computer software, "shared memory" is either

* a method of inter-process communication (IPC), i.e. a way of exchanging data between programs running at the same time. One process will create an area in RAM which other processes can access, "or"
* a method of conserving memory space by directing accesses to what would ordinarily be copies of a piece of data to a single instance instead, by using virtual memory mappings or with explicit support of the program in question. This is most often used for shared libraries and for Execute in Place.

Since both processes can access the shared memory area like regular working memory, this is a very fast way of communication (as opposed to other mechanisms of IPC such as named pipes, Unix sockets or CORBA). On the other hand, it is less powerful, as for example the communicating processes must be running on the same machine (whereas other IPC methods can use a computer network), and care must be taken to avoid issues if processes sharing memory are running on separate CPUs and the underlying architecture is not cache coherent.

IPC by shared memory is used for example to transfer images between the application and the X server on Unix systems, or inside the IStream object returned by CoMarshalInterThreadInterfaceInStream in the COM libraries under Windows.

Dynamic libraries are generally held in memory once and mapped to multiple processes, and only pages that had to be customized for the individual process (because a symbol resolved differently there) are duplicated, usually with a mechanism that transparently copies the page when a write is attempted, and then lets the write succeed on the private copy.

POSIX provides a standardized API for using shared memory, "POSIX Shared Memory". This uses the function shm_open from sys/mman.h.

Unix System 5 provides an API for shared memory as well. This uses shmget from sys/shm.h.

BSD systems provide "anonymous mapped memory" which can be used by several processes.

lookahead buffer can be created from shared memory in window mobile 6 using the NDIS library function-NdisCreateLookaheadBufferFromSharedMemory

ee also

*Shared Memory Architecture, where the graphics chip uses main system RAM
*Global variable

External links

* [http://www.ossp.org/pkg/lib/mm/ Shared Memory Allocation]
* [http://www.lfbs.rwth-aachen.de/content/smi Shared Memory Interface]
* [http://www.inf.pucrs.br/~pinho/shared_memory_library.htm Shared Memory Library FAQ] by Márcio Serolli Pinho
*Article " [http://www.cs.cf.ac.uk/Dave/C/node27.html IPC:Shared Memory] " by Dave Marshall
* [http://www.opengroup.org/onlinepubs/007908799/xsh/sysshm.h.html shared memory facility] from the Single UNIX Specification
* [http://www.opengroup.org/onlinepubs/007908799/xsh/shm_open.html shm_open] - POSIX
* [http://docs.sun.com/app/docs/doc/817-0691/6mgfmmdt3?a=view shmop] - documentation from SunOS 5.9
* [http://gim.org.pl/uczelnia/PSI/2.ipc/ Linux and Solaris IPC examples] IPC SystemV shared memory. IPC message queues - posix ans system V.
* [http://msdn2.microsoft.com/en-us/library/aa374778.aspx CreateSharedMemory function] from Win32-SDK
* [http://www.php.net/manual/en/ref.shmop.php Functions in PHP-API]
*Paper " [http://allocator.sourceforge.net/rtlinux2003.pdf A C++ Pooled, Shared Memory Allocator For The Standard Template Library] " by Marc Ronell
* [http://citeseer.csail.mit.edu/cs?q=shared+memory+library Citations from CiteSeer]
* [http://www.ecst.csuchico.edu/~beej/guide/ipc/shmem.html Linux Shared Memory Allocation with example ]
* [http://www.boost.org/doc/libs/1_36_0/doc/html/interprocess.html Boost.Interprocess C++ Library]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Shared Memory — (dt. „gemeinsam genutzter Speicher“) wird in der Computertechnologie verwendet und kann dabei je nach Kontext eine andere Technologie beschreiben: Shared Memory in der Interprozesskommunikation (IPC): Hier nutzen zwei oder mehrere Prozesse einen… …   Deutsch Wikipedia

  • Shared memory — (dt. „geteilter Speicher“) bezeichnet eine bestimmte Art der Interprozesskommunikation (IPC). Bei dieser Art nutzen zwei oder mehrere Prozesse einen bestimmten Teil des Hintergrundspeichers (RAM) gemeinsam. Für alle beteiligten Prozesse liegt… …   Deutsch Wikipedia

  • Shared Memory —   [dt. »geteilter Speicher«], ein Bereich des Arbeitsspeichers, der von mehreren Benutzern oder Prozessen gemeinsam genutzt werden kann. Bei kleinen Netzwerken mit Nutzung von Groupware kann sich der Begriff auch auf die Nutzung der… …   Universal-Lexikon

  • shared memory — bendroji atmintis statusas T sritis informatika apibrėžtis ↑Atminties sritis, kurią bendrai naudoja keli procesai duomenų mainams. Per ją vyksta duomenų mainai tarp procesų. atitikmenys: angl. shared memory ryšiai: dar žiūrėk – atmintis palygink… …   Enciklopedinis kompiuterijos žodynas

  • Shared Memory Architecture — In computer architecture, Shared Memory Architecture (SMA) refers to a design where the graphics chip does not have its own dedicated memory, and instead shares the main system RAM with the CPU and other components. This design is used with many… …   Wikipedia

  • shared memory —    An interprocess communications technique in which the same memory is accessed by more than one program running in a multitasking operating system.    Semaphores or other management elements prevent the applications from colliding or trying to… …   Dictionary of networking

  • shared memory —    Portion of memory accessible to multiple processes …   IT glossary of terms, acronyms and abbreviations

  • Distributed shared memory — (DSM), in Computer Architecture is a form of memory architecture where the (physically separate) memories can be addressed as one (logically shared) address space. Here, the term shared does not mean that there is a single centralized memory but… …   Wikipedia

  • Distributed Shared Memory — (verteilter gemeinsamer Speicher, DSM) ist ein Ausdruck aus der Informatik und bezieht sich auf die Verteilung des Arbeitsspeichers von Computerclustern. Da sich die einzelnen CPUs nicht auf einem gemeinsamen Mainboard befinden, existiert auch… …   Deutsch Wikipedia

  • Virtual shared memory — Als Virtual Shared Memory bzw. virtueller Gemeinspeicher bezeichnet man eine Technik zur Verwendung gemeinsamer Speicherbereiche in Computernetzwerken oder Computerclustern. Dabei muss der gemeinsame Speicher nicht physikalisch existieren,… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”