aboutsummaryrefslogtreecommitdiff
path: root/pthreads/manual/pthread_cancel.html
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /pthreads/manual/pthread_cancel.html
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'pthreads/manual/pthread_cancel.html')
-rw-r--r--pthreads/manual/pthread_cancel.html205
1 files changed, 205 insertions, 0 deletions
diff --git a/pthreads/manual/pthread_cancel.html b/pthreads/manual/pthread_cancel.html
new file mode 100644
index 000000000..d9acd7727
--- /dev/null
+++ b/pthreads/manual/pthread_cancel.html
@@ -0,0 +1,205 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
+ <TITLE>PTHREAD_CANCEL(3) manual page</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
+ <META NAME="CREATED" CONTENT="20050504;12090500">
+ <META NAME="CHANGED" CONTENT="20050505;18220000">
+ <!-- manual page source format generated by PolyglotMan v3.2, -->
+ <!-- available at http://polyglotman.sourceforge.net/ -->
+</HEAD>
+<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
+<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
+<P><A HREF="index.html">Reference Index</A></P>
+<P><A HREF="#toc">Table of Contents</A></P>
+<H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
+<P>pthread_cancel, pthread_setcancelstate, pthread_setcanceltype,
+pthread_testcancel - thread cancellation
+</P>
+<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
+<P><B>#include &lt;pthread.h&gt;</B>
+</P>
+<P><B>int pthread_cancel(pthread_t </B><I>thread</I><B>);</B>
+</P>
+<P><B>int pthread_setcancelstate(int </B><I>state</I><B>, int
+*</B><I>oldstate</I><B>);</B>
+</P>
+<P><B>int pthread_setcanceltype(int </B><I>type</I><B>, int
+*</B><I>oldtype</I><B>);</B>
+</P>
+<P><B>void pthread_testcancel(void);</B>
+</P>
+<H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
+<P>Cancellation is the mechanism by which a thread can terminate the
+execution of another thread. More precisely, a thread can send a
+cancellation request to another thread. Depending on its settings,
+the target thread can then either ignore the request, honor it
+immediately, or defer it until it reaches a cancellation point.
+</P>
+<P>When a thread eventually honors a cancellation request, it
+performs as if <B>pthread_exit(PTHREAD_CANCELED)</B> has been called
+at that point: all cleanup handlers are executed in reverse order,
+destructor functions for thread-specific data are called, and finally
+the thread stops executing with the return value <B>PTHREAD_CANCELED</B>.
+See <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> for more
+information.
+</P>
+<P><B>pthread_cancel</B> sends a cancellation request to the thread
+denoted by the <I>thread</I> argument.
+</P>
+<P><B>pthread_setcancelstate</B> changes the cancellation state for
+the calling thread -- that is, whether cancellation requests are
+ignored or not. The <I>state</I> argument is the new cancellation
+state: either <B>PTHREAD_CANCEL_ENABLE</B> to enable cancellation, or
+<B>PTHREAD_CANCEL_DISABLE</B> to disable cancellation (cancellation
+requests are ignored). If <I>oldstate</I> is not <B>NULL</B>, the
+previous cancellation state is stored in the location pointed to by
+<I>oldstate</I>, and can thus be restored later by another call to
+<B>pthread_setcancelstate</B>.
+</P>
+<P><B>pthread_setcanceltype</B> changes the type of responses to
+cancellation requests for the calling thread: asynchronous
+(immediate) or deferred. The <I>type</I> argument is the new
+cancellation type: either <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> to
+cancel the calling thread as soon as the cancellation request is
+received, or <B>PTHREAD_CANCEL_DEFERRED</B> to keep the cancellation
+request pending until the next cancellation point. If <I>oldtype</I>
+is not <B>NULL</B>, the previous cancellation state is stored in the
+location pointed to by <I>oldtype</I>, and can thus be restored later
+by another call to <B>pthread_setcanceltype</B>.
+</P>
+<P><B>Pthreads-w32</B> provides two levels of support for
+<B>PTHREAD_CANCEL_ASYNCHRONOUS</B>: full and partial. Full support
+requires an additional DLL and driver be installed on the Windows
+system (see the See Also section below) that allows blocked threads
+to be cancelled immediately. Partial support means that the target
+thread will not cancel until it resumes execution naturally. Partial
+support is provided if either the DLL or the driver are not
+automatically detected by the pthreads-w32 library at run-time.</P>
+<P>Threads are always created by <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A>
+with cancellation enabled and deferred. That is, the initial
+cancellation state is <B>PTHREAD_CANCEL_ENABLE</B> and the initial
+type is <B>PTHREAD_CANCEL_DEFERRED</B>.
+</P>
+<P>Cancellation points are those points in the program execution
+where a test for pending cancellation requests is performed and
+cancellation is executed if positive. The following POSIX threads
+functions are cancellation points:
+</P>
+<P><A HREF="pthread_join.html"><B>pthread_join</B>(3)</A>
+<BR><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B>(3)</A>
+<BR><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B>(3)</A>
+<BR><A HREF=""><B>pthread_testcancel</B>(3)</A> <BR><A HREF="sem_init.html"><B>sem_wait</B>(3)</A>
+<BR><A HREF="sem_init.html"><B>sem_timedwait</B>(3)</A> <BR><A HREF="pthread_kill.html"><B>sigwait</B>(3)</A></P>
+<P><B>Pthreads-w32</B> provides two functions to enable additional
+cancellation points to be created in user functions that block on
+Win32 HANDLEs:</P>
+<P><A HREF="pthreadCancelableWait.html">pthreadCancelableWait()</A>
+<BR><A HREF="pthreadCancelableTimedWait.html">pthreadCancelableTimedWait()</A></P>
+<P>All other POSIX threads functions are guaranteed not to be
+cancellation points. That is, they never perform cancellation in
+deferred cancellation mode.
+</P>
+<P><B>pthread_testcancel</B> does nothing except testing for pending
+cancellation and executing it. Its purpose is to introduce explicit
+checks for cancellation in long sequences of code that do not call
+cancellation point functions otherwise.
+</P>
+<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
+<P><B>pthread_cancel</B>, <B>pthread_setcancelstate</B> and
+<B>pthread_setcanceltype</B> return 0 on success and a non-zero error
+code on error.
+</P>
+<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
+<P><B>pthread_cancel</B> returns the following error code on error:
+</P>
+<DL>
+ <DL>
+ <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ESRCH</B>
+ </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ no thread could be found corresponding to that specified by the
+ <I>thread</I> ID.
+ </DD></DL>
+</DL>
+<P>
+<B>pthread_setcancelstate</B> returns the following error code on
+error:
+</P>
+<DL>
+ <DL>
+ <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B>
+ </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ the <I>state</I> argument is not
+ </DD></DL>
+</DL>
+<BLOCKQUOTE>
+<B>PTHREAD_CANCEL_ENABLE</B> nor <B>PTHREAD_CANCEL_DISABLE</B>
+</BLOCKQUOTE>
+<P><B>pthread_setcanceltype</B> returns the following error code on
+error:
+</P>
+<DL>
+ <DL>
+ <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B>
+ </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm">
+ the <I>type</I> argument is not
+ </DD></DL>
+</DL>
+<BLOCKQUOTE>
+<B>PTHREAD_CANCEL_DEFERRED</B> nor <B>PTHREAD_CANCEL_ASYNCHRONOUS</B>
+</BLOCKQUOTE>
+<H2><A HREF="#toc5" NAME="sect5">Author</A></H2>
+<P>Xavier Leroy &lt;Xavier.Leroy@inria.fr&gt;
+</P>
+<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
+<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2>
+<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> ,
+<A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A>
+, <A HREF="pthread_cleanup_pop.html"><B>pthread_cleanup_pop</B>(3)</A>
+, Pthreads-w32 package README file 'Prerequisites' section.
+</P>
+<H2><A HREF="#toc7" NAME="sect7">Bugs</A></H2>
+<P>POSIX specifies that a number of system calls (basically, all
+system calls that may block, such as <A HREF="read.html"><B>read</B>(2)</A>
+, <A HREF="write.html"><B>write</B>(2)</A> , <A HREF="wait.html"><B>wait</B>(2)</A>
+, etc.) and library functions that may call these system calls (e.g.
+<A HREF="fprintf.html"><B>fprintf</B>(3)</A> ) are cancellation
+points. <B>Pthreads-win32</B> is not integrated enough with the C
+library to implement this, and thus none of the C library functions
+is a cancellation point.
+</P>
+<P>A workaround for these calls is to temporarily switch to
+asynchronous cancellation (assuming full asynchronous cancellation
+support is installed). So, checking for cancellation during a <B>read</B>
+system call, for instance, can be achieved as follows:
+</P>
+<BLOCKQUOTE><BR><BR>
+</BLOCKQUOTE>
+<PRE STYLE="margin-left: 1cm; margin-right: 1cm">pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &amp;oldCancelType);
+read(fd, buffer, length);
+pthread_setcanceltype(oldCancelType, NULL);</PRE>
+<HR>
+<BLOCKQUOTE><A NAME="toc"></A><B>Table of Contents</B></BLOCKQUOTE>
+<UL>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
+ Value</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See
+ Also</A>
+ </BLOCKQUOTE>
+ <LI><BLOCKQUOTE><A HREF="#sect7" NAME="toc7">Bugs</A>
+ </BLOCKQUOTE>
+</UL>
+</BODY>
+</HTML>