Date: Thu, 29 Sep 2005 21:04:25 +0400 From: Stanislav Sedov <stas@310.ru> To: Divacky Roman <xdivac02@stud.fit.vutbr.cz> Cc: hackers@freebsd.org Subject: Re: dev_lock() question Message-ID: <20050929170425.GB3526@core.310.ru> In-Reply-To: <20050929165538.GA20614@stud.fit.vutbr.cz> References: <20050929165538.GA20614@stud.fit.vutbr.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Sep 29, 2005 at 06:55:38PM +0200, Divacky Roman wrote:
> Hi,
>
> dev_lock() looks this way:
>
> void
> dev_lock(void)
> {
> if (!mtx_initialized(&devmtx))
> mtx_init(&devmtx, "cdev", NULL, MTX_DEF);
> mtx_lock(&devmtx);
> }
>
> I wonder why is the mtx_initialized checking necessary? shouldnt explicit
> initialization be sufficient?
>
> thnx for answer
>
> roman
Moving "mtx_initialized()" check into mtx_init will decrease speed of other
mutexes initialization. We must check if it's initialized here because of
it's not permiited to pass already initialized mutex to mtx_init().
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050929170425.GB3526>
