Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Jan 2001 23:12:18 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.ORG>
To:        Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   RE: mtx_destroy() and MTX_COLD
Message-ID:  <XFMail.010104231218.jhb@FreeBSD.org>
In-Reply-To: <200101050658.PAA11958@zodiac.mech.utsunomiya-u.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help

On 05-Jan-01 Kazutaka YOKOTA wrote:
> In order to declare a mutex which will be used before malloc(9)
> becomes available in the kernel, MUTEX_DECLARE() should be used, then
> it should be initialized by passing the MTX_COLD flag to mtx_init(),
> so that a statically allocated buffer will be used, instead of
> malloc()ing a buffer, right?

Yes.

> Will it be safe to call mtx_destroy() for this mutex? 
> /sys/kern/kern_mutex.c:mtx_destroy() seems to always try to free() the
> buffer...

No, the assumption is that anything that comes before malloc is so critical
that it won't be destroyed, and thus one shouldn't have to worry about this. 
If you have a mutex that is used before malloc() and needs to be destroy'd
(doing so won't free any memory, the mutex is already statically allocated)
then mtx_destroy() could be taught to handle MTX_COLD being passed in, but I'd
be surprised that such a mutex exists..

> Kazu

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.Baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


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?XFMail.010104231218.jhb>