Cancelling a Thread
- Registers a cancellation event with the specified thread.
- There is no way to unregister a cancellation event.
- Does not wait for the thread to terminate.
- Joining with a cancelled thread will return get a status of
- A thread must be in one of three cancellable states...
disabled, deferred, or asynchronous
- A thread always starts its life in the deferred state.
int pthread_setcancelstate(int state, int * old_state);
int pthread_setcanceltype(int type, int * old_type);
- Deferred cancellation can only occur at certain point
- Usually a blocking syscall is a cancellation point
- Mutexes are NEVER a cancellation point
- pthread_testcancel is a cancelation point
- It does nothing if cancellation is disabled
- There is no nondestructive test for a cancelation event.
Chris Provenzano (email@example.com)