Re: Thread Cancelation
Re: Thread Cancelation
- Subject: Re: Thread Cancelation
- From: John Stiles <email@hidden>
- Date: Fri, 29 Oct 2004 14:27:03 -0700
On Oct 29, 2004, at 1:51 PM, Agent M wrote:
On most threading implementations, canceling a thread is a bad idea.
If a thread is sleeping or waiting on a mutex, etc, what, exactly do
you expect to happen? What happens to any memory that code in that
thread allocated? What happens to resources that that thread my have a
lock on? What happens to objects that still have positive retain
counts?
These are all accounted for by POSIX with pthread cleanup handlers or
thread-specific memory. Apparently, Darwin doesn't offer the full
POSIX functionality of pthread cancel states which means Darwin is
deficient. If it is possible to cancel an arbitrary mach thread, then
it should be possible to cancel pthreads layered on top of them. The
deficiency lies in a number of syscalls which are not cancel-safe.
Maybe this will be fixed in the next release.
Which OSes implement this fully?
I've never even heard of this. It sounds cool from a theoretical
perspective, but in practice, trying to write code that can be stopped
at any arbitrary point and then asked to clean itself up sounds like an
utter nightmare. I think there are only a few programmers in the world
who could write bulletproof code in this fashion.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden