How to detect whether CPU is idle?

How to detect whether CPU is idle?

Post by Ben » Sat, 29 Jan 2000 04:00:00



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

 
 
 

How to detect whether CPU is idle?

Post by fv » Sat, 29 Jan 2000 04:00:00



>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).

--

                        Frank v Waveren

                        ICQ# 10074100

 
 
 

How to detect whether CPU is idle?

Post by r.. » Sun, 30 Jan 2000 04:00:00


: 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.

--

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 ---

 
 
 

How to detect whether CPU is idle?

Post by Peter Samuels » Sun, 30 Jan 2000 04:00:00



Quote:> 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

 
 
 

How to detect whether CPU is idle?

Post by Juergen Hein » Mon, 31 Jan 2000 04:00:00




>>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     : Jrgen Heinzl                 \       no flames      /

 
 
 

How to detect whether CPU is idle?

Post by fv » Mon, 31 Jan 2000 04:00:00



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

Oh, my bad. sorry.

--

                        Frank v Waveren

                        ICQ# 10074100

 
 
 

1. kapm-idled shows 90+% cpu usage when idle

Do you have CONFIG_APM_CPU_IDLE=y in your .config? If so, disable it.

There was a thread about this problem some months ago. I found
that on all of my APM-capable machines, including a Dell laptop,
CONFIG_APM_CPU_IDLE=y had a negative effect. The kernel ended up
in a tight loop performing tons of APM IDLE BIOS calls, since each
BIOS call returned immediately without having idled the CPU.

Leaving CONFIG_APM_CPU_IDLE unset lets the kernel use its own
"HLT when idle" code. On my main development box, idle CPU
temperature dropped >10 degrees C, and kapm-idled now uses 0% CPU.

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Internet Start-Up Opportunity

3. kapm-idled no longer idling CPU?

4. CGI & Perl scripts under Apache

5. Relationship between load average and CPU busy or CPU idle

6. serial problems on my Multia

7. Difference between a LOADed CPU & a non IDLE CPU ???

8. PCI Maestro

9. How can I tell whether I am logging in on console inside .login?

10. Determining whether I am using shared text segments under SVR4

11. How to detect whether a tape is write-protected

12. Detecting whether or not a file is executable

13. does anyone know a good way to detect whether or no a duplicate process is running?