1 .\" Copyright (C) 1996-1999 Free Software Foundation, Inc.
3 .\" Permission is granted to make and distribute verbatim copies of
4 .\" this manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of
8 .\" this manual under the conditions for verbatim copying, provided that
9 .\" the entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Permission is granted to copy and distribute translations of this
13 .\" manual into another language, under the above conditions for modified
14 .\" versions, except that this permission notice may be stated in a
15 .\" translation approved by the Foundation.
17 .\" Copyright (C) 1996 Xavier Leroy.
19 .\" Japanese Version Copyright (C) 2002-2003 Suzuki Takashi
20 .\" all rights reserved.
21 .\" Translated Sat Jan 4 14:23:32 JST 2003
22 .\" by Suzuki Takashi.
24 .\"WORD: mutex creation attribute mutexºîÀ®»þ¤Î°À
25 .\"WORD: mutex attribute object mutex°À¥ª¥Ö¥¸¥§¥¯¥È
26 .\"WORD: mutex kind mutex¼ïÊÌ
27 .\"WORD: mutex kind attribute mutex¼ïÊ̤òɽ¤¹Â°À
28 .\"WORD: mutex type mutex·¿
29 .\"WORD: timed »þ¹ï¾ðÊó¤Ä¤
32 .TH PTHREAD_MUTEXATTR 3 LinuxThreads
37 .\"O pthread_mutexattr_init, pthread_mutexattr_destroy, pthread_mutexattr_settype, pthread_mutexattr_gettype
38 .\"O \- mutex creation attributes
39 pthread_mutexattr_init, pthread_mutexattr_destroy, pthread_mutexattr_settype, pthread_mutexattr_gettype
44 .B #include <pthread.h>
46 .BI "int pthread_mutexattr_init(pthread_mutexattr_t *" attr ");"
48 .BI "int pthread_mutexattr_destroy(pthread_mutexattr_t *" attr ");"
50 .BI "int pthread_mutexattr_settype(pthread_mutexattr_t *" attr ", int " kind ");"
52 .BI "int pthread_mutexattr_gettype(const pthread_mutexattr_t *" attr ", int *" kind ");"
57 .\"O Mutex attributes can be specified at mutex creation time, by passing a
58 .\"O mutex attribute object as second argument to
59 .\"O .BR "pthread_mutex_init" (3).
62 .\"O is equivalent to passing a mutex attribute object with
63 .\"O all attributes set to their default values.
64 mutex ¤Î°À¤Ï mutex ºîÀ®»þ¤Ë¡¢
65 .BR "pthread_mutex_init" (3)
66 ¤ÎÂè 2 °ú¿ô¤È¤·¤Æ mutex °À¥ª¥Ö¥¸¥§¥¯¥È¤òÅϤ¹¤³¤È¤Ç
67 »ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
69 ¤òÅϤ¹¤³¤È¤Ï¡¢¤¹¤Ù¤Æ¤Î°À¤¬¥Ç¥Õ¥©¥ë¥ÈÃͤË
70 ÀßÄꤵ¤ì¤¿ mutex °À¥ª¥Ö¥¸¥§¥¯¥È¤òÅϤ¹¤³¤È¤ÈƱÅù¤Ç¤¢¤ë¡£
72 .\"O .B "pthread_mutexattr_init"
73 .\"O initializes the mutex attribute object
75 .\"O and fills it with default values for the attributes.
76 .B "pthread_mutexattr_init"
77 ¤Ï mutex °À¥ª¥Ö¥¸¥§¥¯¥È
79 ¤ò½é´ü²½¤·¡¢¤¹¤Ù¤Æ¤Î°À¤ò¥Ç¥Õ¥©¥ë¥È¤ÎÃͤËÀßÄꤹ¤ë¡£
81 .\"O .B "pthread_mutexattr_destroy"
82 .\"O destroys a mutex attribute object, which
83 .\"O must not be reused until it is reinitialized.
84 .\"O .B "pthread_mutexattr_destroy"
85 .\"O does nothing in the LinuxThreads implementation.
86 .B "pthread_mutexattr_destroy"
87 ¤Ï mutex °À¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë¡£
88 Ç˲õ¤µ¤ì¤¿ mutex °À¥ª¥Ö¥¸¥§¥¯¥È¤Ï
89 ºÆ¤Ó½é´ü²½¤µ¤ì¤ë¤Þ¤ÇºÆ»ÈÍѤ·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
90 .B "pthread_mutexattr_destroy"
91 ¤Ï LinuxThreads ¤Î¼ÂÁõ¤Ç¤Ï²¿¤â¤·¤Ê¤¤¡£
93 .\"O LinuxThreads supports only one mutex attribute: the mutex kind, which
95 .\"O .B "PTHREAD_MUTEX_FAST_NP"
96 .\"O for ``fast'' mutexes,
97 .\"O .B "PTHREAD_MUTEX_RECURSIVE_NP"
98 .\"O for ``recursive'' mutexes,
100 .\"O .B "PTHREAD_MUTEX_ERRORCHECK_NP"
101 .\"O for ``error checking'' mutexes.
104 .\"O suffix indicates, this is a non-portable extension to the
105 .\"O POSIX standard and should not be employed in portable programs.
106 LinuxThreads ¤Ï¤¿¤À 1 ¤Ä¤Î mutex °À¤ËÂбþ¤·¤Æ¤¤¤ë¡£
107 ¤½¤ì¤Ï mutex ¼ïÊÌ (mutex kind) ¤Ç¡¢
108 ¡Ö®¤¤ (fast) ¡× mutex ¤òɽ¤¹
109 .B "PTHREAD_MUTEX_FAST_NP"
110 ¤«¡¢¡ÖºÆµ¢Åª¤Ê (recursive) ¡× mutex ¤òɽ¤¹
111 .B "PTHREAD_MUTEX_RECURSIVE_NP"
112 ¡¢¡Ö¥¨¥é¡¼¸¡ºº¤ò¹Ô¤Ê¤¦ (error checking) ¡× mutex ¤òɽ¤¹
113 .B "PTHREAD_MUTEX_ERRORCHECK_NP"
114 ¤Î¤¤¤º¤ì¤«¤ÎÃͤò¤È¤ë¡£
116 ¤È¤¤¤¦ÀÜÈø¼¤¬¼¨¤¹¤è¤¦¤Ë¡¢
117 ¤³¤ì¤Ï POSIX ɸ½à¤ËÂФ¹¤ë¥Ý¡¼¥¿¥Ö¥ë¤Ç¤Ê¤¤³ÈÄ¥¤Ç¡¢
118 ¥Ý¡¼¥¿¥Ö¥ë¤Ê¥×¥í¥°¥é¥à¤Ç¤ÏÍѤ¤¤ë¤Ù¤¤Ç¤Ê¤¤¡£
120 .\"O The mutex kind determines what happens if a thread attempts to lock a
121 .\"O mutex it already owns with
122 .\"O .BR "pthread_mutex_lock" (3).
123 .\"O If the mutex is of
124 .\"O the ``fast'' kind,
125 .\"O .BR "pthread_mutex_lock" (3)
126 .\"O simply suspends the calling
127 .\"O thread forever. If the mutex is of the ``error checking'' kind,
128 .\"O .BR "pthread_mutex_lock" (3)
129 .\"O returns immediately with the error code
131 .\"O If the mutex is of the ``recursive'' kind, the call to
132 .\"O .BR "pthread_mutex_lock" (3)
133 .\"O returns immediately with a success return
134 .\"O code. The number of times the thread owning the mutex has locked it is
135 .\"O recorded in the mutex. The owning thread must call
136 .\"O .BR "pthread_mutex_unlock" (3)
137 .\"O the same number of times before the mutex
138 .\"O returns to the unlocked state.
140 ¤¢¤ë¥¹¥ì¥Ã¥É¤¬¼«Ê¬¼«¿È¤Ç
141 .BR "pthread_mutex_lock" (3)
142 ¤Ç¤¹¤Ç¤ËÊÝ»ý¤·¤Æ¤¤¤ë mutex ¤ò¥í¥Ã¥¯¤·¤è¤¦¤È¤·¤¿¤È¤¤Ë¡¢
143 ²¿¤¬µ¯¤³¤ë¤«¤ò·èÄꤹ¤ë¡£
144 mutex ¤¬¡Ö®¤¤ (fast) ¡×¤È¤¤¤¦¼ïÊ̤ξì¹ç¡¢
145 .BR "pthread_mutex_lock" (3)
146 ¤Ïñ¤Ë¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤ò±Ê±ó¤ËÄä»ß¤µ¤»¤ë¡£
147 mutex ¤¬¡Ö¥¨¥é¡¼¸¡ºº¤ò¹Ô¤Ê¤¦ (error checking) ¡×¤È¤¤¤¦¼ïÊ̤ξì¹ç¡¢
148 .BR "pthread_mutex_lock" (3)
152 mutex ¤¬¡ÖºÆµ¢Åª¤Ê (recursive) ¡×¤È¤¤¤¦¼ïÊ̤ξì¹ç¡¢
153 .BR "pthread_mutex_lock" (3)
154 ¤Î¸Æ¤Ó½Ð¤·¤ÏÀ®¸ù¤ÎÊÖ¤êÃͤȤȤâ¤Ëľ¤Á¤ËÊ֤롣
155 mutex ¤òÊÝ»ý¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤¬²¿²ó¥í¥Ã¥¯¤·¤¿¤«¤¬¤½¤Î mutex ¤ËµÏ¿¤µ¤ì¤ë¡£
156 ÊÝ»ý¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤¬¥í¥Ã¥¯²ò½ü¾õÂÖ¤ËÌá¤ë¤¿¤á¤Ë¤Ï¡¢
158 .BR "pthread_mutex_unlock" (3)
159 ¤ò¸Æ¤Ó½Ð¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
161 .\"O The default mutex kind is ``fast'', that is,
162 .\"O .BR "PTHREAD_MUTEX_FAST_NP" .
163 ¥Ç¥Õ¥©¥ë¥È¤Î mutex ¼ïÊ̤ϡÖ®¤¤ (fast) ¡×¡¢
165 .B "PTHREAD_MUTEX_FAST_NP"
168 .\"O .B "pthread_mutexattr_settype"
169 .\"O sets the mutex kind attribute in
171 .\"O to the value specified by
173 .B "pthread_mutexattr_settype"
176 ¤Î mutex ¼ïÊ̤òɽ¤¹Â°À¤ò
178 ¤Ç¼¨¤µ¤ì¤ëÃͤËÀßÄꤹ¤ë¡£
180 .\"O .B "pthread_mutexattr_gettype"
181 .\"O retrieves the current value of the
182 .\"O mutex kind attribute in
184 .\"O and stores it in the location pointed
187 .B "pthread_mutexattr_gettype"
190 ¤Î mutex ¼ïÊ̤òɽ¤¹Â°À¤ò¼èÆÀ¤·¡¢
192 ¤Ç»Ø¤·¼¨¤µ¤ì¤ëÎΰè¤Ë³ÊǼ¤¹¤ë¡£
194 .\"O .SH "RETURN VALUE"
195 .\"O .BR "pthread_mutexattr_init" ,
196 .\"O .B "pthread_mutexattr_destroy"
198 .\"O .B "pthread_mutexattr_gettype"
199 .\"O always return 0.
201 .B "pthread_mutexattr_init"
203 .B "pthread_mutexattr_destroy"
205 .B "pthread_mutexattr_gettype"
208 .\"O .B "pthread_mutexattr_settype"
209 .\"O returns 0 on success and a non-zero
210 .\"O error code on error.
211 .B "pthread_mutexattr_settype"
212 ¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤ò¡¢¥¨¥é¡¼¤Î¾ì¹çÈó 0 ¤Î¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹¡£
218 .\"O .B "pthread_mutexattr_settype"
219 .\"O returns the following error code:
224 .\"O .B "PTHREAD_MUTEX_FAST_NP"
226 .\"O .B "PTHREAD_MUTEX_RECURSIVE_NP"
228 .\"O .B "PTHREAD_MUTEX_ERRORCHECK_NP"
230 .B "pthread_mutexattr_settype"
231 ¤Ï¼¡¤Î¤è¤¦¤Ê¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹:
236 .B "PTHREAD_MUTEX_FAST_NP"
238 .B "PTHREAD_MUTEX_RECURSIVE_NP"
240 .B "PTHREAD_MUTEX_ERRORCHECK_NP"
245 Xavier Leroy <Xavier.Leroy@inria.fr>
249 .BR "pthread_mutex_init" (3),
250 .BR "pthread_mutex_lock" (3),
251 .BR "pthread_mutex_unlock" (3).
254 [ÌõÃí1] glibc-linuxthreads ¤ÎºÇ¿·¤Î¥É¥¥å¥á¥ó¥È¤Ï Texinfo ·Á¼°¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
255 ¾å¤Îµ½Ò¤Ï glibc-linuxthreads-2.2 °Ê¹ß¤Ç¤ÏÀµ¤·¤¯¤Ê¤¤¡£
256 °Ê²¼¤Ï glibc-linuxthreads-2.3.1 ¤Î Texinfo ¥Õ¥¡¥¤¥ë¤«¤é¤Î°úÍѤǤ¢¤ë¡£
257 ¼ïÊÌ (kind) ¤¬·¿ (type) ¤ËÊѹ¹¤µ¤ì¤Æ¤¤¤ë¡£
259 .\"O ---from glibc-linuxthreads-2.3.1/linuxthreads/linuxthreads.texi
260 .\"O LinuxThreads supports only one mutex attribute: the mutex type, which is
261 .\"O either @code{PTHREAD_MUTEX_ADAPTIVE_NP} for ``fast'' mutexes,
262 .\"O @code{PTHREAD_MUTEX_RECURSIVE_NP} for ``recursive'' mutexes,
263 .\"O @code{PTHREAD_MUTEX_TIMED_NP} for ``timed'' mutexes, or
264 .\"O @code{PTHREAD_MUTEX_ERRORCHECK_NP} for ``error checking'' mutexes. As
265 .\"O the @code{NP} suffix indicates, this is a non-portable extension to the
266 .\"O POSIX standard and should not be employed in portable programs.
267 LinuxThreads ¤Ï¤¿¤À 1 ¤Ä¤Î mutex °À¤ËÂбþ¤·¤Æ¤¤¤ë¡£
268 ¤½¤ì¤Ï mutex ·¿ (mutex type) ¤Ç¡¢
269 ¡Ö®¤¤ (fast) ¡× mutex ¤òɽ¤¹
270 .B "PTHREAD_MUTEX_ADAPTIVE_NP"
271 ¤«¡¢¡ÖºÆµ¢Åª¤Ê (recursive) ¡× mutex ¤òɽ¤¹
272 .B "PTHREAD_MUTEX_RECURSIVE_NP"
273 ¡¢¡Ö»þ¹ï¾ðÊó¤Ä¤ (timed) ¡× mutex ¤òɽ¤¹
274 .B "PTHREAD_MUTEX_TIMED_NP"
275 ¡¢¡Ö¥¨¥é¡¼¸¡ºº¤ò¹Ô¤Ê¤¦ (error checking) ¡× mutex ¤òɽ¤¹
276 .B "PTHREAD_MUTEX_ERRORCHECK_NP"
277 ¤Î¤¤¤º¤ì¤«¤ÎÃͤò¤È¤ë¡£
279 ¤È¤¤¤¦ÀÜÈø¼¤¬¼¨¤¹¤è¤¦¤Ë¡¢
280 ¤³¤ì¤Ï POSIX ɸ½à¤ËÂФ¹¤ë¥Ý¡¼¥¿¥Ö¥ë¤Ç¤Ê¤¤³ÈÄ¥¤Ç¡¢
281 ¥Ý¡¼¥¿¥Ö¥ë¤Ê¥×¥í¥°¥é¥à¤Ç¤ÏÍѤ¤¤ë¤Ù¤¤Ç¤Ê¤¤¡£
283 .\"O The mutex type determines what happens if a thread attempts to lock a
284 .\"O mutex it already owns with @code{pthread_mutex_lock}. If the mutex is of
285 .\"O the ``fast'' type, @code{pthread_mutex_lock} simply suspends the calling
286 .\"O thread forever. If the mutex is of the ``error checking'' type,
287 .\"O @code{pthread_mutex_lock} returns immediately with the error code
288 .\"O @code{EDEADLK}. If the mutex is of the ``recursive'' type, the call to
289 .\"O @code{pthread_mutex_lock} returns immediately with a success return
290 .\"O code. The number of times the thread owning the mutex has locked it is
291 .\"O recorded in the mutex. The owning thread must call
292 .\"O @code{pthread_mutex_unlock} the same number of times before the mutex
293 .\"O returns to the unlocked state.
295 ¤¢¤ë¥¹¥ì¥Ã¥É¤¬¼«Ê¬¼«¿È¤Ç
296 .BR "pthread_mutex_lock" (3)
297 ¤Ç¤¹¤Ç¤ËÊÝ»ý¤·¤Æ¤¤¤ë mutex ¤ò¥í¥Ã¥¯¤·¤è¤¦¤È¤·¤¿¤È¤¤Ë¡¢
298 ²¿¤¬µ¯¤³¤ë¤«¤ò·èÄꤹ¤ë¡£
299 mutex ¤¬¡Ö®¤¤ (fast) ¡×¤È¤¤¤¦·¿¤Î¾ì¹ç¡¢
300 .BR "pthread_mutex_lock" (3)
301 ¤Ïñ¤Ë¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤ò±Ê±ó¤ËÄä»ß¤µ¤»¤ë¡£
302 mutex ¤¬¡Ö¥¨¥é¡¼¸¡ºº¤ò¹Ô¤Ê¤¦ (error checking) ¡×¤È¤¤¤¦·¿¤Î¾ì¹ç¡¢
303 .BR "pthread_mutex_lock" (3)
307 mutex ¤¬¡ÖºÆµ¢Åª¤Ê (recursive) ¡×¤È¤¤¤¦·¿¤Î¾ì¹ç¡¢
308 .BR "pthread_mutex_lock" (3)
309 ¤Î¸Æ¤Ó½Ð¤·¤ÏÀ®¸ù¤ÎÊÖ¤êÃͤȤȤâ¤Ëľ¤Á¤ËÊ֤롣
310 mutex ¤òÊÝ»ý¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤¬²¿²ó¥í¥Ã¥¯¤·¤¿¤«¤¬¤½¤Î mutex ¤ËµÏ¿¤µ¤ì¤ë¡£
311 ÊÝ»ý¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤¬¥í¥Ã¥¯²ò½ü¾õÂÖ¤ËÌá¤ë¤¿¤á¤Ë¤Ï¡¢
313 .BR "pthread_mutex_unlock" (3)
314 ¤ò¸Æ¤Ó½Ð¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
316 .\"OThe default mutex type is ``timed'', that is, @code{PTHREAD_MUTEX_TIMED_NP}.
317 .\"O@c This doesn't describe how a ``timed'' mutex behaves. FIXME
318 ¥Ç¥Õ¥©¥ë¥È¤Î mutex ·¿¤Ï¡Ö»þ¹ï¾ðÊó¤Ä¤ (timed) ¡×¡¢
320 .B "PTHREAD_MUTEX_TIMED_NP"
324 [ÌõÃí2] LinuxThreads ¤Ç¤Ï mutex ¤ò¥×¥í¥»¥¹´Ö¤Ç¶¦Í¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
325 glibc-linuxthreads-2.2 °Ê¹ß¡¢¼¡¤Î 2 ¤Ä¤Î´Ø¿ô¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
327 .BI "int pthread_mutexattr_getpshared(const pthread_mutexattr_t *" attr ", int *" pshared ");"
331 .B "PTHREAD_PROCESS_PRIVATE"
332 ¤ò³ÊǼ¤·¡¢¾ï¤Ë 0 ¤òÊÖ¤¹¡£
334 .BI "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr ", int " pshared ");"
338 .B "PTHREAD_PROCESS_PRIVATE"
340 .B "PTHREAD_PROCESS_SHARED"
341 ¤Î¤¤¤º¤ì¤Ç¤â¤Ê¤¤¾ì¹ç¡¢
346 .B "PTHREAD_PROCESS_SHARED"
350 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢ 0 ¤òÊÖ¤¹¡£