Date: Sat, 18 May 2002 19:52:36 -0400 (EDT) From: John Baldwin <jhb@FreeBSD.org> To: Terry Lambert <tlambert2@mindspring.com> 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: <XFMail.20020518195236.jhb@FreeBSD.org> In-Reply-To: <3CE6E6A2.4A42228B@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 18-May-2002 Terry Lambert wrote: > John Baldwin wrote: >> On 18-May-2002 Terry Lambert wrote: >> > 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-). >> >> Actually, there is more to it than that. Or at least, there will be >> when turnstiles are added (turnstiles require some function callouts >> to work properly). > > It's the function callouts that are the problem. 8-(. Unfortunately there aren't easy solutions to this. Even solaris 7 uses callouts. We would use fewer of them at least. >> > MUTEX_DECLARE(mutex_name). >> >> Umm, yes, like MTX_SYSINIT(). :) > > No. An MTX_SYSINIT() that wrapped a declaration and a SYSINIT() > would als imply the definition of an static function to do the > initialization, that then got called by the SYSINIT() itself. This is a false implication. > This is actually what I was saying was bad: a static function > per mutex declaration. Umm, no, there is _one_ global function that we call. Why not check the actual code? > So, among other things, you want to use the same initializer function > instance for all statically declared mutexes. Um, we already do this. > So you have to use something other than a SYSINIT() for the declarations, > but you could use *one SYSINIT()* to do the pre-use initialization of > *all* declarations. Why don't you read the code? Here, I'll quote it for you: struct mtx_args { struct mtx *ma_mtx; const char *ma_desc; int ma_opts; }; #define MTX_SYSINIT(name, mtx, desc, opts) \ static struct mtx_args name##_args = { \ mtx, \ desc, \ opts \ }; \ SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ mtx_sysinit, &name##_args) Note no static function, instead we use the global function mtx_sysinit() in kern_mutex.c: /* * General init routine used by the MTX_SYSINIT() macro. */ void mtx_sysinit(void *arg) { struct mtx_args *margs = arg; mtx_init(margs->ma_mtx, margs->ma_desc, NULL, margs->ma_opts); } -- 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-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020518195236.jhb>