1SHM_OVERVIEW(7)            Linux Programmer's Manual           SHM_OVERVIEW(7)
2
3
4

NAME

6       shm_overview - Overview of POSIX shared memory
7

DESCRIPTION

9       The POSIX shared memory API allows processes to communicate information
10       by sharing a region of memory.
11
12       The interfaces employed in the API are:
13
14       shm_open(3)    Create and open  a  new  object,  or  open  an  existing
15                      object.  This is analogous to open(2).  The call returns
16                      a file descriptor for use by the other interfaces listed
17                      below.
18
19       ftruncate(2)   Set the size of the shared memory object.  (A newly cre‐
20                      ated shared memory object has a length of zero.)
21
22       mmap(2)        Map the shared memory object into  the  virtual  address
23                      space of the calling process.
24
25       munmap(2)      Unmap  the shared memory object from the virtual address
26                      space of the calling process.
27
28       shm_unlink(3)  Remove a shared memory object name.
29
30       close(2)       Close the file descriptor allocated by shm_open(3)  when
31                      it is no longer needed.
32
33       fstat(2)       Obtain a stat structure that describes the shared memory
34                      object.  Among the information returned by this call are
35                      the  object's  size  (st_size),  permissions  (st_mode),
36                      owner (st_uid), and group (st_gid).
37
38       fchown(2)      To change the ownership of a shared memory object.
39
40       fchmod(2)      To change the permissions of a shared memory object.
41
42   Versions
43       POSIX shared memory is supported since Linux 2.4 and glibc 2.2.
44
45   Persistence
46       POSIX shared memory objects have kernel persistence:  a  shared  memory
47       object will exist until the system is shut down, or until all processes
48       have unmapped the object and it has been deleted with shm_unlink(3)
49
50   Linking
51       Programs using the POSIX shared memory API must  be  compiled  with  cc
52       -lrt to link against the real-time library, librt.
53
54   Accessing shared memory objects via the file system
55       On  Linux,  shared memory objects are created in a (tmpfs) virtual file
56       system, normally mounted under /dev/shm.  Since  kernel  2.6.19,  Linux
57       supports  the use of access control lists (ACLs) to control the permis‐
58       sions of objects in the virtual file system.
59

CONFORMING TO

61       POSIX.1-2001.
62

NOTES

64       Typically, processes must synchronize their access to a  shared  memory
65       object, using, for example, POSIX semaphores.
66
67       System  V  shared  memory (shmget(2), shmop(2), etc.) is an older sema‐
68       phore API.  POSIX shared memory provides a simpler, and better designed
69       interface;  on  the  other  hand  POSIX  shared memory is somewhat less
70       widely available (especially on older systems)  than  System  V  shared
71       memory.
72

SEE ALSO

74       fchmod(2),  fchown(2),  fstat(2),  ftruncate(2),  mmap(2), mprotect(2),
75       munmap(2), shmget(2), shmop(2), shm_open(3),  shm_unlink(3),  sem_over‐
76       view(7)
77

COLOPHON

79       This  page  is  part of release 3.22 of the Linux man-pages project.  A
80       description of the project, and information about reporting  bugs,  can
81       be found at http://www.kernel.org/doc/man-pages/.
82
83
84
85Linux                             2008-06-25                   SHM_OVERVIEW(7)
Impressum