Date: Sat, 03 Feb 2007 23:57:22 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: luping.nju@gmail.com Cc: freebsd-hackers@freebsd.org Subject: Re: "sleep" in freebsd kernel Message-ID: <20070203.235722.1973608952.imp@bsdimp.com> In-Reply-To: <e80b0eb70702031854n57d81f6ar8b7f46be9d34d1a8@mail.gmail.com> References: <e80b0eb70702031854n57d81f6ar8b7f46be9d34d1a8@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <e80b0eb70702031854n57d81f6ar8b7f46be9d34d1a8@mail.gmail.com> "lu ping" <luping.nju@gmail.com> writes: : I have a kernel thread running as a daemon, and I want to make it sleep for : a while in an infinite loop. I guess I can use "tsleep" but it only timeout : after intergal system ticks, which only has millisecond granularity, but I : want to make it sleep in some microsecond. Is there any way I can do this in : the kernel? Make HZ=10000 and you get 100us timeouts. :-) However, there are issues with that... There's presently no easy way to sleep for microseconds without some kind of hardware assist. Maybe the daemon you are running can access custom hardware, which you could use to schedule your interrupt in the near future. There is DELAY which will delay things by a number of microseconds, but it isn't that useful if you are doing it a lot because it is a busy wait, not a scheduling event. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070203.235722.1973608952.imp>