You are not logged in.

#1 2010-05-10 09:13:26

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Change CPU clock when idle

Ok, so what I'm interested in is automatically changing the cpu clock after <n> minutes and putting the clock back to "performance" governor when the mouse or keyboard is touched. Yes, I have tried the cpufrequtils and its ondemand governor with p4-clockmod (Celeron M inside) and it works ok, but not the way I want it. It is dynamic, but it's too fast. It changes clock immediately. What I want is to be able to automatically change it after 30mins, and put it back on to 1700MHz when the mouse or keyboard activity is present. So that's something like a screensaver from xset.

I would want it to execute this after <n> minutes:

echo <some_cpu_clock> > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

(p4-clockmod will already be loaded at boot)

Any ideas? smile

Last edited by archman-cro (2010-05-10 16:09:18)

Offline

#2 2010-05-10 10:34:04

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Change CPU clock when idle

To implement this in a clean way you'll have to use X's idle time - but it probably won't be fun.

May I ask how ondemand reducing the frequency when there is no load presents a problem?
What exactly is your use case?

Offline

#3 2010-05-10 11:10:26

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Change CPU clock when idle

Ondemand is a problem for me cause when I stop working something, it automatically in a second drops the clock to the minimum, and when I want to do something after 10 seconds or so, I experience a slowdown when the clock is "rasing up", so that governor isn't really good for me. If you understand what i'm saying... smile
So, basically, I want something "less responsive" in terms of clock changes. Ondemand ones are too prompt for me. smile

Any further ideas about what you mentioned (X)?

Btw, found this code to determine the idle time from xscreensaver, but it only reports 6 ms max, dunno why...

http://coderrr.wordpress.com/2008/04/20 … e-in-unix/

Last edited by archman-cro (2010-05-10 11:32:58)

Offline

#4 2010-05-10 17:00:08

tindzk
Member
Registered: 2010-05-10
Posts: 25
Website

Re: Change CPU clock when idle

@archman-cro:
Actually, the program is alright. The 6 ms is the time that's elapsed between the XScreenSaverQueryInfo() function call key press (the enter after "./idle").

You could include a sleep() to circumvent this issue making the code look like:

#include <X11/extensions/scrnsaver.h>

main() {
  XScreenSaverInfo *info = XScreenSaverAllocInfo();
  Display *display = XOpenDisplay(0);

  sleep(5);

  XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
  printf("%u ms\n", info->idle);
}

Now do the same while waiting the 5 seconds but do not press any keys or move the mouse during that time. It will report ~5000 ms as expected.

Offline

#5 2010-05-10 17:21:43

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: Change CPU clock when idle

My thoughts: cpufreq isn't too fast, it's too *slow*... Can't you set it so that it changes to the desired frequency faster? I know I did that one or two years ago when I used p4-clockmod. You only have to change one value in /sys/devices/system/cpu/cpufreq/cpu0/ or something like that.

Offline

#6 2010-05-10 18:15:10

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Change CPU clock when idle

I don't know. It was too fast on my machine. I was getting slowdowns all the time.

Offline

Board footer

Powered by FluxBB