John Baldwin wrote:
> > God, it's annoying that a statically declared mutex is not
> > defacto initialized.
> Is it in solaris?

It isn't in FreeBSD because of the need to link mutex'es into
the "witness protection program".  8-).

> > Yeah, I understand the "witness" crap (if it's there); that
> > doesn't make it any less annoying.
> >
> > Actually, a linker set (not a SYSINIT) could fix that... you
> > would still need one sysinit to do the linkage of the statically
> > declared structures, but it's at least doable.
> a SYSINIT just is a linker set, and there is a convenience SYSINIT
> MTX_SYSINIT() or what not that just registers a sysinit to initialize
> a mutex.

What you want to do is implement a:


This would implicitly add the mutex into the limker set containing
the addresses of statically declared mutex'es.

The SYSINIT()'s purpose would be to traverse this linker set,
calling the moral equivalent of "mutex_init" on each one of them.

You could do this with a SYSINIT(), as has been suggested, but
that would add a relatively large per mutex overhead for each
one you want to declare, since you'd basically be repeating the
common components for doing the job for each and every mutex,
instead of sharing them.

Technically, some later programmer could come along and recover
the linker set memory, actually, since it's only used once, for
the traversal, at kernel startup.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to