* fhandler_proc.cc: Add <sys/param.h> include.
(format_proc_uptime): Use KernelTime and UserTime only as they include the other counters. (format_proc_stat): KernelTime includes IdleTime, so subtract IdleTime from KernelTime. Make number of 'jiffies' per second same as HZ define. * fhandler_process.cc: Add <sys/param.h> include. (format_process_stat): Make number of 'jiffies' per second same as HZ define. Use KernelTime and UserTime only to calculate start_time.
This commit is contained in:
parent
af598a3b09
commit
c8bef40026
|
@ -1,3 +1,14 @@
|
||||||
|
2002-08-31 Christopher January <chris@atomice.net>
|
||||||
|
|
||||||
|
* fhandler_proc.cc: Add <sys/param.h> include.
|
||||||
|
(format_proc_uptime): Use KernelTime and UserTime only as they include
|
||||||
|
the other counters.
|
||||||
|
(format_proc_stat): KernelTime includes IdleTime, so subtract IdleTime
|
||||||
|
from KernelTime. Make number of 'jiffies' per second same as HZ define.
|
||||||
|
* fhandler_process.cc: Add <sys/param.h> include.
|
||||||
|
(format_process_stat): Make number of 'jiffies' per second same as
|
||||||
|
HZ define. Use KernelTime and UserTime only to calculate start_time.
|
||||||
|
|
||||||
2002-08-30 Christopher Faylor <cgf@redhat.com>
|
2002-08-30 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
(inspired by a patch from Egor Duda)
|
(inspired by a patch from Egor Duda)
|
||||||
|
|
|
@ -23,6 +23,7 @@ details. */
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
|
|
||||||
#define _COMPILING_NEWLIB
|
#define _COMPILING_NEWLIB
|
||||||
|
@ -423,9 +424,8 @@ format_proc_uptime (char *destbuf, size_t maxsize)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
idle_time = spt.IdleTime.QuadPart / 100000ULL;
|
idle_time = spt.IdleTime.QuadPart / 100000ULL;
|
||||||
uptime = (spt.InterruptTime.QuadPart + spt.KernelTime.QuadPart +
|
uptime = (spt.KernelTime.QuadPart +
|
||||||
spt.IdleTime.QuadPart + spt.UserTime.QuadPart +
|
spt.UserTime.QuadPart) / 100000ULL;
|
||||||
spt.DpcTime.QuadPart) / 100000ULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return __small_sprintf (destbuf, "%U.%02u %U.%02u\n",
|
return __small_sprintf (destbuf, "%U.%02u %U.%02u\n",
|
||||||
|
@ -467,9 +467,9 @@ format_proc_stat (char *destbuf, size_t maxsize)
|
||||||
ret, RtlNtStatusToDosError (ret));
|
ret, RtlNtStatusToDosError (ret));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
kernel_time = (spt.KernelTime.QuadPart + spt.InterruptTime.QuadPart + spt.DpcTime.QuadPart) / 100000ULL;
|
kernel_time = (spt.KernelTime.QuadPart - spt.IdleTime.QuadPart) * HZ / 10000000ULL;
|
||||||
user_time = spt.UserTime.QuadPart / 100000ULL;
|
user_time = spt.UserTime.QuadPart * HZ / 10000000ULL;
|
||||||
idle_time = spt.IdleTime.QuadPart / 100000ULL;
|
idle_time = spt.IdleTime.QuadPart * HZ / 10000000ULL;
|
||||||
interrupt_count = spt.InterruptCount;
|
interrupt_count = spt.InterruptCount;
|
||||||
pages_in = spi.PagesRead;
|
pages_in = spi.PagesRead;
|
||||||
pages_out = spi.PagefilePagesWritten + spi.MappedFilePagesWritten;
|
pages_out = spi.PagefilePagesWritten + spi.MappedFilePagesWritten;
|
||||||
|
|
|
@ -23,6 +23,7 @@ details. */
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
|
#include <sys/param.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define _COMPILING_NEWLIB
|
#define _COMPILING_NEWLIB
|
||||||
|
@ -454,22 +455,18 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fault_count = vmc.PageFaultCount;
|
fault_count = vmc.PageFaultCount;
|
||||||
utime = put.UserTime.QuadPart / 100000ULL;
|
utime = put.UserTime.QuadPart * HZ / 10000000ULL;
|
||||||
stime = put.KernelTime.QuadPart / 100000ULL;
|
stime = put.KernelTime.QuadPart * HZ / 10000000ULL;
|
||||||
if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
|
if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
|
||||||
start_time = (spt.InterruptTime.QuadPart + spt.KernelTime.QuadPart +
|
start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart -
|
||||||
spt.IdleTime.QuadPart + spt.UserTime.QuadPart +
|
stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / 10000000ULL;
|
||||||
spt.DpcTime.QuadPart - stodi.CurrentTime.QuadPart +
|
|
||||||
put.CreateTime.QuadPart) / 100000ULL;
|
|
||||||
else
|
else
|
||||||
/*
|
/*
|
||||||
* sometimes stodi.CurrentTime is a bit behind
|
* sometimes stodi.CurrentTime is a bit behind
|
||||||
* Note: some older versions of procps are broken and can't cope
|
* Note: some older versions of procps are broken and can't cope
|
||||||
* with process start times > time(NULL).
|
* with process start times > time(NULL).
|
||||||
*/
|
*/
|
||||||
start_time = (spt.InterruptTime.QuadPart + spt.KernelTime.QuadPart +
|
start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
|
||||||
spt.IdleTime.QuadPart + spt.UserTime.QuadPart +
|
|
||||||
spt.DpcTime.QuadPart) / 100000ULL;
|
|
||||||
priority = pbi.BasePriority;
|
priority = pbi.BasePriority;
|
||||||
unsigned page_size = getpagesize();
|
unsigned page_size = getpagesize();
|
||||||
vmsize = vmc.VirtualSize;
|
vmsize = vmc.VirtualSize;
|
||||||
|
@ -478,7 +475,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start_time = (GetTickCount() / 1000 - time(NULL) + p->start_time) * 100;
|
start_time = (GetTickCount() / 1000 - time(NULL) + p->start_time) * HZ;
|
||||||
}
|
}
|
||||||
return __small_sprintf (destbuf, "%d (%s) %c "
|
return __small_sprintf (destbuf, "%d (%s) %c "
|
||||||
"%d %d %d %d %d "
|
"%d %d %d %d %d "
|
||||||
|
|
Loading…
Reference in New Issue