OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man7 / shm_overview.7
1 '\" t
2 .\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .TH SHM_OVERVIEW 7 2010-09-10 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 shm_overview \- overview of POSIX shared memory
30 .SH DESCRIPTION
31 The POSIX shared memory API allows processes to communicate information
32 by sharing a region of memory.
33
34 The interfaces employed in the API are:
35 .TP 15
36 .BR shm_open (3)
37 Create and open a new object, or open an existing object.
38 This is analogous to
39 .BR open (2).
40 The call returns a file descriptor for use by the other
41 interfaces listed below.
42 .TP
43 .BR ftruncate (2)
44 Set the size of the shared memory object.
45 (A newly created shared memory object has a length of zero.)
46 .TP
47 .BR mmap (2)
48 Map the shared memory object into the virtual address space
49 of the calling process.
50 .TP
51 .BR munmap (2)
52 Unmap the shared memory object from the virtual address space
53 of the calling process.
54 .TP
55 .BR shm_unlink (3)
56 Remove a shared memory object name.
57 .TP
58 .BR close (2)
59 Close the file descriptor allocated by
60 .BR shm_open (3)
61 when it is no longer needed.
62 .TP
63 .BR fstat (2)
64 Obtain a
65 .I stat
66 structure that describes the shared memory object.
67 Among the information returned by this call are the object's
68 size
69 .RI ( st_size ),
70 permissions
71 .RI ( st_mode ),
72 owner
73 .RI ( st_uid ),
74 and group
75 .RI ( st_gid ).
76 .TP
77 .BR fchown (2)
78 To change the ownership of a shared memory object.
79 .TP
80 .BR fchmod (2)
81 To change the permissions of a shared memory object.
82 .SS Versions
83 POSIX shared memory is supported since Linux 2.4 and glibc 2.2.
84 .SS Persistence
85 POSIX shared memory objects have kernel persistence:
86 a shared memory object will exist until the system is shut down,
87 or until all processes have unmapped the object and it has been deleted with
88 .BR shm_unlink (3)
89 .SS Linking
90 Programs using the POSIX shared memory API must be compiled with
91 .I cc \-lrt
92 to link against the real-time library,
93 .IR librt .
94 .SS Accessing shared memory objects via the filesystem
95 On Linux, shared memory objects are created in a
96 .RI ( tmpfs )
97 virtual filesystem, normally mounted under
98 .IR /dev/shm .
99 Since kernel 2.6.19, Linux supports the use of access control lists (ACLs)
100 to control the permissions of objects in the virtual filesystem.
101 .SH CONFORMING TO
102 POSIX.1-2001.
103 .SH NOTES
104 Typically, processes must synchronize their access to a shared
105 memory object, using, for example, POSIX semaphores.
106
107 System V shared memory
108 .RB ( shmget (2),
109 .BR shmop (2),
110 etc.) is an older shared memory API.
111 POSIX shared memory provides a simpler, and better designed interface;
112 on the other hand POSIX shared memory is somewhat less widely available
113 (especially on older systems) than System V shared memory.
114 .SH SEE ALSO
115 .BR fchmod (2),
116 .BR fchown (2),
117 .BR fstat (2),
118 .BR ftruncate (2),
119 .BR mmap (2),
120 .BR mprotect (2),
121 .BR munmap (2),
122 .BR shmget (2),
123 .BR shmop (2),
124 .BR shm_open (3),
125 .BR shm_unlink (3),
126 .BR sem_overview (7)
127 .SH COLOPHON
128 This page is part of release 3.79 of the Linux
129 .I man-pages
130 project.
131 A description of the project,
132 information about reporting bugs,
133 and the latest version of this page,
134 can be found at
135 \%http://www.kernel.org/doc/man\-pages/.