Shared Memory: Difference between revisions

From
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 3: Line 3:
For this to work, the Operating System needs to become involved. It has to map the memory into both processes' address space in an appropriate manner.
For this to work, the Operating System needs to become involved. It has to map the memory into both processes' address space in an appropriate manner.
Note that certain problems arise when shared memory is involved. For example, [[Race Condition]]s can occur. Thus, in most applications, it is essential that the processes be synchronized in some way. See also [[Synchronization]].
Note that certain problems arise when shared memory is involved. For example, [[Race Condition]]s can occur. Thus, in most applications, it is essential that the processes be synchronized in some way. See also [[Synchronization]].
In systems implementing the Win32 API, shared memory is implemented by use of Memory Mapped Files (MMFs, sometimes also called Sections). In these systems, most of the [[Interprocess Communication]] methods are internally implemented using MMFs.
In systems implementing the Win32 API, shared memory is implemented by use of Memory Mapped Files (MMFs, sometimes also called Sections). In these systems, most of the [[Inter Process Communication]] methods are internally implemented using MMFs.

Revision as of 20:40, 10 April 2005

In today's modern operating systems, every Process believes to possess the complete available address space. On 32-bit systems, this means 4 GB of adressable space. This also means that no process can see another process' adress space. However, sometimes it is necessary for processes to share memory. Sharing memory for two processes means that there is a region of memory which both processes can access (read/write) such that both processes see the same contents of that memory. Example: Consider two Processes A and B. Both have a shared memory region. In Process A, this region starts at MA, in Process B it starts at MB. Let A write the value 0x23 to MA+4, that is, 4 bytes into the shared region. Then Process B sees, in its own address space, the value 0x23 at MB+4. For this to work, the Operating System needs to become involved. It has to map the memory into both processes' address space in an appropriate manner. Note that certain problems arise when shared memory is involved. For example, Race Conditions can occur. Thus, in most applications, it is essential that the processes be synchronized in some way. See also Synchronization. In systems implementing the Win32 API, shared memory is implemented by use of Memory Mapped Files (MMFs, sometimes also called Sections). In these systems, most of the Inter Process Communication methods are internally implemented using MMFs.