Date: Sun, 9 Apr 2017 14:02:07 -0400 From: Ryan Stone <rysto32@gmail.com> To: vasanth sabavat <vasanth.raonaik@gmail.com> Cc: Yubin Ruan <ablacktshirt@gmail.com>, Ed Schouten <ed@nuxi.nl>, "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: Understanding the FreeBSD locking mechanism Message-ID: <CAFMmRNzOypqsBam2BfaFm%2BpX7hSYoEvB2oFtec8OtH6D=s9yTw@mail.gmail.com> In-Reply-To: <CAAuizBiJFkqaEcaHkjP7ZVTgALzVagOopaf9gt3JjbQA3UE02A@mail.gmail.com> References: <e99b6366-7d30-a889-b7db-4a3b3133ff5e@gmail.com> <CABh_MKkbVVi%2BgTkaBVDvVfRggS6pbHKJE_VbYBZpAaTCZ81b7Q@mail.gmail.com> <c72c0ee3-328d-3efc-e8a0-4d6c0d5c8cee@gmail.com> <CAFMmRNwWnaq-4vEDCByqdUzWfoiZeN0nM_M5rt8ST0P8xnUTsA@mail.gmail.com> <CAAuizBiJFkqaEcaHkjP7ZVTgALzVagOopaf9gt3JjbQA3UE02A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 9, 2017 at 12:48 PM, vasanth sabavat <vasanth.raonaik@gmail.com> wrote: > Isn't it true that interrupt handlers instead of running on the current > thread stack now have their own thread? > It depend on what you mean by "interrupt handler" in this context,as that's ambiguous in FreeBSD. Most driver interrupt handling is done through an ithread, which does have its own thread context, and MTX_DEF mutexes are the appropriate locking primitive to use with them. However, it is possible to handle an interrupt through what FreeBSD calls an "interrupt filter", which runs on the kernel stack of whatever thread happened to be running on the CPU, and therefore you must use a spinlock to synchronize with an interrupt. FreeBSD prefers the use of ithreads and MTX_DEF mutexes over filters and spinlocks. Sorry for the use of confusing terminology. I considering referring interrupt filters in my last message, but I figured the term would be unfamiliar to someone not intimately familiar with FreeBSD internals so I decided to avoid it.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNzOypqsBam2BfaFm%2BpX7hSYoEvB2oFtec8OtH6D=s9yTw>