diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-03-31 11:21:24 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-03-31 11:21:24 +0000 |
commit | 11e5516d6756b8594e3e6fcff2e661b6141c5ab7 (patch) | |
tree | 8b7d27bc349e01fc50d57605296265e812b6059f | |
parent | 90fb65f7a60f70fc2c9d072780378286dee2ee85 (diff) | |
download | busybox-w32-11e5516d6756b8594e3e6fcff2e661b6141c5ab7.tar.gz busybox-w32-11e5516d6756b8594e3e6fcff2e661b6141c5ab7.tar.bz2 busybox-w32-11e5516d6756b8594e3e6fcff2e661b6141c5ab7.zip |
Patch from Thomas Winkler showing the the system time for each process
when running 'top'
-rw-r--r-- | patches/top_system_cpu.diff | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/patches/top_system_cpu.diff b/patches/top_system_cpu.diff new file mode 100644 index 000000000..5d213e76a --- /dev/null +++ b/patches/top_system_cpu.diff | |||
@@ -0,0 +1,51 @@ | |||
1 | diff -purN busybox.ori/include/libbb.h busybox/include/libbb.h | ||
2 | --- busybox.ori/include/libbb.h 2004-03-21 14:39:35.000000000 +0100 | ||
3 | +++ busybox-1.0/include/libbb.h 2004-03-21 14:45:35.000000000 +0100 | ||
4 | @@ -447,6 +447,7 @@ typedef struct { | ||
5 | int ppid; | ||
6 | #ifdef FEATURE_CPU_USAGE_PERCENTAGE | ||
7 | unsigned pcpu; | ||
8 | + unsigned pscpu; | ||
9 | unsigned long stime, utime; | ||
10 | #endif | ||
11 | char *cmd; | ||
12 | diff -purN busybox.ori/procps/top.c busybox/procps/top.c | ||
13 | --- busybox.ori/procps/top.c 2004-03-21 14:40:09.000000000 +0100 | ||
14 | +++ busybox-1.0/procps/top.c 2004-03-21 17:27:52.961951448 +0100 | ||
15 | @@ -289,6 +289,15 @@ static void do_stats(void) | ||
16 | i = 999; | ||
17 | cur->pcpu = i; | ||
18 | |||
19 | + /* | ||
20 | + * Calculate percent of system time from cpu time | ||
21 | + */ | ||
22 | + if (systime != 0) { | ||
23 | + cur->pscpu = 100 * total_time / systime; | ||
24 | + } else { | ||
25 | + cur->pscpu = 0; | ||
26 | + } | ||
27 | + | ||
28 | } | ||
29 | |||
30 | /* | ||
31 | @@ -393,7 +402,7 @@ static void display_status(int count, in | ||
32 | |||
33 | #ifdef FEATURE_CPU_USAGE_PERCENTAGE | ||
34 | /* what info of the processes is shown */ | ||
35 | - printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n"); | ||
36 | + printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%SCPU %%MEM COMMAND\e[0m\n"); | ||
37 | #else | ||
38 | printf("\n\e[7m PID USER STATUS RSS PPID %%MEM COMMAND\e[0m\n"); | ||
39 | #endif | ||
40 | @@ -410,9 +419,9 @@ static void display_status(int count, in | ||
41 | else | ||
42 | sprintf(rss_str_buf, "%7ld", s->rss); | ||
43 | #ifdef FEATURE_CPU_USAGE_PERCENTAGE | ||
44 | - printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ", | ||
45 | + printf("%5d %-8s %s %s %5d %2d.%d %2d.%d %2u.%u ", | ||
46 | s->pid, s->user, s->state, rss_str_buf, s->ppid, | ||
47 | - s->pcpu/10, s->pcpu%10, pmem/10, pmem%10); | ||
48 | + s->pcpu/10, s->pcpu%10,s->pscpu/10, s->pscpu%10, pmem/10, pmem%10); | ||
49 | #else | ||
50 | printf("%5d %-8s %s %s %5d %2u.%u ", | ||
51 | s->pid, s->user, s->state, rss_str_buf, s->ppid, | ||