public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: ncm@cygnus.com (Nathan Myers)
To: egcs@cygnus.com
Subject: Re: How EGCS with multi-threaded compliance?
Date: Mon, 13 Apr 1998 20:27:00 -0000	[thread overview]
Message-ID: <199804140314.UAA18016@pern.cygnus.com.> (raw)

[ 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


             reply	other threads:[~1998-04-13 20:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-13 20:27 Nathan Myers [this message]
1998-04-14 15:55 ` Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
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
1998-04-13 20:27 Nathan Myers
1998-04-14  6:11 ` David Lucas
1998-04-14 15:55   ` Alexandre Oliva
     [not found] <004501bd5f56$50b61ba0$2c91b780.cygnus.egcs@pitcheri.gsfc.nasa.gov>
1998-04-10 20:10 ` 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-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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199804140314.UAA18016@pern.cygnus.com. \
    --to=ncm@cygnus.com \
    --cc=egcs@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).