On 03-Apr-2002 Terry Lambert wrote:
> Jake Burkholder wrote:
>> The reason they need to be initialized is to insert them into an all_mtx
>> list which is used for debugging. Otherwise there's no problem; the lock
>> for said list is statically initialized.
>>
>> This is the kernel. This is not pthreads. Arguably anything that depends
>> on them needing to be statically initialized to unlocked and usable is
>> broken.
>
> So it should be "#ifdef DEBUG".
>
> In the non-debug case, this should be done using linker sets.
> Here is some sample code:
>
> struct foo {
> int some_data;
> struct foo *next;
> };
>
> #define FOOINIT(uniquifier, data) \
> static struct foo uniquifier ## _foo_init = { \
> data, \
> 0 \
> }; \
> DATA_SET(foo_set,uniquifier ## _foo_init);
>
> void
> foo_startup( void)
> {
> register struct foo **foopp;
>
> /*
> * Turn sysinit list into linked list so we can
> * extend it later by linking things onto the
> * next pointer.
> */
> for( foopp = foo; *foopp != NULL; foopp++) {
> if ( *(foopp + 1) != NULL)
> (*foopp)->next = *(foopp + 1);
> }
> }
>
> Voila'. You now have a linked list, like that used for debugging,
> built out of linker set entries, and the list is runtime extensible,
> unlike, say, the VOP descriptor list.
>
> You can now statically declare mutex instances, and they will be
> immediately ready for use, after the statup that does the linkage
> runs.
We need mutexes prior to mi_startup().
--
John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message