diff options
author | Richard Braun <rbraun@sceen.net> | 2013-12-30 15:08:29 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-12-30 15:08:29 +0100 |
commit | 19689c97a05e0a10691b671c4c37ca0bf51bdd2b (patch) | |
tree | 87f59068e7ecc833966e3c5c2daa32c6ea09cb80 | |
parent | 3a3fcc811e6b50b21124a5c5a128652e788a3b67 (diff) |
libps: fix process user and system times
Include the run time of terminated threads in the user and system times
of processes.
-rw-r--r-- | libps/procstat.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libps/procstat.c b/libps/procstat.c index e688fa47..e732f751 100644 --- a/libps/procstat.c +++ b/libps/procstat.c @@ -352,6 +352,7 @@ summarize_thread_basic_info (struct procinfo *pi) { int i; unsigned num_threads = 0, num_run_threads = 0; + task_basic_info_t taskinfo = &pi->taskinfo; thread_basic_info_t tbi = malloc (sizeof (struct thread_basic_info)); int run_base_priority = 0, run_cur_priority = 0; int total_base_priority = 0, total_cur_priority = 0; @@ -426,6 +427,12 @@ summarize_thread_basic_info (struct procinfo *pi) } } + /* Include the run time of terminated threads. */ + tbi->user_time.seconds += taskinfo->user_time.seconds; + tbi->user_time.microseconds += taskinfo->user_time.microseconds; + tbi->system_time.seconds += taskinfo->system_time.seconds; + tbi->system_time.microseconds += taskinfo->system_time.microseconds; + tbi->user_time.seconds += tbi->user_time.microseconds / 1000000; tbi->user_time.microseconds %= 1000000; tbi->system_time.seconds += tbi->system_time.microseconds / 1000000; |