Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2003 01:04:26 -0400
From:      Chuck Swiger <cswiger@mac.com>
To:        Anurag Chaudhary <chaudharyanurag@hotmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: nanosleep crashed my kernel
Message-ID:  <3ED6E65A.7000509@mac.com>
In-Reply-To: <Law9-F96AZ829oU9IFh00063276@hotmail.com>
References:  <Law9-F96AZ829oU9IFh00063276@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Anurag Chaudhary wrote:
> I used nanosleep() in my device driver, but it crashed the kernel saying 
> pagefault in kernel mode.
> Can anybody please suggest some other method to be used in a kld to sleep

When you put the kernel to sleep, what were you expecting to wake it up?  :-)

A literal answer would be an interrupt, but in many contexts, such as device 
drivers, tend to block receipt of new interrupts while servicing the existing 
one.  Regardless, there is a critical design methodology involved: you shouldn't 
ever block or busy-wait in the kernel, at least if you can possibly avoid it. 
Look into continuations and performing a context swap to a runnable process 
until the next interrupt happens and your device driver can make more progress.

-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3ED6E65A.7000509>