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

94 lines
3.5 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!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>Unsupported cancellation points</title>
<!-- Begin Header Records ========================================== -->
<!-- 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. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- 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 -->
<!--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>Unsupported cancellation points</h2>
<p>i5/OS does not support the full set of cancellation points. Although the
APIs may be provided, they are not necessarily cancellation points. The only
cancellation points currently supported are those APIs that are part of the
Pthread run-time. Those APIs are the following:</p>
<ul>
<li><strong>pthread_cond_timedwait</strong>()</li>
<li><strong>pthread_cond_wait</strong>()</li>
<li><strong>pthread_delay_np</strong>()</li>
<li><strong>pthread_join</strong>()</li>
<li><strong>pthread_join_np</strong>()</li>
<li><strong>pthread_testcancel</strong>()</li>
</ul>
<p>An appropriate alternative to create cancellation points for these APIs
might be like the following example. You can use this example to create a
cancellation point out of any function that is asynchronous signal safe. See
<a href="unix5a2.htm">Signal Concepts</a> for a list of functions that are
asynchronous signal safe. If a function is not asynchronous signal safe, you
should not use this form of asynchronous cancellation because it corrupt
data.</p>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<pre>
... preceding code ...
int oldtype=0;
/* If cancellation is currently disabled, this will have no effect */
/* if cancellation is currently enabled, we'll set it to asynchronous */
/* for the duration of this call to try to simulate a cancellation point */
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &amp;oldtype);
/* Call kernel API that you want to be a cancel point. You should */
/* only call functions which are asynchronous signal safe in this block. */
/* Validating the asynchronous signal safety of the function will */
/* ensure that the asynchronous cancellation does not negatively */
/* affect the API or corrupt the data that the API uses */
APICallHere();
/* Restore the cancellation type that was previously in effect */
pthread_setcanceltype(oldtype, &amp;oldtype);
... following code ...
</pre>
<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>