(Non-)cancellable functions usage

Peter Mazinger ps.m at gmx.net
Wed Apr 27 10:46:54 UTC 2011


Hi Carmelo,

> > within uClibc we reuse some of the functions (mostly their __GI_X
> > counterparts by libc_hidden_proto(). By having the cancellation
> > in libc, we most of the time reuse the cancellable version
> 
> I think that this is correct, because we don't know if the libc function
> is called in a multi-thread scenario that it is going to be canceled. If
> we use generally a not-cancellable implementation within libc itself, we
> could prevent cancellation to happen.
> Make sense ?
> 
> > Currently we dedicately define (as glibc does) where the non-cancellable
> > function should be used (by using FUNC_not_cancel*/not-cancel.h).
> > There are 2 approaches:
> > 1. use it the glibc-way (and probably adding bloat at runtime for
> unneeded
> > cancellation-handling).
> 
> if there are no threads actually, we just pay for an if (0).
> 
> > 2. invert the usage and use per default the non-cancellable functions
> within uClibc, using the cancellable ones only if it is unavoidable
> > (or necessary or we benefit sizewise).
> > At least libc would benefit of this (to reuse these in other libs out of
> > libc we need to either export them, or provide a structure with pointers
> > to use them within libpthread/librt).
> > If the cancellable version is used, it might also be documented, why
> this
> > has to happen.
> > 
> > A good example (although not quite correct) is the use of close()
> > within libc. In most of the cases close_not_cancel_no_status
> > would be more appropiate, since there is no error checking done...
> > 
> > Opinions?
> > 
> 
> I have much more doubts than opinions :)
> 
> > Personally I would opt for 2.
> > 
> 
> Based on my first comment, I'd opt for 1 instead.

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

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?

Thanks, Peter
> 
> Cheers,
> Carmelo
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone


More information about the uClibc mailing list