[ros-kernel] Section object initialization
Hartmut Birr
hartmut.birr at gmx.de
Sat Oct 18 10:41:51 CEST 2003
> -----Original Message-----
> From: ros-kernel-bounces at reactos.com
> [mailto:ros-kernel-bounces at reactos.com] On Behalf Of KJK::Hyperion
> Sent: Thursday, October 16, 2003 10:13 PM
> To: ReactOS General List
> Subject: Re: [ros-kernel] Section object initialization
>
> why not use topological sort to ensure initialization
> routines are called
> in the proper order? the algorithm is very simple:
>
> void init_doh(void)
> {
> // node coloring to prevent infinite recursion
> static bool entered = 0;
> if(entered) return;
> else entered = 1;
>
> // initialize units Doh depends from
> init_blah();
> init_graz();
>
> // initialize Doh unit
> // etc.
> }
>
> You keep an array of initialization routines somewhere,
> something like:
>
> void (*inits[])(void) =
> {
> init_blah,
> init_doh,
> init_graz
> };
>
> and just call them one by one. They'll resolve the dependencies
> automatically, they'll ensure by themselves they won't be
> called twice and
> they'll require no micro-management. If you find yourself in
> some nasty
> circular dependency scenario, you just split the
> initialization functions
> into smaller ones
>
I don't like this way for calling init functions. If each init function
can call an other init function, it is very difficult to find out the
real calling order for the init functions.
- Hartmut
More information about the Ros-kernel
mailing list