pthread unsafe macros

Alex Waugh alex at alexwaugh.com
Wed Mar 3 11:48:18 PST 2004


In message <404505E1.1070701 at dsvr.net>
          Nick Burrett <nick at dsvr.net> wrote:

> Alex Waugh wrote:
> > In message <3FFAB7B8.6070105 at dsvr.net>
> >           Nick Burrett <nick at dsvr.net> wrote:
> > 
> > 
> >>
> >>Alex,
> >>
> >>Could you explain why the function Bfree in strtod.c requires 
> >>PTHREAD_UNSAFE to be declared ?  I would have assumed that the 
> >>declaration is only needed at the toplevel function i.e. strtod rather 
> >>than at all child functions.
> >>
> >>Hmm.  On closer inspection of _ints.s, are you doing this so that 
> >>interrupts are disabled for as little time as possible ?
> > 
> > 
> > It's just a trade off between context switch latency and
> > efficiency/simplicity. In general if a function was thread safe but its
> > children weren't then I would only put PTHREAD_UNSAFE in the child
> > functions, which made things simpler when the child function was in a
> > different file or could be called from more than one parent function.
> > In strtod's case all the child functions are static thus it doesn't
> > really matter, and I suspect the difference would be unnoticable.
> 
> Well, maybe.  Consider the difference here, the former with 
> PTHREAD_UNSAFE and the latter without.  It probably is unnoticable though.

I hadn't considered that it might turn a leaf function into a non-leaf
function, so in this case that is a bigger overhead than I was
expecting. Feel free to change it, but it doesn't bother me enough to
change it myself :-)

Alex

-- 
Alex Waugh                                           alex at alexwaugh.com

PHP, Roots, Subversion, WebJames and more from http://www.alexwaugh.com/





More information about the gcc mailing list