Linux inter-process communication (IPC) programming practices (8) use of shared memory-POSIX shared memory (API)
1. Posix provides two methods to share memory areas between unrelated processes:
(1) memory ing file: open the function first, and then
Introduction: System v Shared Memory and shared file mappings allow unrelated processes to share memory areas for IPC communication. But there are some drawbacks to these two technologies: 1. The System V Shared memory model uses keys and
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.
The previous section introduced the knowledge about System V shared memory. Now let's take a look at POSIX shared memory and functions.
Shared Memory is simply a real physical memory area. Some functions can be used to map this area to the address
Document directory
Standard (ansi c, POSIX, svid, xpg ,...)
Online Documentation (man, info, how-,...)
Storage location of library and header files
Standard (ansi c, POSIX, svid, xpg ,...)
Ansi c: This is the C language standard set by ANSI
1. Create/acquire a shared memory#include #include / * for Mode constants */#include / * for O_* Constants */int Shm_open (const char *name, int oflag, mode_t mode);Parameters:Name: Shared memory names; Oflag: With the Open
POSIX shared memory has two ways of sharing memory between non-affinity processes:1). Use a memory-mapped file, opened by the Open function, and the MMAP function maps the returned file descriptor to a file in the current process space.2). Using the
Reprint Please specify the Source: http://blog.csdn.net/suool/article/details/38515863shared memory can be described as a mapping of an area ( segment) of memory that can be shared by more processes. This is the fastest form of the IPC mechanism
IPC (inter-process communication, interprocess communication) can have three ways of sharing information (along with the file system, with the kernel, with shared memory). (Of course, although it is interprocess communication, it can also be
The Unified Call uses MMAP () to map a common file to implement shared memory. System V maps files in the SHM of a special file system to implement shared memory communication between processes. That is to say, each shared memory area corresponds to
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.