OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / glibc-linuxthreads / draft / man3 / pthread_mutexattr_init.3
1 .\"   Copyright (C) 1996-1999 Free Software Foundation, Inc.
2 .\"
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.
6 .\"
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.
11 .\"
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.
16 .\"
17 .\" Copyright (C) 1996 Xavier Leroy.
18 .\"
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.
23 .\"
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               時刻情報つき
30 .\"
31 .\"
32 .TH PTHREAD_MUTEXATTR 3 LinuxThreads
33
34
35 .\"O .SH NAME
36 .SH "名前"
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 
40 \- mutex 作成時の属性
41
42 .\"O .SH SYNOPSIS
43 .SH "書式"
44 .B #include <pthread.h>
45
46 .BI "int pthread_mutexattr_init(pthread_mutexattr_t *" attr ");"
47
48 .BI "int pthread_mutexattr_destroy(pthread_mutexattr_t *" attr ");"
49
50 .BI "int pthread_mutexattr_settype(pthread_mutexattr_t *" attr ", int " kind ");"
51
52 .BI "int pthread_mutexattr_gettype(const pthread_mutexattr_t *" attr ", int *" kind ");"
53
54 .\"O .SH DESCRIPTION
55 .SH "説明"
56
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).
60 .\"O Passing 
61 .\"O .B "NULL"
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 指定することができる。
68 .B "NULL"
69 を渡すことは、すべての属性がデフォルト値に
70 設定された mutex 属性オブジェクトを渡すことと同等である。
71
72 .\"O .B "pthread_mutexattr_init"
73 .\"O initializes the mutex attribute object 
74 .\"O .I "attr"
75 .\"O and fills it with default values for the attributes.
76 .B "pthread_mutexattr_init"
77 は mutex 属性オブジェクト
78 .I "attr"
79 を初期化し、すべての属性をデフォルトの値に設定する。
80
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 の実装では何もしない。
92
93 .\"O LinuxThreads supports only one mutex attribute: the mutex kind, which
94 .\"O is either 
95 .\"O .B "PTHREAD_MUTEX_FAST_NP"
96 .\"O for ``fast'' mutexes,
97 .\"O .B "PTHREAD_MUTEX_RECURSIVE_NP"
98 .\"O for ``recursive'' mutexes,
99 .\"O or 
100 .\"O .B "PTHREAD_MUTEX_ERRORCHECK_NP"
101 .\"O for ``error checking'' mutexes.
102 .\"O As the 
103 .\"O .B "NP"
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 のいずれかの値をとる。
115 .B "NP"
116 という接尾辞が示すように、
117 これは POSIX 標準に対するポータブルでない拡張で、
118 ポータブルなプログラムでは用いるべきでない。
119
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
130 .\"O .BR "EDEADLK" .
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.
139 mutex 種別は、
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)
149 はエラーコード
150 .B "EDEADLK"
151 とともに直ちに返る。
152 mutex が「再帰的な (recursive) 」という種別の場合、
153 .BR "pthread_mutex_lock" (3)
154 の呼び出しは成功の返り値とともに直ちに返る。
155 mutex を保持しているスレッドが何回ロックしたかがその mutex に記録される。
156 保持しているスレッドがロック解除状態に戻るためには、
157 同じ回数だけ
158 .BR "pthread_mutex_unlock" (3)
159 を呼び出さなければならない。
160
161 .\"O The default mutex kind is ``fast'', that is, 
162 .\"O .BR "PTHREAD_MUTEX_FAST_NP" .
163 デフォルトの mutex 種別は「速い (fast) 」、
164 すなわち
165 .B "PTHREAD_MUTEX_FAST_NP"
166 である。
167
168 .\"O .B "pthread_mutexattr_settype"
169 .\"O sets the mutex kind attribute in 
170 .\"O .I "attr"
171 .\"O to the value specified by 
172 .\"O .IR "kind" .
173 .B "pthread_mutexattr_settype"
174
175 .I "attr"
176 の mutex 種別を表す属性を
177 .I "kind"
178 で示される値に設定する。
179
180 .\"O .B "pthread_mutexattr_gettype"
181 .\"O retrieves the current value of the
182 .\"O mutex kind attribute in 
183 .\"O .I "attr"
184 .\"O and stores it in the location pointed
185 .\"O to by 
186 .\"O .IR "kind" .
187 .B "pthread_mutexattr_gettype"
188
189 .I "attr"
190 の mutex 種別を表す属性を取得し、
191 .I "kind"
192 で指し示される領域に格納する。
193
194 .\"O .SH "RETURN VALUE"
195 .\"O .BR "pthread_mutexattr_init" ,
196 .\"O .B "pthread_mutexattr_destroy"
197 .\"O and
198 .\"O .B "pthread_mutexattr_gettype"
199 .\"O always return 0.
200 .SH "返り値"
201 .B "pthread_mutexattr_init"
202 および
203 .B "pthread_mutexattr_destroy"
204
205 .B "pthread_mutexattr_gettype"
206 は常に 0 を返す。
207
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 のエラーコードを返す。
213
214 .\"O .SH ERRORS
215 .SH "エラー"
216
217 .\"O On error, 
218 .\"O .B "pthread_mutexattr_settype"
219 .\"O returns the following error code:
220 .\"O .TP
221 .\"O .B "EINVAL"
222 .\"O .I "kind"
223 .\"O is neither 
224 .\"O .B "PTHREAD_MUTEX_FAST_NP"
225 .\"O nor 
226 .\"O .B "PTHREAD_MUTEX_RECURSIVE_NP"
227 .\"O nor 
228 .\"O .B "PTHREAD_MUTEX_ERRORCHECK_NP"
229 エラーのとき、
230 .B "pthread_mutexattr_settype"
231 は次のようなエラーコードを返す:
232 .TP
233 .B "EINVAL"
234 .I "kind"
235
236 .B "PTHREAD_MUTEX_FAST_NP"
237 および
238 .B "PTHREAD_MUTEX_RECURSIVE_NP"
239
240 .B "PTHREAD_MUTEX_ERRORCHECK_NP"
241 のいずれでもない。
242
243 .\"O .SH AUTHOR
244 .SH "著者"
245 Xavier Leroy <Xavier.Leroy@inria.fr>
246
247 .\"O .SH "SEE ALSO"
248 .SH "関連項目"
249 .BR "pthread_mutex_init" (3),
250 .BR "pthread_mutex_lock" (3),
251 .BR "pthread_mutex_unlock" (3).
252
253
254 [訳注1] glibc-linuxthreads の最新のドキュメントは Texinfo 形式で提供されている。
255 上の記述は glibc-linuxthreads-2.2 以降では正しくない。
256 以下は glibc-linuxthreads-2.3.1 の Texinfo ファイルからの引用である。
257 種別 (kind) が型 (type) に変更されている。
258
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 のいずれかの値をとる。
278 .B "NP"
279 という接尾辞が示すように、
280 これは POSIX 標準に対するポータブルでない拡張で、
281 ポータブルなプログラムでは用いるべきでない。
282
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.
294 mutex 型は、
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)
304 はエラーコード
305 .B "EDEADLK"
306 とともに直ちに返る。
307 mutex が「再帰的な (recursive) 」という型の場合、
308 .BR "pthread_mutex_lock" (3)
309 の呼び出しは成功の返り値とともに直ちに返る。
310 mutex を保持しているスレッドが何回ロックしたかがその mutex に記録される。
311 保持しているスレッドがロック解除状態に戻るためには、
312 同じ回数だけ
313 .BR "pthread_mutex_unlock" (3)
314 を呼び出さなければならない。
315
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) 」、
319 すなわち
320 .B "PTHREAD_MUTEX_TIMED_NP"
321 である。
322
323
324 [訳注2] LinuxThreads では mutex をプロセス間で共有することはできない。
325 glibc-linuxthreads-2.2 以降、次の 2 つの関数が追加されている。
326
327 .BI "int pthread_mutexattr_getpshared(const pthread_mutexattr_t *" attr ", int *" pshared ");"
328
329 .I "pshared"
330 で指し示される領域に
331 .B "PTHREAD_PROCESS_PRIVATE"
332 を格納し、常に 0 を返す。
333
334 .BI "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr ", int " pshared ");"
335
336 .I "pshared"
337
338 .B "PTHREAD_PROCESS_PRIVATE"
339 および
340 .B "PTHREAD_PROCESS_SHARED"
341 のいずれでもない場合、
342 .B "EINVAL"
343 を返す。
344 .I "pshared"
345
346 .B "PTHREAD_PROCESS_SHARED"
347 の場合、
348 .B "ENOSYS"
349 を返す。
350 それ以外の場合、 0 を返す。