Subject: Re: foo_init()s in main() [was: CVS commit: src/sys]
To: Bill Studenmund <>
From: Jason Thorpe <>
List: tech-kern
Date: 11/22/2005 14:18:31
On Nov 22, 2005, at 1:53 PM, Bill Studenmund wrote:

> How do you think we should encode dependencies? I agree that the  
> FreeBSD
> way is uncentralized. However someone who studies the whole system can
> tune it so that things get loaded in the right order (just pick the  
> right
> set of "FIRST", "SECOND", and so on). How would we do that w/o the  
> master
> list of values?

The init routine for each subsystem could easily enough call init  
routines for the subsystems on which it depends.  Each of those init  
routines would internally handle the "once" handling.


static void
	/* do stuff */

	static ONCE_DECL(once_control);

	RUN_ONCE(once_control, foo_init0);

So, consider a network driver, which would call if_attach()...  
if_attach() would in turn call if_init(), which would in turn call  
if_init0() once.

For things like lists / tables / etc., we can change to using static  
initializers for those.


-- thorpej