How to detect whether CPU is idle?

0 views
Skip to first unread message

Ben

unread,
Jan 28, 2000, 3:00:00 AM1/28/00
to
Hi,there,
I am starting a device driver which will layer on top of the current
disk deivce drivers.When the CPU is idle,my driver will wake up otherwise it
will keep sleeping.So I need an API/function to detect the CPU is idle or
not from my driver code.Anyone can give some hints?Thanks in advance.

---Ben


fvw

unread,
Jan 28, 2000, 3:00:00 AM1/28/00
to

Leave the scheduling to the system. Just go to nice +19, that way you'll only
get cpu time when the cpu is idle (well, not completely true, but the little
non-idle cpu time you get is negligable).

--

Frank v Waveren
f...@var.cx
ICQ# 10074100

ri...@no-annexia-spam.org

unread,
Jan 29, 2000, 3:00:00 AM1/29/00
to
Ben <benlin...@yahoo.com> wrote:
: Hi,there,
: I am starting a device driver which will layer on top of the current
: disk deivce drivers.When the CPU is idle,my driver will wake up otherwise it
: will keep sleeping.So I need an API/function to detect the CPU is idle or
: not from my driver code.Anyone can give some hints?Thanks in advance.

Why do you want to do this? If you have some background
processing it to do, it might be better to do it in
a daemon in userspace.

Rich.

--
ri...@annexia.org | Free email for life at: http://www.postmaster.co.uk/
BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG.
+44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/
--- Original message content Copyright © 1999 Richard Jones ---

Peter Samuelson

unread,
Jan 29, 2000, 3:00:00 AM1/29/00
to
[Juergen Heinzl <jue...@monocerus.demon.co.uk>]
> It is a driver .. good luck with trying to re-nice a kernel driver.

That is what kernel threads are for. So that you can play with the
process context state of what is otherwise just a driver.

Peter

Juergen Heinzl

unread,
Jan 30, 2000, 3:00:00 AM1/30/00
to
In article <94909499...@var.cx>, fvw wrote:

>In <86sh8q$koj$1...@ron.uri.edu>, benlin...@yahoo.com wrote:
>>Hi,there,
>> I am starting a device driver which will layer on top of the current
>>disk deivce drivers.When the CPU is idle,my driver will wake up otherwise it
>>will keep sleeping.So I need an API/function to detect the CPU is idle or
>>not from my driver code.Anyone can give some hints?Thanks in advance.
>
>Leave the scheduling to the system. Just go to nice +19, that way you'll only
>get cpu time when the cpu is idle (well, not completely true, but the little
>non-idle cpu time you get is negligable).

It is a driver .. good luck with trying to re-nice a kernel driver.

You might start here ...
/usr/src/linux/init/main.c
... as there is an idle thread and take a look into the scheduler
code too. AFAIK though there cannot even be a API function as the
kernel is using the HALT instruction so your best bet might be
a 08/15 driver.

I am not going to ask why you want to do that, hope this is okay ;)
Juergen

--
\ Real name : Jürgen Heinzl \ no flames /
\ EMail Private : jue...@monocerus.demon.co.uk \ send money instead /

fvw

unread,
Jan 30, 2000, 3:00:00 AM1/30/00
to
In <slrn8972i1...@monocerus.demon.co.uk>, jue...@monocerus.demon.co.uk wrote:
>It is a driver .. good luck with trying to re-nice a kernel driver.

Oh, my bad. sorry.

Reply all
Reply to author
Forward
0 new messages