Subject: Re: foo_init()s in main() [was: CVS commit: src/sys]
To: Jason Thorpe <firstname.lastname@example.org>
From: Andrey Petrov <email@example.com>
Date: 11/22/2005 15:13:08
On Tue, Nov 22, 2005 at 02:18:31PM -0800, Jason Thorpe wrote:
> On Nov 22, 2005, at 1:53 PM, Bill Studenmund wrote:
> >How do you think we should encode dependencies? I agree that the
> >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
> >set of "FIRST", "SECOND", and so on). How would we do that w/o the
> >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.
It could be done by kernel linker(loader) so he'll be responsible for module loading
and initialization, and so it wouldn't be needed to code dependiencies explicitly.