dev_lock() question
John Baldwin
jhb at FreeBSD.org
Thu Sep 29 11:07:02 PDT 2005
On Thursday 29 September 2005 01:04 pm, Stanislav Sedov wrote:
> 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().
Actually, you would think that it could be initialized either via an early
SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need
the early check and avoid penalizing dev_lock().
phk, how early his dev_lock needed?
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-hackers
mailing list