readlink(); check bounds
top: add 'system' cpu time to 'kernel', 'idle' and 'user'
This commit is contained in:
@@ -110,7 +110,7 @@ void print_procs(int maxlines,
|
||||
struct mproc *mproc)
|
||||
{
|
||||
int p, nprocs;
|
||||
int idleticks = 0, kernelticks = 0;
|
||||
int idleticks = 0, kernelticks = 0, systemticks = 0, userticks = 0;
|
||||
|
||||
for(p = nprocs = 0; p < PROCS; p++) {
|
||||
if(proc2[p].p_rts_flags & SLOT_FREE)
|
||||
@@ -131,14 +131,19 @@ void print_procs(int maxlines,
|
||||
/* Kernel task time, not counting IDLE */
|
||||
if(proc2[p].p_nr < 0)
|
||||
kernelticks += tick_procs[nprocs].ticks;
|
||||
else if(mproc[proc2[p].p_nr].mp_procgrp == 0)
|
||||
systemticks += tick_procs[nprocs].ticks;
|
||||
else
|
||||
userticks += tick_procs[nprocs].ticks;
|
||||
nprocs++;
|
||||
}
|
||||
|
||||
qsort(tick_procs, nprocs, sizeof(tick_procs[0]), cmp_ticks);
|
||||
|
||||
printf("CPU states: %5.2f%% user, %5.2f%% kernel, %5.2f%% idle\n\n",
|
||||
100.0*(dt-idleticks-kernelticks)/dt,
|
||||
100.0*(kernelticks)/dt,
|
||||
printf("CPU states: %5.2f%% user, %5.2f%% system, %5.2f%% kernel, %5.2f%% idle\n\n",
|
||||
100.0*userticks/dt,
|
||||
100.0*systemticks/dt,
|
||||
100.0*kernelticks/dt,
|
||||
100.0*idleticks/dt);
|
||||
maxlines -= 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user