Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 May 2002 16:02:36 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        net@FreeBSD.org, current@FreeBSD.org, "Kenneth D. Merry" <ken@kdm.org>, Alfred Perlstein <bright@mu.org>
Subject:   Re: new zero copy sockets patches available
Message-ID:  <3CE6DD8C.FC95386F@mindspring.com>
References:  <XFMail.20020518090340.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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:

MUTEX_DECLARE(mutex_name).

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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CE6DD8C.FC95386F>