title: how to determine if process is idle in C
body: <p>How can I know that a process is being idle ?</p>
  
  <p>Let say my program spawns n number of processes, I would like to know if any of them are sitting idle so I can ask them to do additional work,
  but the problem is how to determine if a process was idle during its allocated time slice.</p>
  
  <p>I can find cpu utilization ((total time - idle time)/ total time) across the system but don't know how can I get it for a process. </p>
  
  <p>Since (correct me if I am wrong) a process if idle in a time slice, would voluntarily give up the remaining cpu time so getting cpu time for that process is no good.</p>
  
  <p>A possible solution could be to see if voluntary context switches count increased (lets say over a threshold) but I have to work with kernel lower than 2.6.23 so reading /proc/pid/status for voluntary_context_switches &amp; nonvoluntary_context_switches is not an option for me...</p>
  
  <p>Any suggestions... </p>
  
  <p>NOTE:
  The example that I gave above is an over simplification. IPC is not an option. The process on a particular call should be able to determine if it was sitting idle. Tracking this at all the places where the process spends time is not feasible.</p>
  
  <p>Bottom line, I want to look at some kernel stat to determine if this particular process was sitting and do some stuff based on this info. </p>