Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Oct 2011 13:21:13 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-drivers@freebsd.org
Cc:        satish kondapalli <nitw.satish@gmail.com>
Subject:   Re: one question on mutex.
Message-ID:  <201110031321.14112.jhb@freebsd.org>
In-Reply-To: <1317047852252-4841580.post@n5.nabble.com>
References:  <1317047852252-4841580.post@n5.nabble.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, September 26, 2011 10:37:32 am satish kondapalli wrote:
> I declared one test mutex  in my char module:
> struct mtx test_mutex;
> 
> Initialized the above mutex while module loading:
> mtx_init(&test_mutex,"cdev_test_mutex",NULL,MTX_DEF);
> 
> and in charter device open() function I called mtx_lock() twice. 
> mtx_lock(&test_mutex);
> mtx_lock(&test_mutex);
> 
> Here my question is why the kernel is not blocking on second call of
> mtx_lock() ?
> Here i initilaized my mutex type as MTX_DEF. All default MTX_DEF are
> recursive? (then what is MTX_RECURSE ).

If you have INVARIANTS on, it will panic if you do not have MTX_RECURSE set.
However, mutexes are all effectively recursive.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110031321.14112.jhb>