ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/users_38.htm

121 lines
5.9 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>Thread cancellation APIs</title>
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Begin Header Records ========================================== -->
<!-- NETMG2 SCRIPT A converted by B2H R4.1 (346) (CMS) by HOLTJM at -->
<!-- RCHVMW2 on 29 Jan 1999 at 10:01:37 -->
<!--File Edited November 2001 -->
<!-- 031112 JETAYLOR replaced API and/or Exit listings with -->
<!-- pagegenerator output from javascript array -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>Thread cancellation APIs</h2>
<p>You can use thread cancellation APIs to cause a thread to end prematurely,
or to aid in cleanup when a thread is ended (either prematurely or normally).
The thread cancellation APIs work together to provide a mechanism for thread
cleanup and protecting threaded resources from cancellation. The thread
cancellation APIs only provide clean up and protection in relationship to other
pthread APIs. You cannot protect from or clean up when a thread ends as a
result of your process ending (normally or abnormally), or when the thread ends
by some mechanism outside of the pthread API set. Some examples of mechanisms
that can terminate a thread that are outside o the pthread API set are the
ENDJOB *IMMED CL command, a thread ending from an unhandled exception, or the
operator terminating a thread using the work with threads screen (Option 20
from the WRKJOB display).</p>
<p>The table below lists the thread cancelability states, the cancellation
types, and the cancellation action. Cancelability consists of three separate
states (disabled, deferred, asynchronous) that can be represented by two
boolean values. The default cancelability state is deferred.</p>
<table border width="80%">
<tr>
<th valign="top">Cancelability</th>
<th valign="top">Cancelability State</th>
<th valign="top">Cancelability Type</th>
</tr>
<tr>
<td align="left" valign="top" width="20%">disabled</td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_DISABLE</strong></td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_DEFERRED</strong></td>
</tr>
<tr>
<td align="left" valign="top" width="20%">disabled</td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_DISABLE</strong></td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_ASYNCHRONOUS</strong></td>
</tr>
<tr>
<td align="left" valign="top" width="20%">deferred</td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_ENABLE</strong></td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_DEFERRED</strong></td>
</tr>
<tr>
<td align="left" valign="top" width="20%">asynchronous</td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_ENABLE</strong></td>
<td align="left" valign="top" width="40%">
<strong>PTHREAD_CANCEL_ASYNCHRONOUS</strong></td>
</tr>
</table>
<p>For information about the examples included with the APIs, see the <a href=
"users_g3.htm">information on the API examples</a>.</p>
<p>The thread cancellation APIs are:</p>
<!-- ***** NOTE ***** Do not manually update text or links in this section. -->
<!-- Updates made in this section *will* be overlaid by automated tools -->
<!-- Notify User Technologies of needed updates to be made in XML for API finder.-->
<!--***************API BEGIN PASTE***************-->
<ul>
<li><A HREF="users_39.htm">pthread_cancel()</A> (Cancel Thread) requests cancellation of the target thread.</li>
<li><A HREF="users_40.htm">pthread_cleanup_peek_np()</A> (Copy Cleanup Handler from Cancellation Cleanup Stack) returns a copy of the cleanup handler entry that the next call to pthread_cleanup_pop() would pop.</li>
<li><A HREF="users_41.htm">pthread_cleanup_pop()</A> (Pop Cleanup Handler off of Cancellation Cleanup Stack) pops the last cleanup handler from the cancellation cleanup stack.</li>
<li><A HREF="users_42.htm">pthread_cleanup_push()</A> (Push Cleanup Handler onto Cancellation Cleanup Stack) pushes a cancellation cleanup routine onto the calling threads cancellation cleanup stack.</li>
<li><A HREF="users_43.htm">pthread_getcancelstate_np()</A> (Get Cancel State) gets the current cancel state of the thread.</li>
<li><A HREF="users_44.htm">pthread_setcancelstate()</A> (Set Cancel State) sets the cancel state to one of PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE and returns the old cancel state into the location specified by oldstate (if oldstate is non-NULL).</li>
<li><A HREF="users_45.htm">pthread_setcanceltype()</A> (Set Cancel Type) sets the cancel type to one of PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS and returns the old cancel type into the location specified by oldtype (if oldtype is non-NULL)</li>
<li><A HREF="users_47.htm">pthread_test_exit_np()</A> (Test Thread Exit Status) returns the current state of the thread along with its exit status.</li>
<li><A HREF="users_46.htm">pthread_testcancel()</A> (Create Cancellation Point) creates a cancellation point in the calling thread.</li>
</ul>
<!--***************API END PASTE***************-->
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"rzah4mst.htm">Pthread APIs</a> | <a href="aplist.htm">APIs by
category</a></td>
</tr>
</table>
</center>
</body>
</html>