![]() |
|
||||
POSIX 1.c Migration Guide |
Thread Cancellation
Thread Cancellation Control
The thread cancellation control interfaces have undergone significant changes from POSIX.4a to POSIX.1c. These are listed in the following table:
Thread Cancellation Control Interface Changes POSIX.1c POSIX.4aThe POSIX.4a interfaces use the values CANCEL_ON (to enable) and CANCEL_OFF (to disable) to control both the general cancellability state via pthread_setcancel() and the asynchronous cancellability state via pthread_setasynccancel(). POSIX.1c defines a distinct set of values for each control interface: PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE to control cancellability state via pthread_setcancelstate(), and PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS to control cancellability type via pthread_setcanceltype().
The pthread_cleanup_push() and pthread_cleanup_pop() functions in LynxOS versions prior to 3.1.0 returned an int instead of nothing (void) to allow handing cleanup stack management errors from the underlying implementation. The LynxOS 4 versions of these functions have a void return type in compliance with POSIX.1c and silently ignore errors that may occur in the underlying implementation. This may result in one or more cleanup handlers not being registered or run if cleanup stack management errors occur.
Cancellability Defaults
In LynxOS versions prior to 3.1.0, both general and asynchronous cancellability were disabled by default in all newly created threads (this was not POSIX.4a
Draft 4-compatible).LynxOS 4 is fully compliant with POSIX.1c, where the cancellability state and type of any newly created threads, including the thread in which main() was invoked, is cancellation enabled (PTHREAD_CANCEL_ENABLE) and asynchronous cancellation disabled (PTHREAD_CANCEL_DEFERRED).
Cancellation Points
In POSIX.4a, cancellation points in blocking POSIX.1 and POSIX.4 (POSIX.1b) are implementation defined. LynxOS versions prior to 3.1.0 implemented cancellation points in the POSIX.1b blocking synchronization primitives, but not in POSIX.1 functions.
POSIX.1c explicitly defines function lists for all mandatory and optional POSIX.1 and C Standard cancellation points (see ISO/IEC 9945-1 1996 Section 18.1.2). LynxOS implements all listed optional as well as mandatory cancellation points.
Elimination of Cancellation-Safe Interfaces
POSIX.4a required a number of ANSI C Standard functions to be asynchronous-cancel safe. POSIX.1c does not require any POSIX.1 or C Standard functions to be asynchronous-cancel safe.
Cleanup Handler Restrictions
In POSIX.4a, support for exiting a cancellation handler via longjmp() or siglongjmp() was implementation defined, although not supported by LynxOS. This behavior is explicitly disallowed in POSIX.1c.
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |