This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: threadsafeness at egcs1.0.3 and 1.1


> To: egcs@cygnus.com
> Date: 10 Jul 1998 20:24:11 -0700
> From: Ulrich Drepper <drepper@cygnus.com>
> Stamped: newsgate-cygnus

> martin@mira.isdn.cs.tu-berlin.de (Martin von Loewis) writes:

> > int f()
> > {
> >   static int i = get_some_value();
> >   return i;
> > }

> long).  Plus there is the problem of handling this case if no
> threaded program is used.  (Note that it isn't possible to have a
> simple "not done"/"done" flag since the second thread arriving must
> not return from the get_some_value call until the first did and this
> requires interaction with the thread package.  Busy waiting is no
> option since the waiting thread might have a higher priority.)

No, this is defined in C++ as i having the value zero on the second
call until someone starts changing i.  The implementation is required
to not block, pend or busy wait.  We can extend this out to threaded
apps uniformly.  The setting and testing of the single flag that
controls initialization should be critical regioned.

But yes, even when we do all this, it doesn't have nice semantics in
beefy threaded programs, unless you use sigatomic_t and volatile.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]