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