OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man7 / shm_overview.7
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
5 .\" <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .TH SHM_OVERVIEW 7 2008-06-25 "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 file system
95 On Linux, shared memory objects are created in a
96 .RI ( tmpfs )
97 virtual file system, 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 file system.
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 semaphore 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)