Date: Tue, 13 Jun 2017 14:58:36 +0100 From: Matthew Seaman <matthew@FreeBSD.org> To: freebsd-questions@freebsd.org Subject: Re: A question about in lock usage in FreeBSD Message-ID: <f55f3cd9-9916-b5c0-bd9e-5c6358a97f9f@FreeBSD.org> In-Reply-To: <593FE1C9.2060706@163.com> References: <593FE1C9.2060706@163.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LnjcnolROOmvPJNHrsvLQ27S5Ag51VGOD Content-Type: multipart/mixed; boundary="drxjQBkJ3LOTbqEALV43h8Gsd9aDlD029"; protected-headers="v1" From: Matthew Seaman <matthew@FreeBSD.org> To: freebsd-questions@freebsd.org Message-ID: <f55f3cd9-9916-b5c0-bd9e-5c6358a97f9f@FreeBSD.org> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f55f3cd9-9916-b5c0-bd9e-5c6358a97f9f>