[Prev] [Contents] [Next]
Unsupported cancelation points
OS/400 does not support the full set of cancelation points. Although the APIs may be provided, they are not necessarily cancelation points. The only cancelation points currently supported are those APIs that are part of the pthreads run-time. i.e.
- pthread_cond_timedwait()
- pthread_cond_wait()
- pthread_delay_np()
- pthread_join()
- pthread_join_np()
- pthread_testcancel()
An appropriate work around to create cancelation points for these APIs might be something like the following example. You can use this example to create a cancelation point out of any function that is asynchronous signal safe. See the Signal Concepts section of the Unix Type APIs section in the System API reference book for the list of asynchronous. signal safe functions. If the function is not asynchronous signal safe, this form of asynchronous cancelation is not recommended and could cause data corruption.
... Your code ...
int oldtype=0;
/* If cancelation is currently disabled, this will have no effect */
/* if cancelation is currently enabled, we'll set it to asynchronous */
/* for the duration of this call to try to simulate a cancelation point */
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
/* Call kernel API that you want to be a cancel point. You should */
/* only call functions which are async signal safe in this block. */
/* Validating the async signal safety of the function will */
/* ensure that the asynchronous cancelation doesn't negatively */
/* effect the API or corrupt the data that the API uses */
APICallHere();
/* Restore the cancelation type that was previously in effect */
pthread_setcanceltype(oldtype, &oldtype);
... More code ...
[Prev] [Contents] [Next]
Copyright © 1998, IBM Corporation. All rights
reserved.
Comments? Contact rchthrds@us.ibm.com