public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: How EGCS with multi-threaded compliance?
@ 1998-04-16 18:39 Mike Stump
  1998-04-17 16:36 ` David Lucas
  0 siblings, 1 reply; 17+ messages in thread
From: Mike Stump @ 1998-04-16 18:39 UTC (permalink / raw)
  To: dlucas; +Cc: egcs

> Date: Wed, 15 Apr 1998 12:36:17 -0400
> From: David Lucas <dlucas@checkfree.com>

> Alexandre Oliva wrote:
> >Nope, because zero-initialization takes place before any dynamic
> >initialization.

> First off, I prefer Unix over any other OS.  Secondly, my comments
> earlier where in general, compilers do not implement the same nor
> guarentee order of initialization.

General statements aren't very useful, in general.  (:-))

There are hard guarantees abort init order in C++, not many of them,
but there are some.

> Thirdly, where in the C++ specs do you read that zero-initialization
> takes place on anything other than simple types?

  3.6.2  Initialization of non-local objects          [basic.start.init]

1 The storage for objects with static storage duration (3.7.1) shall  be
  zero-initialized  (8.5)  before  any other initialization takes place.

5 To  zero-initialize storage for an object of type  T means:

  - if  T is a non-union class type, the storage for each nonstatic data
    member and each base-class subobject is zero-initialized;

  - if  T is a union type, the storage for its first data  member85)  is
    zero-initialized;

  - if  T is an array type,  the  storage  for  each  element  is  zero-
    initialized;

  - if  T is a reference type, no initialization is performed.


As you can see, pretty clearly states that non-simple types are in
fact zero-initialized.

^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <199804140327.UAA18022@pern.cygnus.com>]
* Re: How EGCS with multi-threaded compliance?
@ 1998-04-13 20:27 Nathan Myers
  1998-04-14 15:55 ` Alexandre Oliva
  0 siblings, 1 reply; 17+ messages in thread
From: Nathan Myers @ 1998-04-13 20:27 UTC (permalink / raw)
  To: egcs

[ multithreaded static inits: ]
> >   void f()
> >   {
> >     static A a;
> >   }
> 
> > The constructor for 'a' is supposed to run the first time you enter f().
> 
> Actually, it is supposed to run the first time control passes through
> the declaration-statement, unless the object is initialized together
> with namespace-scope objects.
> 
> Since there's no requirement in the standard about making this
> thread-safe, and, in fact, the C++ Standard does not talk about
> thread-safety at all, I don't think compilers should care about this,
> since it *is* possible to perform a similiar initialization in a
> thread-safe manner:

There's no requirement for thread-safety anywhere, so why have it at all?
Because users want it.
 
> Of course, a compiler might generate this code implicitly, but I don't 
> think I would appreaciate that much hidden overhead.
 
Most of the "overhead" could be packed into a single (short) function.
The result looks vaguely like:

f()
{
  static struct { char x[sizeof A]; bool inited; } a;  
  if (!a.inited) __init_static(a.x, &_A_ctor, &a.inited);
}

The space overhead is little different from what you have now.  
Probably a single mutex would be sufficient for all the static 
locals.

In general, for thread-safety the compiler should lock for
invisible activities that are not thread-safe, so that libraries
that don't have obvious violations can easily be adopted into an
mt program.

Nathan Myers
ncm@cantrip.org


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: How EGCS with multi-threaded compliance?
@ 1998-04-13 20:27 Nathan Myers
  1998-04-14  6:11 ` David Lucas
  0 siblings, 1 reply; 17+ messages in thread
From: Nathan Myers @ 1998-04-13 20:27 UTC (permalink / raw)
  To: egcs

David Lucas <dlucas@checkfree.com>
> Just an observastion, but some compilers do not even guarentee that
> init_lock will be initialized before the use of f_initialize_a, thus a
> possible uninitialized Mutex object.

On any Real System, the mutex object is correctly initialized
by the runtime loader before any static constructors are run.
That is, the zero value is a valid, unlocked mutex.  

Code that runs on losing systems is less efficient.  But isn't
that a tautology?  

Nathan Myers
ncm@cantrip.org  http://www.cantrip.org/


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: How EGCS with multi-threaded compliance?
@ 1998-04-09 18:29 Mike Stump
  0 siblings, 0 replies; 17+ messages in thread
From: Mike Stump @ 1998-04-09 18:29 UTC (permalink / raw)
  To: Dirk.Broer, egcs

> From: "Dirk Broer" <Dirk.Broer@gsfc.nasa.gov>
> To: "EGCS" <egcs@cygnus.com>
> Date: Fri, 3 Apr 1998 18:14:55 -0500

> I'm searching for a C++ compiler that is multi-thread compliance.

I suspect that g++ can do what you want.

> Under a high context switch environment g++ consistently fails.

This statement doesn't have enough detail for us to help you.

For example, if you use fopen, and your environment provides an fopen
that isn't mt safe, then calls to it in C++ (as compiled with g++) in
an mt situation are wrong and will fail.

I don't offhand know of a bug that you are referring to, so I cannot
comment further.

Show us how it fails, show us why.  If you do that, we may be able to
fix it for you.

> Is EGCS better?  Especially the c++ parts?

egcs is better in some respects.

I am very interested in mt type bugs, as I work for a company that
does mt OSes.  I maintained the official g++ bug repository for 5 or
so years, and in all that time, I don't recall seeing any/many bug
reports relating to mt issues.


As a side note, egcs g++ has had a bit of work on exception handling,
and we recently have been improving that to make it thread safe.

^ permalink raw reply	[flat|nested] 17+ messages in thread
* How EGCS with multi-threaded compliance?
@ 1998-04-03 21:52 Dirk Broer
  1998-04-04 20:05 ` Jeffrey A Law
  0 siblings, 1 reply; 17+ messages in thread
From: Dirk Broer @ 1998-04-03 21:52 UTC (permalink / raw)
  To: EGCS

I'm searching for a C++ compiler that is multi-thread compliance.

Under a high context switch environment g++ consistently fails.   I've
been told this is to be expected with g++ (even release 2.8x)

Is EGCS better?  Especially the c++ parts?

The word "thread" never showed up in the faq so I fear the worse.

Dirk


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~1998-04-17 16:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <004501bd5f56$50b61ba0$2c91b780.cygnus.egcs@pitcheri.gsfc.nasa.gov>
1998-04-10 20:10 ` How EGCS with multi-threaded compliance? Nathan Myers
1998-04-10 21:44   ` Alexandre Oliva
1998-04-13 12:28     ` David Lucas
1998-04-11  4:07   ` John Carr
1998-04-16 18:39 Mike Stump
1998-04-17 16:36 ` David Lucas
     [not found] <199804140327.UAA18022@pern.cygnus.com>
     [not found] ` <35336112.59CF6444.cygnus.egcs@checkfree.com>
1998-04-14 13:21   ` Ulrich Drepper
1998-04-15 14:53     ` David Lucas
  -- strict thread matches above, loose matches on Subject: below --
1998-04-13 20:27 Nathan Myers
1998-04-14 15:55 ` Alexandre Oliva
1998-04-13 20:27 Nathan Myers
1998-04-14  6:11 ` David Lucas
1998-04-14 15:55   ` Alexandre Oliva
1998-04-09 18:29 Mike Stump
1998-04-03 21:52 Dirk Broer
1998-04-04 20:05 ` Jeffrey A Law
1998-04-05 10:02   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).