From owner-freebsd-drivers@FreeBSD.ORG Mon Oct 3 17:46:29 2011 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A8451065676 for ; Mon, 3 Oct 2011 17:46:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 433128FC16 for ; Mon, 3 Oct 2011 17:46:29 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id D93DB46B06; Mon, 3 Oct 2011 13:46:28 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 76F878A02F; Mon, 3 Oct 2011 13:46:28 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Mon, 3 Oct 2011 13:21:13 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110617; KDE/4.5.5; amd64; ; ) References: <1317047852252-4841580.post@n5.nabble.com> In-Reply-To: <1317047852252-4841580.post@n5.nabble.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201110031321.14112.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 03 Oct 2011 13:46:28 -0400 (EDT) Cc: satish kondapalli Subject: Re: one question on mutex. X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Oct 2011 17:46:29 -0000 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