Re: [c++-pthreads] Re: pthread_cancel and EH: let's try this again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Re: pthread_cancel and EH: let's try this again
- To: Peter Dimov <pdimov@xxxxxxxxx>
- Subject: Re: [c++-pthreads] Re: pthread_cancel and EH: let's try this again
- From: Dave Butenhof <david.butenhof@xxxxxx>
- Date: Wed, 27 Jul 2005 11:35:00 -0400
Peter Dimov wrote:
Peter Dimov wrote:
It's certainly questionable whether a cleanup handler (TSD
destructor) that explicitly enables cancellation and calls a
cancellation point should re-cancel itself... and if it does, whether
it should re-invoke itself, so it might be argued that this
clarification introduced a new problem instead of fixing the old.
Scratch that, if this:
"The cancelability state shall remain set to PTHREAD_CANCEL_DISABLE
until the thread has terminated. The behavior is undefined if a
cancellation cleanup handler or thread-specific data destructor
routine changes the cancelability state to PTHREAD_CANCEL_ENABLE."
made it into the TC, it specifically prohibits the scenario I
described. It also appears to prohibit enabling cancellation after
catch(pthread_cancel_e) without rethrow, effectively disallowing catch
without rethrow ("shall remain set to...").
That's an intrinsic requirement of the C binding to POSIX; there's no
catch, only cleanup handlers which implicitly and irrevokably "rethrow".
(And aren't allowed to interfere in any way with the unwind.) It's not
just cleanup handlers that need cancel disabled, but also TSD
destructors, which run only when the thread has been fully unwound. We
can't say "if", because in POSIX there's no if... the thread IS fully
unwound, and TSD destructors DO run; but concession to a catchable
cancel in some other language binding would mean breaking those scopes
in two... possible, yes; but more complicated and pretty hard to justify
in the current standards environment that's C-only and exception-phobic.
begin:vcard
fn:Dave Butenhof
n:Butenhof;Dave
org:Hewlett-Packard Company;Manageability Systems Lab
adr;dom:110 Spit Brook Rd;;ZKO2-3/Q18;Nashua;NH;03062
email;internet:david.butenhof@xxxxxx
title:HP Utility Pricing software agent Technical Lead
tel;work:603.884.7460
note;quoted-printable:POSIX thread standards consultant=0D=0A=
Author of "Programming With POSIX Threads" (Addison-Wesley)=0D=0A=
Father to Amy (12) and Alyssa (8)
x-mozilla-html:TRUE
version:2.1
end:vcard