Skip to contentSkip to conversation

Some ideas about % of CPU for a process

DISCUSSION Diego 4 participants 4 messages Nov 12, 2004

lore
Share & tools
lore

Diego

author
#0 lore raw

Hi,
I´m trying to define a % of cpu for a process, but i don´t have idea
about how i can do it. For example, i said that my process need 40% of CPU during its lifetime, how can i do it in kernel 2.6? Thanks for ideas.

Diego.

#1 lore raw

Hello Diego,

Quoted 4 lines · Diego

I'm trying to define a % of cpu for a process, but i don?t have idea about how i can do it. For example, i said that my process need 40% of CPU during its lifetime, how can i do it in kernel 2.6? Thanks for ideas.

Why don't you 'ps' the process and divide the running time through the starting time?

time
---------------- = average process cpu usage
(now - started))

Yours,

Signature · 3 lines
 Ed Schouten <[email protected]>
 Website: http://g-rave.nl/
 GPG key: finger [email protected]
#2 lore raw
Quoted 8 lines · Ed Schouten
Quoted 4 lines · Diego

I'm trying to define a % of cpu for a process, but i don?t have idea about how i can do it. For example, i said that my process need 40% of CPU during its lifetime, how can i do it in kernel 2.6? Thanks for ideas.

Why don't you 'ps' the process and divide the running time through the starting time?

I think he's trying to make a 40% *allotment* - as in "this number cruncher is authorized to take 40% of the CPU for the next 6 hours". The devil always ends up being in the details however - things I've seen scheduling systems fail with in the past:

1) Process is allowed to take 40% of the CPU, but so overcommits memory that it can't actually *get* it because 65% of the time, the system is in a page wait from the swap partition. (iterate across any *other* shared resource that isn't directly tied to CPU).

2) Process is allowed to take 40% of the CPU, and no more - and somebody gets torqued off because the system is 60% idle.

3) Process is allowed to take 40% at all times, and more if available - and somebody gets torqued off because it's slow to notice the system has bogged down - so it's still getting 60% for another 2-3 minutes when we're loaded before the scheduler catches up.

4) And you always get the whiner who complains it's getting 39% or 41%. ;)

Saying "40% of the CPU" is easy - the fun is in the corner cases...

#3 lore raw
In reply to Diego
Quoted 4 lines · Diego

Hi,
I´m trying to define a % of cpu for a process, but i don´t have idea
about how i can do it. For example, i said that my process need 40% of CPU during its lifetime, how can i do it in kernel 2.6?

Take a look at CKRM.

Chris