OSDN Git Service

(split) LDP: Update release pages based on LDP 3.54 release
[linuxjm/LDP_man-pages.git] / release / man3 / pthread_setcancelstate.3
index f1179b7..09c15d1 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
 .\"     <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\"*******************************************************************
 .\"
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
+.\"
+.\" Japanese Version Copyright (c) 2012  Akihiro MOTOKI
+.\"         all rights reserved.
+.\" Translated 2012-05-31, Akihiro MOTOKI <amotoki@gmail.com>
+.\"
 .TH PTHREAD_SETCANCELSTATE 3 2008\-11\-24 Linux "Linux Programmer's Manual"
 .SH 名前
 pthread_setcancelstate, pthread_setcanceltype \- cancelability state と
-type を設定する
+cancelability type を設定する
 .SH 書式
 .nf
 \fB#include <pthread.h>\fP
@@ -41,15 +48,15 @@ type を設定する
 .fi
 .SH 説明
 \fBpthread_setcancelstate\fP() は、呼び出したスレッドの
-cancelability state に \fIstate\fP で指定された値を設定する。
-変更前のスレッドの cancelability state は
+cancelability state に \fIstate\fP で指定された
\80¤ã\82\92設å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´å\89\8dã\81®ã\82¹ã\83¬ã\83\83ã\83\89ã\81® cancelability state ã\81¯
 \fIoldstate\fP が指すバッファで返される。
 \fIstate\fP 引き数には以下の値のいずれか一つを指定しなければならない。
 .TP 
 \fBPTHREAD_CANCEL_ENABLE\fP
 スレッドは取り消し可能 (cancelable) である。
-これが全ての新しく作成されるスレッドでのデフォルトの cancelability
-state である。これには最初のスレッドも含まれる。
+これが全ての新しく作成されるスレッドでのデフォルトの
+cancelability state である。これには最初のスレッドも含まれる。
 スレッドの cancelability type により、取り消し可能なスレッドが
 取り消し要求にいつ反応するかが決まる。
 .TP 
@@ -66,15 +73,16 @@ cancelability type に \fItype\fP で指定された値を設定する。
 \fBPTHREAD_CANCEL_DEFERRED\fP
 そのスレッドが次に取り消しポイント (cancellation point) の関数を
 呼び出すまで取り消し要求が遅延される。これが全ての新しく作成される
-スレッドでのデフォルトの cancellation type である。
+スレッドでのデフォルトの cancelability type である。
 これには最初のスレッドも含まれる。
 .TP 
 \fBPTHREAD_CANCEL_ASYNCHRONOUS\fP
 スレッドはいつでも取り消すことができる (通常はすぐにキャンセルされるが、
 システムがそのことを保証しているわけではない)。
 .PP
-The set\-and\-get operation performed by each of these functions is atomic
-with respect to other threads in the process calling the same function.
+これらの関数により実行される「設定と取得」操作 (set\-and\-get operation) は、
+同じ関数を呼び出したプロセス内の他のスレッドがあっても、
+アトミックに行われる。
 .SH 返り値
 成功すると、これらの関数は 0 を返す。
 エラーの場合、0 以外のエラー番号を返す。
@@ -96,45 +104,49 @@ POSIX.1\-2001.
 スレッドが取り消された場合に何が起こるかの詳細については
 \fBpthread_cancel\fP(3) を参照。
 
-Briefly disabling cancelability is useful if a thread performs some critical
-action that must not be interrupted by a cancellation request.  Beware of
-disabling cancelability for long periods, or around operations that may
-block for long periods, since that will render the thread unresponsive to
-cancellation requests.
+取り消し要求により中断されてはならない重要なアクションをスレッドが
+実行する場合、短い時間だけ cancelability を無効にするのは有用である。
+長い時間 cancelability を無効にしたり、長い時間停止 (block) される
+可能性のある操作の前後で cancelability を無効にしたりする際には
+注意すること。なぜなら、無効にしてしまうと、キャンセル要求に対して
+スレッドが応答しない状態になってしまうからである。
 
-Setting the cancelability type to \fBPTHREAD_CANCEL_ASYNCHRONOUS\fP is rarely
-useful.  Since the thread could be canceled at \fIany\fP time, it cannot safely
-reserve resources (e.g., allocating memory with \fBmalloc\fP(3)), acquire
-mutexes, semaphores, or locks, and so on.  Reserving resources is unsafe
-because the application has no way of knowing what the state of these
-resources is when the thread is canceled; that is, did cancellation occur
-before the resources were reserved, while they were reserved, or after they
-were released? Furthermore, some internal data structures (e.g., the linked
-list of free blocks managed by the \fBmalloc\fP(3)  family of functions) may be
-left in an inconsistent state if cancellation occurs in the middle of the
-function call.  Consequently, clean\-up handlers cease to be useful.
-Functions that can be safely asynchronously canceled are called
-\fIasync\-cancel\-safe functions\fP.  POSIX.1\-2001 only requires that
-\fBpthread_cancel\fP(3), \fBpthread_setcancelstate\fP(), and
-\fBpthread_setcanceltype\fP()  be async\-cancel\-safe.  In general, other library
-functions can't be safely called from an asynchronously cancelable thread.
-One of the few circumstances in which asynchronous cancelability is useful
-is for cancellation of a thread that is in a pure compute\-bound loop.
+cancelability type を \fBPTHREAD_CANCEL_ASYNCHRONOUS\fP に設定して役に立つ
+ことはめったにない。スレッドは\fIいつでも\fPキャンセルすることができること
+になるので、スレッドが安全にリソースの確保 (例えば \fBmalloc\fP(3) で
+メモリを割り当てる) や mutex、セマフォ、ロックなどの獲得を行うことがで
+きない。アプリケーションは、スレッドがキャンセルされる際に、これらのリ
+ソースがどのような状態にあるかを知る術はないので、リソースの確保が安全
+ではなくなる。つまり、キャンセルが起こったのが、リソースの確保前なのか、
+確保中なのか、確保後なのかが分からない。さらに、関数呼び出しの最中に
+キャンセルが発生すると、いくつかの内部データ構造 (例えば、\fBmalloc\fP(3)
+関連の関数が管理している未使用ブロックのリンクリスト) が一貫性のない
+状態のままになってしまう可能性がある。その結果、クリーンアップハンドラ
+が役に立たないものになってしまう。
+非同期で安全にキャンセルできる関数は \fIasync\-cancel\-safe functions\fP と
+呼ばれる。 POSIX.1\-2001 で、非同期で安全にキャンセルできるように求めら
+れている関数は \fBpthread_cancel\fP(3), \fBpthread_setcancelstate\fP(),
+\fBpthread_setcanceltype\fP() だけである。一般的には、それ以外のライブラリ
+関数は、非同期にキャンセルできるスレッドから安全に呼び出すことはできな
+い。非同期でのキャンセルが有効な数少ない状況としては、純粋に計算だけを
+行うループに入っているスレッドをキャンセルするといった場面がある。
 
 .\" It looks like at least Solaris, FreeBSD and Tru64 support this.
-The Linux threading implementations permit the \fIoldstate\fP argument of
-\fBpthread_setcancelstate\fP()  to be NULL, in which case the information about
-the previous cancelability state is not returned to the caller.  Many other
-implementations also permit a NULL \fIoldstat\fP argument, but POSIX.1\-2001
-does not specify this point, so portable applications should always specify
-a non\-NULL value in \fIoldstate\fP.  A precisely analogous set of statements
-applies for the \fIoldtype\fP argument of \fBpthread_setcanceltype\fP().
+Linux のスレッド実装では、 \fBpthread_setcancelstate\fP() の \fIoldstate\fP
+引き数に NULL を指定することを認めている。 NULL が指定された場合、
+変更前の cancelability state の情報が呼び出し側に返されない。
+他の多くの実装でも \fIoldstate\fP 引き数に NULL を指定することを認めて
+いるが、 POSIX.1\-2001 ではこの点については規定されていない。
+したがって、移植性が必要なアプリケーションでは常に \fIoldstate\fP に
+NULL 以外の値を指定するようにすべきである。
+\fBpthread_setcanceltype\fP() の \fIoldtype\fP 引き数についても、
+全く同じことが言える。
 .SH 例
 \fBpthread_cancel\fP(3) を参照。
 .SH 関連項目
 \fBpthread_cancel\fP(3), \fBpthread_cleanup_push\fP(3), \fBpthread_testcancel\fP(3),
 \fBpthreads\fP(7)
 .SH この文書について
-この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
 である。プロジェクトの説明とバグ報告に関する情報は
 http://www.kernel.org/doc/man\-pages/ に書かれている。