Background
In Unix-like systems for IPC (Inter-process communication) communication, Shared memory is the most efficient, I call it the king of IPC.
Introduction
This article describes how to use Shared Memory (Shared Memory) for IPC (inter-process
# Include # Include IntShmget(Key_t key, size_t size, int shmflg );
Key_t key-----------------------------------------------Key:0/ipc_private. When the key value is ipc_private, The shmget () function creates a new shared memory. If the key value is
###################################################Shared Memory AreaShared memory is the fastest in the IPC format because shared memory does not exchange data with the kernel.A child process that is derived from fork does not share the memory area
Each process has a different user address space, the global variables of any one process can not be seen in another process, so the process to exchange data between the kernel, the kernel to open a buffer, process 1 data from the user space to the
Shared memory
The essence of interprocess communication is to allow different processes to access a common resource.1. Shared memory is the fastest way to communicate between processes (why)2. Shared memory does not provide any synchronization
Shared memory Basic ConceptsThe shared memory area is the fastest IPC form . Once such memory is mapped to the address space of the process that shares it, these inter-process data transfers no longer involve the kernel, in other words, the process
System V IPC parameters
name
Description
Reasonable Value
SHMMAX
Maximum shared memory segment size (bytes)
At least a few megabytes (see text)
Shmmin
Minimum shared memory segment size
Http://www.cnblogs.com/dubingsky/archive/2009/06/18/1505841.html
One, what is the shared memory area
The shared memory area is the fastest available form of IPC. It allows multiple unrelated processes to access the same part of the logical memory.
During the experiment on shared memory today, we found that the usage of functions related to semaphores used in the previous experiment was forgotten .. It is a waste of time to search again. I decided to drag this kind of things from others' blogs
Shared memoryShared Memory is a portion of physical memory that is shared by multiple processes. Shared memory is the quickest way to share data between processes, where a process writes data to shared memory, and all processes that share that
11In Figure 2, process a requests a shared memory segment. Process A initializes the memory segment so that it is ready to receive access. This process gives the memory segment a name so that other processes can find it. In general, memory segment
Shared memory is the most useful communication method between processes and the fastest IPC format. The shared memory of two different processes A and B means that the same physical memory is mapped to the process address space of process a and
To use shared memory, follow these steps:1. Open up a shared memory shmget ()2. allow this process to use a shared memory shmat ()3. Write/read4. prohibit this process from using this shared memory shmdt ()5. Delete this shared memory shmctl () or
The concept of shared memory areas is now extended to include memory areas that are shared between unrelated processes. POSIX provides two ways to share memory areas between unrelated processes :1. Memory mapped file: Opened by the Open function,
Inter-process communication-shared memoryWe are familiar with inter-process communication methods, such as pipelines (named pipelines), signals (signal), shared memory, message queues, sockets (sockets ), semaphores are classified as inter-process
It sounds like shared memory and games are not very much, but using shared memory on game servers is not a new thing, and swimming and pixel in the Dragon Eight and the quest for fairy on the implementation of this application (but not necessarily
I. Introduction to the IPC (inter-process communication, interprocess communication) object The IPC objects for System V have shared memory, message queues, and semaphores.Note: In the IPC communication mode, each IPC object has a unique name,
An IPC communication framework based on shared memoryThe operations associated with shared memory mainly include the initialization of shared memory, the release of shared memory, the associated operation of shared memory locks, and the environment
A. Shared memoryIn the system, two different processes will maintain their own piece of address space, this address space is generally a virtual address, will be mapped through the MMU and page table to the corresponding physical memory, because
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.