From owner-freebsd-current Thu Jan 4 23:12:44 2001 From owner-freebsd-current@FreeBSD.ORG Thu Jan 4 23:12:42 2001 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 1017B37B400 for ; Thu, 4 Jan 2001 23:12:42 -0800 (PST) Received: from foo.osd.bsdi.com (root@foo.osd.bsdi.com [204.216.28.137]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f057COm71417; Thu, 4 Jan 2001 23:12:24 -0800 (PST) (envelope-from jhb@foo.osd.bsdi.com) Received: (from jhb@localhost) by foo.osd.bsdi.com (8.11.1/8.11.0) id f057CIv66169; Thu, 4 Jan 2001 23:12:18 -0800 (PST) (envelope-from jhb) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200101050658.PAA11958@zodiac.mech.utsunomiya-u.ac.jp> Date: Thu, 04 Jan 2001 23:12:18 -0800 (PST) Organization: BSD, Inc. From: John Baldwin To: Kazutaka YOKOTA Subject: RE: mtx_destroy() and MTX_COLD Cc: freebsd-current@FreeBSD.ORG Sender: jhb@foo.osd.bsdi.com Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 -- 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