Mohamed Horani
Mohamed Horani

Reputation: 554

Process runtime in kernel space

I'm trying to get the runtime of a given process in kernel space or user space. Anyway here is what i'm trying to do...

//suppose struct task_struct *task has a direct link to pid 1
cputime_t ktime = task->cputime_expires.stime;
cputime_t utime = task->cputime_expires.utime;
cputime_t total = ktime + utime;
printk(KERN_INFO "TOTAL [%lu]",total); // 0 

why the output is zero ?

Upvotes: 0

Views: 763

Answers (1)

Nithin
Nithin

Reputation: 191

We'll get process runtime from task->utime, task->stime, etc.

Check function account_process_tick() source.

The one you have mentioned i.e task->cputime_expires is used for timer_settime() system call to arm a POSIX per-process timer.

Upvotes: 2

Related Questions