PTHREAD_CANCEL_DEFERRED

Kostik Belousov kostikbel at gmail.com
Wed Aug 18 10:04:11 UTC 2010


On Wed, Aug 18, 2010 at 01:32:39PM +0000, David Xu wrote:
> David Xu wrote:
> >My idea is to always let close() syscall run, until it will be
> >blocked by lower layer, e.g tty or socket layer, as manual of close()
> >said it always release the file descriptor despite whether
> >it returns EINTR or EWOULDBLOCK, when it is going to sleep,
> >a flag will cause it to abort the sleep.
> >if the thread does not found the flag at that time,
> >a latter signal SIGCANCEL sent by pthread_cancel will unblock it,
> >this is how signal works.
> >
> 
> I have worked out a patch:
> http://people.freebsd.org/~davidxu/patch/thread_cancel.patch
> 
Ok, the patch is definitely better then my proposal. But it has several
details that seems to need correction.

First, if TDP_WAKEUP-marked thread receives any non-cancellation signal,
then a syscall returns with EINTR. This breaks SA_RESTART.

Also, I think that a condition to perform cancellation in thr_syscalls.c
should be not (ret == -1), but (ret == -1 && errno == EINTR).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20100818/17df22e9/attachment.pgp


More information about the freebsd-threads mailing list