From owner-freebsd-scsi@FreeBSD.ORG Thu Feb 23 02:14:29 2012 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F259106564A; Thu, 23 Feb 2012 02:14:29 +0000 (UTC) (envelope-from Kashyap.Desai@lsi.com) Received: from na3sys009aog119.obsmtp.com (na3sys009aog119.obsmtp.com [74.125.149.246]) by mx1.freebsd.org (Postfix) with ESMTP id 8E3E28FC0C; Thu, 23 Feb 2012 02:14:28 +0000 (UTC) Received: from paledge01.lsi.com ([192.19.193.42]) (using TLSv1) by na3sys009aob119.postini.com ([74.125.148.12]) with SMTP ID DSNKT0WhA8nu2WfPrFJ2KyTSxqqVWE9HEGHw@postini.com; Wed, 22 Feb 2012 18:14:28 PST Received: from PALCAS01.lsi.com (128.94.213.117) by PALEDGE01.lsi.com (192.19.193.42) with Microsoft SMTP Server (TLS) id 8.3.213.0; Wed, 22 Feb 2012 21:19:14 -0500 Received: from inbexch01.lsi.com (135.36.98.37) by PALCAS01.lsi.com (128.94.213.117) with Microsoft SMTP Server (TLS) id 8.3.213.0; Wed, 22 Feb 2012 21:14:26 -0500 Received: from inbmail01.lsi.com ([135.36.98.64]) by inbexch01.lsi.com ([135.36.98.37]) with mapi; Thu, 23 Feb 2012 07:44:23 +0530 From: "Desai, Kashyap" To: Chuck Swiger Date: Thu, 23 Feb 2012 07:44:21 +0530 Thread-Topic: mpslsi0 : Trying sleep, but thread marked as sleeping prohibited Thread-Index: AczxxToJrFdKBW0ORNyNsEGs5tS+qgACqMjw Message-ID: References: <20120222191519.GT55074@deviant.kiev.zoral.com.ua> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "freebsd-scsi@freebsd.org" , freebsd-stable , "McConnell, Stephen" Subject: RE: mpslsi0 : Trying sleep, but thread marked as sleeping prohibited X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 02:14:29 -0000 > -----Original Message----- > From: Chuck Swiger [mailto:cswiger@mac.com] > Sent: Thursday, February 23, 2012 6:21 AM > To: Desai, Kashyap > Cc: freebsd-scsi@freebsd.org; freebsd-stable; McConnell, Stephen > Subject: Re: mpslsi0 : Trying sleep, but thread marked as sleeping > prohibited >=20 > On Feb 22, 2012, at 4:22 PM, Desai, Kashyap wrote: > > Just curious to know, What is a reason that thread can do blocking > sleep but can't do unbounded sleep ? >=20 > When you block, the scheduler can run other threads and only needs to > wake up and run your thread after the blocking condition is completed. >=20 > However, you don't want to busy-wait in a spin lock/mutex for any > lengthy period of time. If your thread was allowed to do an unbounded > sleep, especially in a fast interrupt handler context, what's going to > wake it up? An NMI like the reset button [1]? :-) When I started working on freebsd, first thing I noticed was ISR in freebsd= are thread. (special thread). But at least not like linux where we don't h= ave pid associate with ISR. So In Freebsd we will have thread id for related isr routine. Consider that fact, Even in fast interrupts handler context we should be ab= le to sleep. (e.a pause("mps_pause", (hz/1000));) Schedule can put thread into wait_queue and eventually when wait condition = meet, thread will be wake by OS. I mean if we can sleep in fast interrupt handler using mtx_ call, why not m= sleep/pause ? Sorry if I am extending this conversation. I really appreciate kind of help= from freebsd forum.! ` Kashyap >=20 > Regards, > -- > -Chuck >=20 > [1]: Well, you could also call STI to permit clock interrupts or > something else to fire an interrupt, but then your interrupt handler > needs to be re-entrant. (And watch out for multiple nested interrupts > blowing out the available stack space....)