Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am looking to get time/jiffie stats on the state of a daemon process. The states I'm referring to are mentioned in the Linux Kernel Proc Filesystem document. Running, Sleeping, uninterruptible sleep, Zombie, Traced/stopped.

Table 1-4 mentions jiffie time counters for user, kernel, user w/childs, and kernel w/childs, but no mention of jiffies in state.

Are there standard counters that track time spent in these states?

Example:

in /proc/[pid]/stat there are user (utime), kernel (stime), and guest(gtime) counters measured in jiffies.

Do process counters exist for time spent in states: [R]unning, [S]leeping, [D]eep sleeping in an uninterruptible wait, [Z]ombie, [T]raced or stopped measured in jiffies?

share|improve this question
    
When you ask if there are standard counters, I'm assuming you mean on a per process basis right? Not just the cpu counter jiffies, in /proc/stat? –  slm Apr 23 '13 at 3:59
    
Not sure if this info helps or not but it seemed relevant to the question: link1 & link2 –  slm Apr 23 '13 at 4:02
    
What exactly do you want to know, and what for? Also note that the zombie state means that the process finished, but the parent hasn't retrieved its exit status yet. It isn't attributable to the process, but to its parent. –  vonbrand Apr 23 '13 at 12:22
add comment

1 Answer

Having though more about my question I think I can answer my question.

[R]unning state is tracked as user mode(utime) and kernel mode(stime) as it requires cycles. Sleep/idle time can (sort of) be calculated by subtracting calculated running time in jiffies from start_time, time process started after reboot. This isn't all that reliable assuming the clock frequency is scaling dynamically.

Jiffies are a non-absolute time unit (a tick) depending on clock interrupt frequency. Jiffies are time spent doing something.

I can not find any counter or epoch date reference of when a process enters a non-running state, or the times a state has changed to said non-running state.

share|improve this answer
    
The counters are in include/linux/sched.h in struct task_struct. They are utime, stime, utimescaled and stimescaled. If kernel is configured for task acct you also have acct_timexpd = stime + utime. You could not find other counters because there aren't any others. The counters are update each clock tick only for the process that was interrupted by the clock tick. Nothing is incremented when a process is swapped out, only the state variables are changed. –  Jonathan Ben-Avraham Apr 24 '13 at 21:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.