Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:WernerFink:branches:Base:System
procps
procps-ng-4.0.0-accuracy.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File procps-ng-4.0.0-accuracy.dif of Package procps
--- proc/pids.c | 18 +++++++++++++++--- proc/pids.h | 1 + ps/common.h | 3 +++ ps/display.c | 1 + ps/global.c | 1 + ps/output.c | 18 +++++++++--------- 6 files changed, 30 insertions(+), 12 deletions(-) --- proc/pids.c +++ proc/pids.c 2022-03-30 08:53:15.180093896 +0000 @@ -92,6 +92,7 @@ struct pids_info { PROCTAB *fetch_PT; // oldlib interface for 'select' & 'reap' unsigned long hertz; // for the 'TIME' & 'UTILIZATION' calculations double boot_seconds; // for TIME_ELAPSED & 'UTILIZATION' calculations + unsigned long long boot_tics; // for TIME_ELAPSED & 'UTILIZATION' calculations PROCTAB *get_PT; // oldlib interface for active 'get' struct stacks_extent *get_ext; // for active 'get' (also within 'extents') enum pids_fetch_type get_type; // last known type of 'get' request @@ -282,6 +283,7 @@ setDECL(TICS_USER_C) { (void)I; R->re setDECL(TIME_ALL) { R->result.real = ((double)P->utime + P->stime) / I->hertz; } setDECL(TIME_ALL_C) { R->result.real = ((double)P->utime + P->stime + P->cutime + P->cstime) / I->hertz; } setDECL(TIME_ELAPSED) { double t = (double)P->start_time / I->hertz; R->result.real = I->boot_seconds > t ? I->boot_seconds - t : 0; } +setDECL(TICS_ELAPSED) { R->result.ull_int = I->boot_tics >= P->start_time ? I->boot_tics - P->start_time : 0; } setDECL(TIME_START) { R->result.real = (double)P->start_time / I->hertz; } 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; } @@ -571,6 +573,7 @@ static struct { { RS(TIME_ALL), f_stat, NULL, QS(real), 0, TS(real) }, { RS(TIME_ALL_C), f_stat, NULL, QS(real), 0, TS(real) }, { RS(TIME_ELAPSED), f_stat, NULL, QS(real), 0, TS(real) }, + { RS(TICS_ELAPSED), f_stat, NULL, QS(ull_int), 0, TS(ull_int) }, { RS(TIME_START), f_stat, NULL, QS(real), 0, TS(real) }, { RS(TTY), f_stat, NULL, QS(s_int), 0, TS(s_int) }, { RS(TTY_NAME), f_stat, FF(str), QS(strvers), 0, TS(str) }, @@ -1441,8 +1444,11 @@ fresh_start: /* when in a namespace with proc mounted subset=pid, we will be restricted to process information only */ info->boot_seconds = 0; - if (0 >= procps_uptime(&up_secs, NULL)) + info->boot_tics = 0; + if (0 >= procps_uptime(&up_secs, NULL)) { info->boot_seconds = up_secs; + info->boot_tics = up_secs * info->hertz; + } if (NULL == info->read_something(info->get_PT, &info->get_proc)) return NULL; @@ -1484,8 +1490,11 @@ PROCPS_EXPORT struct pids_fetch *procps_ /* when in a namespace with proc mounted subset=pid, we will be restricted to process information only */ info->boot_seconds = 0; - if (0 >= procps_uptime(&up_secs, NULL)) + info->boot_tics = 0; + if (0 >= procps_uptime(&up_secs, NULL)) { info->boot_seconds = up_secs; + info->boot_tics = up_secs * info->hertz; + } rc = pids_stacks_fetch(info); @@ -1589,8 +1598,11 @@ PROCPS_EXPORT struct pids_fetch *procps_ /* when in a namespace with proc mounted subset=pid, we will be restricted to process information only */ info->boot_seconds = 0; - if (0 >= procps_uptime(&up_secs, NULL)) + info->boot_tics = 0; + if (0 >= procps_uptime(&up_secs, NULL)) { info->boot_seconds = up_secs; + info->boot_tics = up_secs * info->hertz; + } rc = pids_stacks_fetch(info); --- proc/pids.h +++ proc/pids.h 2022-03-30 08:53:15.180093896 +0000 @@ -165,6 +165,7 @@ enum pids_item { PIDS_TIME_ALL, // real derived from stat: (utime + stime) / hertz PIDS_TIME_ALL_C, // real derived from stat: (utime + stime + cutime + cstime) / hertz PIDS_TIME_ELAPSED, // real derived from /proc/uptime - (starttime / hertz) + PIDS_TICS_ELAPSED, // ull_int derived from /proc/uptime - starttime PIDS_TIME_START, // real derived from stat: start_time / hertz PIDS_TTY, // s_int stat: tty_nr PIDS_TTY_NAME, // str derived from TTY --- ps/common.h +++ ps/common.h 2022-03-30 08:53:15.180093896 +0000 @@ -42,6 +42,8 @@ #define namREL(e) rel_ ## e #define makEXT(e) extern int namREL(e); #define makREL(e) int namREL(e) = -1; +#define makEXTULL(e) extern unsigned long long namREL(e); +#define makRELULL(e) unsigned long long namREL(e) = -1; #define chkREL(e) if (namREL(e) < 0) { \ Pids_items[Pids_index] = PIDS_ ## e; \ namREL(e) = (Pids_index < PIDSITEMS) ? Pids_index++ : rel_noop; } @@ -160,6 +162,7 @@ makEXT(TICS_ALL) makEXT(TICS_ALL_C) makEXT(TIME_ALL) makEXT(TIME_ELAPSED) +makEXT(TICS_ELAPSED) makEXT(TICS_BEGAN) makEXT(TTY) makEXT(TTY_NAME) --- ps/display.c +++ ps/display.c 2022-03-30 08:54:22.410871769 +0000 @@ -584,6 +584,7 @@ static void finalize_stacks (void) chkREL(TICS_ALL_C) chkREL(TIME_ALL) chkREL(TIME_ELAPSED) + chkREL(TICS_ELAPSED) chkREL(TICS_BEGAN) // special items with 'extra' used as former pcpu chkREL(extra) --- ps/global.c +++ ps/global.c 2022-03-30 08:53:15.180093896 +0000 @@ -141,6 +141,7 @@ makREL(TICS_ALL) makREL(TICS_ALL_C) makREL(TIME_ALL) makREL(TIME_ELAPSED) +makREL(TICS_ELAPSED) makREL(TICS_BEGAN) makREL(TTY) makREL(TTY_NAME) --- ps/output.c +++ ps/output.c 2022-03-30 08:53:15.180093896 +0000 @@ -517,13 +517,13 @@ setREL1(TIME_ELAPSED) static int pr_c(char *restrict const outbuf, const proc_t *restrict const pp){ unsigned long long total_time; /* jiffies used by this process */ unsigned pcpu; /* scaled %cpu, 99 means 99% */ - unsigned long long seconds; /* seconds of process life */ + unsigned long long jiffies; /* jiffies of process life */ setREL4(TICS_ALL,TICS_ALL_C,TIME_ELAPSED,UTILIZATION) pcpu = 0; if(include_dead_children) total_time = rSv(TICS_ALL_C, ull_int, pp); else total_time = rSv(TICS_ALL, ull_int, pp); - seconds = rSv(TIME_ELAPSED, real, pp); - if(seconds) pcpu = (total_time * 100ULL / Hertz) / seconds; + jiffies = rSv(TICS_ELAPSED, ull_int, pp); + if(jiffies) pcpu = (total_time * 100ULL) / jiffies; if (pcpu > 99U) pcpu = 99U; return snprintf(outbuf, COLWID, "%2u", pcpu); } @@ -532,13 +532,13 @@ setREL4(TICS_ALL,TICS_ALL_C,TIME_ELAPSED static int pr_pcpu(char *restrict const outbuf, const proc_t *restrict const pp){ unsigned long long total_time; /* jiffies used by this process */ unsigned pcpu; /* scaled %cpu, 999 means 99.9% */ - unsigned long long seconds; /* seconds of process life */ + unsigned long long jiffies; /* jiffies of process life */ setREL4(TICS_ALL,TICS_ALL_C,TIME_ELAPSED,UTILIZATION) pcpu = 0; if(include_dead_children) total_time = rSv(TICS_ALL_C, ull_int, pp); else total_time = rSv(TICS_ALL, ull_int, pp); - seconds = rSv(TIME_ELAPSED, real, pp); - if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds; + jiffies = rSv(TICS_ELAPSED, ull_int, pp); + if(jiffies) pcpu = (total_time * 1000ULL) / jiffies; if (pcpu > 999U) return snprintf(outbuf, COLWID, "%u", pcpu/10U); return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U); @@ -548,13 +548,13 @@ setREL4(TICS_ALL,TICS_ALL_C,TIME_ELAPSED static int pr_cp(char *restrict const outbuf, const proc_t *restrict const pp){ unsigned long long total_time; /* jiffies used by this process */ unsigned pcpu; /* scaled %cpu, 999 means 99.9% */ - unsigned long long seconds; /* seconds of process life */ + unsigned long long jiffies; /* jiffies of process life */ setREL4(TICS_ALL,TICS_ALL_C,TIME_ELAPSED,UTILIZATION) pcpu = 0; if(include_dead_children) total_time = rSv(TICS_ALL_C, ull_int, pp); else total_time = rSv(TICS_ALL, ull_int, pp); - seconds = rSv(TIME_ELAPSED, real, pp); - if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds; + jiffies = rSv(TICS_ELAPSED, ull_int, pp); + if(jiffies) pcpu = (total_time * 1000ULL) / jiffies; if (pcpu > 999U) pcpu = 999U; return snprintf(outbuf, COLWID, "%3u", pcpu); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor