Author Topic: Throttling  (Read 758 times)

KernelPanic

  • VIP
  • Member
  • ***
  • Posts: 1,878
  • Kudos: 222
Throttling
« on: 21 January 2003, 21:23 »
No I dont wan't advice on how to strangle annoying people  :D

What I was wondering was, in Linux, is there a way to throttle CPU usage to a certain % load?
Contains scenes of mild peril.

KernelPanic

  • VIP
  • Member
  • ***
  • Posts: 1,878
  • Kudos: 222
Throttling
« Reply #1 on: 21 January 2003, 22:11 »
quote:
Originally posted by X11:
ERROR - QUESTION DEFINITION NEEDS DETAIL
code 451 - do not understand.



I want to be able to limit my system to, for example, 20% CPU load for a period of time. So is there a way to stop the system from using all the resources availiable somehow?
Contains scenes of mild peril.

pkd_lives

  • Member
  • **
  • Posts: 554
  • Kudos: 0
Throttling
« Reply #2 on: 22 January 2003, 00:50 »
I think this technically possible, but I doubt there is code for it because it seems pretty pointless.

Surely it is useless, all it will do is slow down your PC, you are limiting how fast it will process information, that information still uses the whole data bus, and still needs to be processed for your system to run. You could always just really underclock your system, this would achieve the same affect. You could, I suppose configure your system to process in 16 bit mode instead of 32 (or whatever you have), but again this does not seem to have much use.

I really can't see why you would want to do this, unless you are trying to create a test condition for performing stability tests, or something like thermal cycling or noise pick-up.

Are you trying to limit user use of the processor, if so then maybe you should look into process queing, of which I know nothing significant.

Could you eleborate a bit.
Tough - Adapt or die : Read The Fucking Manual.

Local Area Network in Australia: the LAN down under.


Master of Reality

  • VIP
  • Member
  • ***
  • Posts: 4,249
  • Kudos: 177
    • http://www.bobhub.tk
Throttling
« Reply #3 on: 22 January 2003, 00:55 »
ulimit will do it for ya.
"man bash" i think will show details about it.
Disorder | Rating
Paranoid: Moderate
Schizoid: Moderate
Linux User #283518
'It takes more than a self-inflicted gunshot wound to the head to stop Bob'

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Throttling
« Reply #4 on: 22 January 2003, 02:04 »
Well, that's what process priority is supposed to be all about in UNIX/Linux (nice level). With a proper scheduler you can set priorities on processes so that they will give up CPU time to more important processes. However, if there are no other processes of higher priority running at the time then those lower priority processes will get the full CPU time.

See:
$ man renice
$ man nice
Someone please remove this account. Thanks...

KernelPanic

  • VIP
  • Member
  • ***
  • Posts: 1,878
  • Kudos: 222
Throttling
« Reply #5 on: 22 January 2003, 19:58 »
The reason I want to do this is I need some data for some work. To make my life more interesting I am going to gather the following data:

Get a whole bunch of systems with different Processor arch's. Run them at different loads (maybe 20% increments) for a set time period and record the temperature after this time.

It looks like I won't be able to do exactly what I was thinking of so I guess I will have to do something else, maybe survey real people...

Thanks for your help anyway.
Contains scenes of mild peril.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Throttling
« Reply #6 on: 22 January 2003, 22:21 »
Why didn't you say that from the start? I thought you were concerned about certain non-critical programs were taking up too much of the resources during critical times and you wanted to prevent them from doing so.

As per your specific tests you could write a simple C program that does nothing but loop and maybe perform a couple of frivolous calculations. Something that would take up 100% CPU (if you only want to test CPU that is). Then add a delay (usleep()) in the loop. You would actually want your program to take an argument so you could pass it how much delay you want. Varying this delay should vary CPU utilization from 100% down to near 0 depending on how much delay you use. Now I don't know how that would effect CPU temperature if any at all but it would be easy to do.

Would you like me to write something for you?

[ January 22, 2003: Message edited by: void main ]

Someone please remove this account. Thanks...

KernelPanic

  • VIP
  • Member
  • ***
  • Posts: 1,878
  • Kudos: 222
Throttling
« Reply #7 on: 22 January 2003, 22:24 »
quote:
Originally posted by void main:
Why didn't you say that from the start? You could write a simple C program that does nothing but loop and maybe perform a couple of frivolous calculations. Something that would take up 100% CPU (if you only want to test CPU that is). Then add a delay in the loop. You would actually want your program to take an argument so you could pass it how much delay you want. Varying this delay should vary CPU utilization from 100% down to near 0 depending on how much delay you use. Now I don't know how that would effect CPU temperature if any at all but it would be easy to do.

Would you like me to write something for you?

[ January 22, 2003: Message edited by: void main ]



Since I havn't done any C for years that would be great   :D  
But, if you are too busy then feel free to leave it and I will get somebody else to do it or do it myself.

I was hoping to avoid having to write anything.

[ January 22, 2003: Message edited by: Tux ]

Contains scenes of mild peril.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Throttling
« Reply #8 on: 22 January 2003, 23:22 »
Well, so far I haven't had much success. I can get it to use all or none but not in between. So I did a little searching and found this page:

http://weather.ou.edu/~apw/projects/stress/

which looked extremely promising from a set of tools on this page:

http://ltp.sourceforge.net/tooltable.php

What I believe you are after is the combined user/system time to add up to a specific %. Even with this tool I was only able to get either 100 or 0. You might want to play around with it some more though and try various I/O, File, etc operations to see how this effects CPU utilization.

What I was hoping I could do (and think I still can very easily but am missing some critical element) is write a program that takes a parameter from 0 to 100 and loop, periodically checking the combined user/system time and adjusting accordingly. I figured this could be done by combining some tight looping with some waits/delays. I'll try and work on this some more as free time permits. If you find something that works for you let me know...

At least I can make my CPU fan switch on on my laptop.  

[ January 22, 2003: Message edited by: void main ]

Someone please remove this account. Thanks...