Re: pthreads
Marcus Brinkmann <[email protected]>
| Newsgroups | gmane.os.hurd.devel.readers |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Jul 27, 2002 at 07:45:51PM +0200, Neal H. Walfield wrote:
> > The critical piece of the thread implementation (any one) is cancellation.
> > This will work differently in pthreads then it works right now in
> > cthreads.
>
> Well sure it will work differently, but it is essentially, a
> substitution. Right now we use, for instance, hurd_condition_wait:
>
> if (hurd_condition_wait (&cond, &mutex))
> {
> mutex_unlock (&mutex);
> return EINTR;
> }
>
> in pthreads we will do:
>
> pthread_cleanup_push (pthread_mutex_unlock, (void *) &mutex);
> pthread_condition_wait (&cond, &mutex);
> pthread_cleanup_pop (1);
>
> Or are you trying to say something else that I am just missing?
Yes. When the cancellation handler returns, the thread is _cancelled_. So
you need to put a lot more into clean up handlers, eg all resources that are
allocated have to be deallocated, and you have to send a reply message in
the last cancellation handler, etc.
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' GNU http://www.gnu.org [email protected]
Marcus Brinkmann The Hurd http://www.gnu.org/software/hurd/
[email protected]
http://www.marcus-brinkmann.de/