|
|
@ -9,14 +9,14 @@ |
|
|
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioc_tty.h>
|
|
|
|
//#include <sys/ioc_tty.h>
|
|
|
|
#include <sys/times.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
|
|
|
|
#include <curses.h>
|
|
|
|
#include <timers.h>
|
|
|
|
//#include <timers.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <termcap.h>
|
|
|
|
#include <termios.h>
|
|
|
@ -45,9 +45,12 @@ unsigned int nr_procs, nr_tasks; |
|
|
|
|
|
|
|
/* name of cpu cycle types, in the order they appear in /psinfo. */ |
|
|
|
const char *cputimenames[] = {"user", "ipc", "kernelcall"}; |
|
|
|
#define CPUTIMENAMES (sizeof(cputimenames) / sizeof(cputimenames[0]))
|
|
|
|
|
|
|
|
int blockedverbose = 0; |
|
|
|
|
|
|
|
int order = ORDER_CPU; |
|
|
|
|
|
|
|
int main() |
|
|
|
{ |
|
|
|
char *cmdline = NULL, *pwd = NULL; |
|
|
@ -892,4 +895,46 @@ struct tp *lookup(endpoint_t who, struct tp *tptab, int np) |
|
|
|
abort(); |
|
|
|
|
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int cmp_procs(const void *v1, const void *v2) |
|
|
|
{ |
|
|
|
struct tp *p1 = (struct tp *)v1, *p2 = (struct tp *)v2; |
|
|
|
int p1blocked, p2blocked; |
|
|
|
|
|
|
|
if (order == ORDER_MEMORY) |
|
|
|
{ |
|
|
|
if (p1->p->p_memory < p2->p->p_memory) |
|
|
|
return 1; |
|
|
|
if (p1->p->p_memory > p2->p->p_memory) |
|
|
|
return -1; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
p1blocked = !!(p1->p->p_flags & BLOCKED); |
|
|
|
p2blocked = !!(p2->p->p_flags & BLOCKED); |
|
|
|
|
|
|
|
/* Primarily order by used number of cpu cycles.
|
|
|
|
* |
|
|
|
* Exception: if in blockedverbose mode, a blocked |
|
|
|
* process is always printed after an unblocked |
|
|
|
* process, and used cpu cycles don't matter. |
|
|
|
* |
|
|
|
* In both cases, process slot number is a tie breaker. |
|
|
|
*/ |
|
|
|
|
|
|
|
if (blockedverbose && (p1blocked || p2blocked)) |
|
|
|
{ |
|
|
|
if (!p1blocked && p2blocked) |
|
|
|
return -1; |
|
|
|
if (!p2blocked && p1blocked) |
|
|
|
return 1; |
|
|
|
} |
|
|
|
else if (p1->ticks != p2->ticks) |
|
|
|
{ |
|
|
|
return (p2->ticks - p1->ticks); |
|
|
|
} |
|
|
|
|
|
|
|
/* Process slot number is a tie breaker. */ |
|
|
|
return (int)(p1->p - p2->p); |
|
|
|
} |