views:

27

answers:

1

Hi,

how can i learn cpu usage percentage of a process in kernel-space?

We are trying to limit cpu usage of a process looking at a field added to task_struct.

Forexample if the field is 10 and the process has already consumed the %10 percent of total timeslice we need to prevent the process from runnning.

thanks

A: 

Your can read the kernel CPU usage of a process from the proc file system (man proc):

/proc/[number]/stat: Status information about the process. This is used by ps(1). It is defined in /usr/src/linux/fs/proc/array.c.

[...]

stime %lu: The number of jiffies that this process has been scheduled in kernel mode.

One jiffy is 1/100 second typically.

Peter G.