The "cancel" message is sent to thread which do long-time job if necessary. While the function which do long-time job must check whether there are "cancel" message received, if so, the function must stop working and return.
- It isn't native programming model in Linux/Unix, so third party software will not use it.
- Can't cancel work in kernel (for example the sleep or block read can not be interrupted)
- signal / real time signal
The "cancel" signal is sent to thread which do long-time job if neccesary. Upon the signal is received, the blocked operation (such as sleep, blocked read, etc) will be interrupted and a signal action function will be called which set a flag to indicate the canel signal is received by the thread. The function which do long-time job must check the flag to see whether there are "cancel" signal received, if so, the function must stop working and return.
- Native programming model in Linux/Unix, easy to cooperate with third party software.
- Can cancel work in kernel.
- race conditions !!!