From owner-freebsd-questions@freebsd.org Tue Jun 13 13:58:46 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FA08BF527F for ; Tue, 13 Jun 2017 13:58:46 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [IPv6:2001:8b0:151:1:c4ea:bd49:619b:6cb3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 110007CDE7 for ; Tue, 13 Jun 2017 13:58:46 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from host-4-75.office.adestra.com (unknown [85.199.232.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id AAA5897E9 for ; Tue, 13 Jun 2017 13:58:43 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/AAA5897E9; dkim=none; dkim-atps=neutral Subject: Re: A question about in lock usage in FreeBSD To: freebsd-questions@freebsd.org References: <593FE1C9.2060706@163.com> From: Matthew Seaman Message-ID: Date: Tue, 13 Jun 2017 14:58:36 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <593FE1C9.2060706@163.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LnjcnolROOmvPJNHrsvLQ27S5Ag51VGOD" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 13:58:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LnjcnolROOmvPJNHrsvLQ27S5Ag51VGOD Content-Type: multipart/mixed; boundary="drxjQBkJ3LOTbqEALV43h8Gsd9aDlD029"; protected-headers="v1" From: Matthew Seaman To: freebsd-questions@freebsd.org Message-ID: Subject: Re: A question about in lock usage in FreeBSD References: <593FE1C9.2060706@163.com> In-Reply-To: <593FE1C9.2060706@163.com> --drxjQBkJ3LOTbqEALV43h8Gsd9aDlD029 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2017/06/13 13:59, Jia-Ju Bai wrote: > I am a freshman in developing FreeBSD drivers, and I have a question in= > lock usage in FreeBSD. >=20 > The kernel provides some kinds of locks in developing drivers, such as > "mutex lock", "mutex spin lock", "rw lock" and "sx lock". I want to kno= w > which locks should be held when the thread can sleep. > From my knowledge of FreeBSD document, I make the following points: > (1) "rw lock" and "sx lock" can be used in this situation; > (2) "mutex lock" and "mutex spin lock" are forbidden in this situation.= >=20 > If my points are right, I will make another point: > mutex_lock will let the thread sleep when the lock is requested, so the= > mutex_lock can not be called in nested style (namely it is unsafe that > mutex_lock is called again when a "mutex lock" is held). >=20 > Are my points are right? > I am looking forward to useful opinions and answers :) Hi, I think you'll get better results if you ask your question on the freebsd-hackers@freebsd.org mailing list. That way it will be seen by people who are familiar with programming drivers and other internals of the kernel and who will know precisely how to answer you. Cheers, Matthew --drxjQBkJ3LOTbqEALV43h8Gsd9aDlD029-- --LnjcnolROOmvPJNHrsvLQ27S5Ag51VGOD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQJ8BAEBCgBmBQJZP++SXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxOUYxNTRFQ0JGMTEyRTUwNTQ0RTNGMzAw MDUxM0YxMEUwQTlFNEU3AAoJEABRPxDgqeTn9ewP/RV9I3msWn1WwTVBbMEn/gr5 u2hzQvTSWNLsmO2xgG1R5EidoIEZMDI+rwjeidmiJXz1P2MtZy45BBYyicohoTjO Vr2SCr/ByxxNK5OjdqQjg8e2IInGdvgNP6trYYRs20YRHrmQN8o6tTZo1dwI+Ypb D442rUheFkuaxVFOB0O3awzrcfgOx6me2a943O2nSyqzps+n3J6enZG2SkEaU56d UTVchJpOij3AlEQ4adDvyxpkn2bzc9H1OIjWDmG3ZfZVMwobQ6u7ssLIOnooOv/+ kL9IaG6AC2xYw0vesm2Ie8kcxtDOotuJqONReoMKm4NONJy3scFe+gbME6M9ZAq1 pi/ElUNLvoQQLdjt3ttFfgxt1H5FVS0TIX2UsZPKULHJXgIzABH7VbQOmaLrKwRw 0JPHS99EhymBlmB6EgHIE/rMKnBGtBYloy+beDnUJhHLgVr8VQ97t8TJIRlFfO/p 4ZyJ+A3Qeu9U2HZzwPNkbNovkaTLAqXo/5/NBJtMFZxcnDN+6B4OOmr9AnwBC104 zRdwornyJCbzcYGvmuP5uCduq3i3cgWXny+jN+idHeMx+6473t03wZ8x6atgAMH8 2xETSExcLpFuTj7ZOqF3LNfdH4WM5TAnaRtCIfMFn5xJm2T5ZXlpPsTzT8BORzNC eovXT+dRef9nDkhEg09j =pTjb -----END PGP SIGNATURE----- --LnjcnolROOmvPJNHrsvLQ27S5Ag51VGOD--