[cpp-threads] pthreads cancellation

Boehm, Hans hans.boehm at hp.com
Tue Apr 26 21:25:33 BST 2005


Clarification:

I think we should not support asynchronous cancellation, at
least initially.  As far as
we're concerned, cancellation can only happen at cancellation
points, a notion we might want to extend.

It's extremely difficult to write C code that is correct in the
presence of asynchronous cancellation.  As far as I can tell, it's
safe to enable asynchronous cancellation at best in (presumably
long-running) compute intensive code that works on a data
structure you can entirely discard if you're cancelled.
There are enough C++ facilities that work on shared data under
the covers that I think it would be really hard just to
specify under what (rare I'm afraid) conditions asynchronous
cancellation
is actually safe.

My impression is that this is already greatly underspecified
for C library code.  I have no idea which parts of libc, if any,
are safe for asynchronous cancellation.

Java got rid of anything resembling asynchronous cancellation
for these reasons.

Hans


> -----Original Message-----
> From: 
> Cpp-threads_decadentplace.org.uk-bounces at decadentplace.org.uk 
> [mailto:Cpp-threads_decadentplace.org.uk-bounces at decadentplace
> .org.uk] On Behalf Of Lawrence Crowl
> Sent: Tuesday, April 26, 2005 1:09 PM
> To: cpp-threads at decadentplace.org.uk
> Subject: Re: [cpp-threads] pthreads cancellation
> 
> 
> "Boehm, Hans" <hans.boehm at hp.com> writes:
>  >(I think there is a (near ?) consensus that we can ignore 
> Posix  >asynchronous cancellation.  I would suggest we not go there.)
> 
> I'm a little unclear on whether that means "not ignoring" or 
> "ignoring".
> 
> There are two problems with thread cancellation.
> 
> First, it is asynchronous.  The exception tables have to be 
> robust enough to handle any instruction pointer.  More 
> importantly, any optimizations between two function calls may 
> change the program behavior in the event of a cancellation, 
> where they would not otherwise.
> 
> Second, it is unpredictable.  We can do substantial 
> optimization when we know that a function cannot throw.  With 
> cancellation, we can never know that it cannot throw.
> 
>   Lawrence Crowl             650-786-6146   Sun Microsystems, Inc.
>                    Lawrence.Crowl at Sun.com   16 Network 
> Circle, UMPK16-303
>            http://www.Crowl.org/Lawrence/   Menlo Park, 
> California, 94025
> 
> -- 
> cpp-threads mailing list
> cpp-threads at decadentplace.org.uk 
> http://decadentplace.org.uk/mailman/listinfo/cpp-threads_decad
entplace.org.uk




More information about the cpp-threads mailing list