Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Dec 1995 11:18:29 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        cimaxp1!jb@werple.net.au (John Birrell)
Cc:        terry@lambert.org, hackers@FreeBSD.org, jb@cimlogic.com.au
Subject:   Re: _thread_init stub in libc (fwd) RFC
Message-ID:  <199512071818.LAA05138@phaeton.artisoft.com>
In-Reply-To: <199512070648.RAA13286@werple.net.au> from "John Birrell" at Dec 7, 95 05:52:13 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512071818.LAA05138>