pthread_cancel and EH: let's try this again

Alexander Terekhov terekhov at web.de
Sat Jul 23 19:26:25 UTC 2005


Peter Dimov wrote:
[...]
> It boils down to this. The implementation of pthread_testcancel is:
> 
> if( request pending && cancelstate == ENABLE )
> {
>     set cancelstate to DISABLE
>     clear request
>     throw pthread_cancel_exception
> }
> 
> but I think that a better alternative is:
> 
> if( request pending && cancelstate == ENABLE && not suppressed )
> {
>     suppress cancellation
>     throw pthread_cancel_exception
> }
> 
> with some kind of automatic un-suppression when the exception is finalized.
> The implementation may even have a separate "suppressed" flag and clear it
> at the point where the current GCC calls terminate. Or the suppression flag
> may be inferred from the current EH state in some way.
> 
> Ironically, this implementation was rendered invalid by the resolution of
> your DR.

Yup. But That's because the only thing related to "suppress" *in 
POSIX* is the thread cancel state. Blame Stroustrup & Co. behind 
C/C++ split, not me. With undefined (and not exposed) "suppressed", 
POSIX was clearly defective with respect to thread cancel. You were
taking about "unfinished_exception()"... well, good luck at trying
to get it through http://www.opengroup.org/austin.

regards,
alexander.




More information about the c++-pthreads mailing list