On Wed, Apr 27, 2011 at 12:46:54PM +0200, Peter Mazinger wrote:
> OK. let's discuss some implementation details then...
> 
> 1.
> static int __pause(void)
> {
>   blah;
>   /* the return sigsuspend is last */
>   return sigsuspend(...);
> }
> a. strong_alias(__pause,pause)
> b. handle explicitly cancellation
> 
> we have 2 options:
> a. call cancellable sigsuspend and do nothing with pause
> b. call uncancellable sigsuspend and do explicit cancellation
> support for pause
> 
> Since return sigsuspend(...) is the last called, probably it does
> not matter which we opt for, a. provides us with sizewise better
> results

I would definitely opt for a.

BTW I also wouldn't worry too much about a consistent general policy.
There are a finite, very small number of cancellation points specified
in POSIX, assuming you don't want to act on the optional ones (and
acting on the optional ones generally requires painful cleanup
handlers all over libc) so it's not a broad-reaching policy matter.

> 2.
> see poll.c (assume that we do not have poll syscall and we are using the
> fallback code, there select - as cancellable function is called in the mid)
> What is here the correct approach to get a cancellable poll?
> How should here cancellation be handled?
> 
> I think the call to the cancellable select is here not enough, we
> have to explicitly add cancellation to poll, but if we add the
> explicit cancellation to poll, then it probably would make more
> sense to use the non-cancellable select.
> 
> Which is correct?

>From my point of view, removing the poll emulation would be the most
correct, or just ignoring that it's a cancellation point. There's no
system that can correctly support threads but lacks poll. LinuxThreads
is way too broken to attempt using cancellation with it; you'll just
end up with unstable, improperly-behaving programs...

Modulo those concerns, in cases like this, the intent of POSIX is that
the implementation would use pthread_cleanup_push and pop around a
cancellable syscall to cleanup any temporary state/resources the
emulation wrapper had used. Of course this aproach results in a good
deal of bloat for programs that don't use cancellation - it might be
possible to reduce it with clever use of weak symbols.

Another possible implementation-internal approach is to make it so
that cancellable syscalls don't immediately invoke cancellation
handlers, but instead return a specially-defined ECANCELED error to
the syscall wrapper, which the wrapper could then pick up and act on
cancellation. This is actually the way cancellation should have been
designed in POSIX from the beginning, returning ECANCELED to the
application rather than hacking exception-like behavior onto C...

Rich
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to