Re: [c++-pthreads] Re: cancellation points report failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Re: cancellation points report failure



Alexander Terekhov wrote:

David Abrahams wrote:
[...]
Of course it's not safe.  That's my point, sort of: if you use
synchronous cancellation, you have to give up on any *guarantee* that
the thread will be cancelled, so we shouldn't be considering measures
that take heroic steps to try to ensure it.  If you want to guarantee
that cancellation happens, you have to do something unsafe.
Note that the use of POSIX asynchronous cancellation (I mean the presence of async-cancel{-safe} regions on the execution path) does NOT guarantee thread termination (cancel request delivery) at all.
Conforming implementations are free to ignore it completely, so to
speak. I wish the standard would define pthread_testcancel() "in
terms" of an empty async-cancel region (and it would also provide async-cancel-safety for pthread_testcancel() itself):

void pthread_testcancel() { /* mandatory shall occur semantics */
int oldtype; pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 pthread_setcanceltype(oldtype, &oldtype);
}
This is all way off topic, but what's your point here, Alexander?

Are you intending to suggest that pthread_setcanceltype() be made a guaranteed cancellation point, so your substitution would have the same effect as the current pthread_testcancel()... or that the definition of pthread_testcancel() (using the current semantics of pthread_setcanceltype()) should be allowed to ignore a pending cancel? ;-)

--
/--------------------[ David.Butenhof@xxxxxx ]--------------------\
| Hewlett-Packard Company       Tru64 UNIX & VMS Thread Architect |
|     My book: http://www.awl.com/cseng/titles/0-201-63392-2/     |
\----[ http://homepage.mac.com/dbutenhof/Threads/Threads.html ]---/