mpslsi0 : Trying sleep, but thread marked as sleeping prohibited

Konstantin Belousov kostikbel at gmail.com
Wed Feb 22 19:16:54 UTC 2012


On Wed, Feb 22, 2012 at 07:36:42PM +0530, Desai, Kashyap wrote:
> Hi,
> 
> I am doing some code changes in mps dirver. While working on those changes, I come to know about something which is new to me.
> Some expert help is required to clarify my doubt.
> 
> 1. When any irq is register with FreeBSD OS, it sets " TDP_NOSLEEPING" pflag. It means though irq in freebsd is treated as thread,
> We cannot sleep in IRQ because of " "TDP_NOSLEEPING " set.
> 2. In mps driver we have below code snippet in ISR routine.
> 
> 
>     mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
>     mps_lock(sc);
>     mps_intr_locked(data);
>     mps_unlock(sc);
> 
> I wonder why there is no issue with above code ? Theoretical we cannot sleep in ISR. (as explained in #1)
> Any thoughts ?
> 
> 
> 3. I recently added few place msleep() instead of DELAY in ISR context and I see 
> " Trying sleep, but thread marked as sleeping prohibited".
> 
FreeBSD has several basic ways to prevent a thread from executing on CPU.
They mostly fall into two categories: bounded sleep, sometimes called
blocking, and unbounded sleep, usually abbreviated as sleep. The bounded
there refers to amount of code executed by other thread that hold resource
preventing blocked thread from making a progress.

Examples of the blocking primitives are mutexes, rw locks and rm locks.
The blocking is not counted as sleeping, so interrupt threads, which are
designated as non-sleeping, still can lock mutexes.

Examples of the sleeping primitives are msleep(), sx locks, lockmgr locks
and conditional variables.

In essence, the locking facilities are split into several classes that
form the hierarchy, and you cannot legally obtain the lock of higher class
while holding a lock of lower class:
	spin mutexes -> blocking locks -> sleeping locks.
It establishes some meta-order on the all locks.

Does this make sense ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20120222/82938dad/attachment.pgp


More information about the freebsd-stable mailing list