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型
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 属性オブジェクトを渡すことで
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"
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 属性オブジェクトを破壊する。
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"
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.
141 .BR "pthread_mutex_lock" (3)
142 ですでに保持している mutex をロックしようとしたときに、
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)
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"
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"
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"
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"
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.
296 .BR "pthread_mutex_lock" (3)
297 ですでに保持している mutex をロックしようとしたときに、
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)
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"
334 .BI "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr ", int " pshared ");"
338 .B "PTHREAD_PROCESS_PRIVATE"
340 .B "PTHREAD_PROCESS_SHARED"
346 .B "PTHREAD_PROCESS_SHARED"