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  ob‐
15                      ject.  This is analogous to open(2).  The call returns a
16                      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 filesystem
55       On  Linux,  shared  memory  objects are created in a (tmpfs(5)) virtual
56       filesystem, normally mounted  under  /dev/shm.   Since  kernel  2.6.19,
57       Linux  supports  the  use of access control lists (ACLs) to control the
58       permissions of objects in the virtual filesystem.
59

NOTES

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

SEE ALSO

71       fchmod(2), fchown(2), fstat(2), ftruncate(2), memfd_create(2), mmap(2),
72       mprotect(2),  munmap(2),  shmget(2),  shmop(2),  shm_open(3),   shm_un‐
73       link(3), sem_overview(7)
74

COLOPHON

76       This  page  is  part of release 5.12 of the Linux man-pages project.  A
77       description of the project, information about reporting bugs,  and  the
78       latest     version     of     this    page,    can    be    found    at
79       https://www.kernel.org/doc/man-pages/.
80
81
82
83Linux                             2021-03-22                   SHM_OVERVIEW(7)
Impressum