Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA00483; Fri, 8 Dec 95 16:30:07 EST
Received: from freefall.FreeBSD.ORG by MIT.EDU with SMTP
	id AA14757; Fri, 8 Dec 95 16:28:58 EST
Received: from localhost (daemon@localhost)
          by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id KAA05479
          Thu, 7 Dec 1995 10:25:14 -0800 (PST)
Received: (from root@localhost)
          by freefall.freebsd.org (8.7.3/8.7.3) id KAA05166
          for hackers-outgoing; Thu, 7 Dec 1995 10:20:52 -0800 (PST)
Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211])
          by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id KAA05159
          for <hackers@FreeBSD.org>; Thu, 7 Dec 1995 10:20:49 -0800 (PST)
Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id LAA05138; Thu, 7 Dec 1995 11:18:29 -0700
From: Terry Lambert <terry@lambert.org>
Message-Id: <199512071818.LAA05138@phaeton.artisoft.com>
Subject: Re: _thread_init stub in libc (fwd) RFC
To: cimaxp1!jb@werple.net.au (John Birrell)
Date: Thu, 7 Dec 1995 11:18:29 -0700 (MST)
Cc: terry@lambert.org, hackers@FreeBSD.org, jb@cimlogic.com.au
In-Reply-To: <199512070648.RAA13286@werple.net.au> from "John Birrell" at Dec 7, 95 05:52:13 pm
X-Mailer: ELM [version 2.4 PL24]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Sender: owner-hackers@FreeBSD.org
Precedence: bulk

> > Why does _thread_init() need to be called from crt0?
> 
> I guess it doesn't have to. The purpose of _thread_init is to (1) set up
> the thread structure for the initial thread; (2) initialise the file
> descriptor table in malloced memory; and (3) initialise signal handling.
> All of this is best done before executing *any* user code.
> 
> > What is the call graph of allowable functions?
> 
> Huh???

What do you have to call in what order, from first to last, to get the
thing to work, so we can pick something at the front of the list and
toenail it in there with:

	static int once = 0;

	if( !once) {
		once = 1;
		_thread_init();
	}

> We don't have a create_thread function. If you mean pthread_create, this is
> not called for the initial thread. The initialisation still has to be
> performed regardless of whether or not you create another thread.

What about a non-threaded program?

I'm thinking to delay the "initial thread" until the first "pthread_create"
to create a second thread.

> > I would *strongly* recommend looking at the initialization sequence
> > for the more recent bind code, which was changed to be "shared library
> > friendly" (breaking older revs of sendmail 8-) at the same time).
> 
> I don't understand how this is relevant. I don't think that what I am
> proposing is "shared library unfriendly". The libc shared library would
> contain an extra function:

Because it addresses the problem of use-time initialization as opposed
to calling an initialization before use.  This was an intentional change
to discard static agregate initialization, which is the other option for
you right now.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
