* fhandler_proc.cc (format_proc_loadavg): Add running/total

processes as fourth component of output.
* fhandler_process.cc (get_process_state): Make non-static.
Add FIXME about generating an 'O' flag.
This commit is contained in:
Yaakov Selkowitz
2011-04-01 09:00:21 +00:00
parent 40afcae356
commit 9ca65531e0
3 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2011-04-01 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* fhandler_proc.cc (format_proc_loadavg): Add running/total
processes as fourth component of output.
* fhandler_process.cc (get_process_state): Make non-static.
Add FIXME about generating an 'O' flag.
2011-04-01 Corinna Vinschen <corinna@vinschen.de> 2011-04-01 Corinna Vinschen <corinna@vinschen.de>
* fhandler_random.cc (fhandler_dev_random::crypt_gen_random): * fhandler_random.cc (fhandler_dev_random::crypt_gen_random):

View File

@ -374,9 +374,21 @@ format_proc_version (void *, char *&destbuf)
static _off64_t static _off64_t
format_proc_loadavg (void *, char *&destbuf) format_proc_loadavg (void *, char *&destbuf)
{ {
extern int get_process_state (DWORD dwProcessId);
unsigned running = 0;
winpids pids ((DWORD) 0);
for (unsigned i = 0; i < pids.npids; i++)
switch (get_process_state (i)) {
case 'O':
case 'R':
running++;
break;
}
destbuf = (char *) crealloc_abort (destbuf, 16); destbuf = (char *) crealloc_abort (destbuf, 16);
return __small_sprintf (destbuf, "%u.%02u %u.%02u %u.%02u\n", return __small_sprintf (destbuf, "%u.%02u %u.%02u %u.%02u %u/%u\n",
0, 0, 0, 0, 0, 0); 0, 0, 0, 0, 0, 0, running, pids.npids);
} }
static _off64_t static _off64_t

View File

@ -79,8 +79,7 @@ static const virt_tab_t process_tab[] =
static const int PROCESS_LINK_COUNT = static const int PROCESS_LINK_COUNT =
(sizeof (process_tab) / sizeof (virt_tab_t)) - 1; (sizeof (process_tab) / sizeof (virt_tab_t)) - 1;
int get_process_state (DWORD dwProcessId);
static int get_process_state (DWORD dwProcessId);
static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize, static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize,
unsigned long *vmrss, unsigned long *vmtext, unsigned long *vmrss, unsigned long *vmtext,
unsigned long *vmdata, unsigned long *vmlib, unsigned long *vmdata, unsigned long *vmlib,
@ -928,7 +927,7 @@ format_process_mounts (void *data, char *&destbuf)
return len; return len;
} }
static int int
get_process_state (DWORD dwProcessId) get_process_state (DWORD dwProcessId)
{ {
/* /*
@ -975,6 +974,7 @@ get_process_state (DWORD dwProcessId)
state = 'S'; state = 'S';
for (unsigned i = 0; i < sp->ThreadCount; i++) for (unsigned i = 0; i < sp->ThreadCount; i++)
{ {
/* FIXME: at some point we should consider generating 'O' */
if (st->State == StateRunning || if (st->State == StateRunning ||
st->State == StateReady) st->State == StateReady)
{ {