]> granicus.if.org Git - procps-ng/commitdiff
library: introduced a 'UTILIZATION_C' item, <pids> api
authorJim Warner <james.warner@comcast.net>
Sun, 6 Mar 2022 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@dropbear.xyz>
Mon, 7 Mar 2022 09:29:06 +0000 (20:29 +1100)
Some items in the <pids> API carry a '_C' suffix which
implies such values include reaped children. So, we'll
now extend this practice to that new UTILIZATION item.

Reference(s):
. Mar, 2022 - tweak PIDS_UTILIZATION
commit 9c0e8e9429d232a85baef3d6fa8269963fd80741
. Feb, 2022 - added PIDS_UTILIZATION
commit c69104b2b835176f9801dfd1a1d893579879a5b6

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/pids.c
proc/pids.h

index e9bae0fa8b9d636661adef29ba65e6c4af217024..77e4deeae7f30acc628457a2feead262fb42cf61 100644 (file)
@@ -287,6 +287,7 @@ REG_set(TTY,              s_int,   tty)
 setDECL(TTY_NAME)       { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
 setDECL(TTY_NUMBER)     { char buf[64]; freNAME(str)(R); dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); if (!(R->result.str = strdup(buf))) I->seterr = 1; }
 setDECL(UTILIZATION)    { double t; if (I->boot_seconds > 0) { t = I->boot_seconds - ((double)P->start_time / I->hertz); if (t > 0) R->result.real = ((P->utime + P->stime) * 100.0f / I->hertz) / t; }}
+setDECL(UTILIZATION_C)  { double t; if (I->boot_seconds > 0) { t = I->boot_seconds - ((double)P->start_time / I->hertz); if (t > 0) R->result.real = ((P->utime + P->stime + P->cutime + P->cstime) * 100.0f / I->hertz) / t; }}
 REG_set(VM_DATA,          ul_int,  vm_data)
 REG_set(VM_EXE,           ul_int,  vm_exe)
 REG_set(VM_LIB,           ul_int,  vm_lib)
@@ -575,6 +576,7 @@ static struct {
     { RS(TTY_NAME),          f_stat,     FF(str),   QS(strvers),   0,        TS(str)     },
     { RS(TTY_NUMBER),        f_stat,     FF(str),   QS(strvers),   0,        TS(str)     },
     { RS(UTILIZATION),       f_stat,     NULL,      QS(real),      0,        TS(real)    },
+    { RS(UTILIZATION_C),     f_stat,     NULL,      QS(real),      0,        TS(real)    },
     { RS(VM_DATA),           f_status,   NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(VM_EXE),            f_status,   NULL,      QS(ul_int),    0,        TS(ul_int)  },
     { RS(VM_LIB),            f_status,   NULL,      QS(ul_int),    0,        TS(ul_int)  },
index 043ec838715bc7c76d86dae43258a4ea0e9a2411..3aa29cc229dc7f5ca749fcf489ab46524b52cf98 100644 (file)
@@ -170,6 +170,7 @@ enum pids_item {
     PIDS_TTY_NAME,          //      str        derived from TTY
     PIDS_TTY_NUMBER,        //      str        derived from TTY as str
     PIDS_UTILIZATION,       //     real        derived from TIME_ALL / TIME_ELAPSED, as percentage
+    PIDS_UTILIZATION_C,     //     real        derived from TIME_ALL_C / TIME_ELAPSED, as percentage
     PIDS_VM_DATA,           //   ul_int        status: VmData
     PIDS_VM_EXE,            //   ul_int        status: VmExe
     PIDS_VM_LIB,            //   ul_int        status: VmLib