#define TC_BUFFER 1024 /* Size of termcap(3) buffer */
#define TC_STRINGS 200 /* Enough room for cm,cl,so,se */
-char *Tclr_all;
+const char *Tclr_all;
int blockedverbose = 0;
return 1;
}
-static int print_proc_summary(struct proc *proc)
+static int print_proc_summary(struct proc *pproc)
{
int p, alive, running, sleeping;
alive = running = sleeping = 0;
for(p = 0; p < nr_total; p++) {
- if (proc[p].p_endpoint == IDLE)
+ if (pproc[p].p_endpoint == IDLE)
continue;
- if(!(proc[p].p_flags & USED))
+ if(!(pproc[p].p_flags & USED))
continue;
alive++;
- if(proc[p].p_flags & BLOCKED)
+ if(pproc[p].p_flags & BLOCKED)
sleeping++;
else
running++;
if(!p2blocked && p1blocked)
return 1;
} else if(p1->ticks != p2->ticks) {
- return (p2->ticks - p1->ticks);
+ if(p1->ticks > p2->ticks) return -1;
+ assert(p1->ticks < p2->ticks);
+ return 1;
}
/* Process slot number is a tie breaker. */
int euid = 0;
static struct passwd *who = NULL;
static int last_who = -1;
- char *name = "";
+ const char *name = "";
int ticks;
struct proc *pr = tp->p;
return t;
}
-static char *ordername(int orderno)
+static const char *ordername(int orderno)
{
switch(orderno) {
case ORDER_CPU: return "cpu";
int main(int argc, char *argv[])
{
- int r, c, s = 0;
+ int r, optc, s = 0;
int cputimemode = 1; /* bitmap. */
if (chdir(_PATH_PROC) != 0) {
init(&r);
- while((c=getopt(argc, argv, "s:B")) != EOF) {
- switch(c) {
+ while((optc=getopt(argc, argv, "s:B")) != EOF) {
+ switch(optc) {
case 's':
s = atoi(optarg);
break;
}
if(ns > 0 && FD_ISSET(STDIN_FILENO, &fds)) {
- char c;
- if(read(STDIN_FILENO, &c, 1) == 1) {
- switch(c) {
+ char inc;
+ if(read(STDIN_FILENO, &inc, 1) == 1) {
+ switch(inc) {
case 'q':
putchar('\r');
return 0;