Idle time of a process in Linux

后端 未结 2 1775
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 03:07

I need to calculate CPU usage (user mode, system mode, idle time) of a process in Linux. I am able to calculate usage in user and system mode using utime and

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 03:36

    I don't know much about it but maybe the following works:

    1) Get the process start up time. Im sure thats possible
    2) Generate time difference (dTime = CurrentTime - TimeProcessStarted)
    3) Substract the time the process is running ( dTime - (usageSystemMode + usageUserMode))
    

    Hope this helps! :D

提交回复
热议问题