]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/shm_overview.7
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man7 / shm_overview.7
CommitLineData
095e0604
MK
1.\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
095e0604 5.\"
4c1c5274 6.TH shm_overview 7 (date) "Linux man-pages (unreleased)"
095e0604 7.SH NAME
f68512e9 8shm_overview \- overview of POSIX shared memory
095e0604
MK
9.SH DESCRIPTION
10The POSIX shared memory API allows processes to communicate information
11by sharing a region of memory.
c6d039a3 12.P
095e0604
MK
13The interfaces employed in the API are:
14.TP 15
15.BR shm_open (3)
16Create and open a new object, or open an existing object.
17This is analogous to
18.BR open (2).
19The call returns a file descriptor for use by the other
20interfaces listed below.
21.TP
22.BR ftruncate (2)
23Set the size of the shared memory object.
24(A newly created shared memory object has a length of zero.)
25.TP
26.BR mmap (2)
27Map the shared memory object into the virtual address space
28of the calling process.
29.TP
30.BR munmap (2)
31Unmap the shared memory object from the virtual address space
32of the calling process.
33.TP
34.BR shm_unlink (3)
35Remove a shared memory object name.
36.TP
37.BR close (2)
38Close the file descriptor allocated by
39.BR shm_open (3)
40when it is no longer needed.
41.TP
42.BR fstat (2)
43Obtain a
44.I stat
45structure that describes the shared memory object.
46Among the information returned by this call are the object's
47size
48.RI ( st_size ),
49permissions
50.RI ( st_mode ),
51owner
52.RI ( st_uid ),
53and group
54.RI ( st_gid ).
55.TP
56.BR fchown (2)
57To change the ownership of a shared memory object.
58.TP
59.BR fchmod (2)
60To change the permissions of a shared memory object.
61.SS Versions
62POSIX shared memory is supported since Linux 2.4 and glibc 2.2.
63.SS Persistence
64POSIX shared memory objects have kernel persistence:
65a shared memory object will exist until the system is shut down,
66or until all processes have unmapped the object and it has been deleted with
67.BR shm_unlink (3)
68.SS Linking
69Programs using the POSIX shared memory API must be compiled with
70.I cc \-lrt
71to link against the real-time library,
72.IR librt .
9ee4a2b6 73.SS Accessing shared memory objects via the filesystem
095e0604 74On Linux, shared memory objects are created in a
c339f054 75.RB ( tmpfs (5))
9ee4a2b6 76virtual filesystem, normally mounted under
095e0604 77.IR /dev/shm .
b324e17d 78Since Linux 2.6.19, Linux supports the use of access control lists (ACLs)
9ee4a2b6 79to control the permissions of objects in the virtual filesystem.
095e0604
MK
80.SH NOTES
81Typically, processes must synchronize their access to a shared
82memory object, using, for example, POSIX semaphores.
c6d039a3 83.P
095e0604
MK
84System V shared memory
85.RB ( shmget (2),
86.BR shmop (2),
fa57b208 87etc.) is an older shared memory API.
095e0604
MK
88POSIX shared memory provides a simpler, and better designed interface;
89on the other hand POSIX shared memory is somewhat less widely available
90(especially on older systems) than System V shared memory.
47297adb 91.SH SEE ALSO
095e0604
MK
92.BR fchmod (2),
93.BR fchown (2),
94.BR fstat (2),
95.BR ftruncate (2),
7a11af70 96.BR memfd_create (2),
095e0604
MK
97.BR mmap (2),
98.BR mprotect (2),
99.BR munmap (2),
100.BR shmget (2),
101.BR shmop (2),
102.BR shm_open (3),
103.BR shm_unlink (3),
104.BR sem_overview (7)