static char sccsid
[] = "@(#)main.c 1.6 (Lucasfilm) %G%";
static struct nlist nlst
[] = {
static WINDOW
*wload
; /* one line window for load average */
if (p
== (struct cmdtab
*)-1) {
fprintf(stderr
, "%s: unknown request\n",
if (nlst
[X_CCPU
].n_type
== 0) {
fprintf(stderr
, "Couldn't namelist /vmunix.\n");
kmem
= open(kmemf
, O_RDONLY
);
mem
= open(memf
, O_RDONLY
);
swap
= open(swapf
, O_RDONLY
);
* Initialize display. Load average appears in a one line
* window of its own. Current command's display appears in
* an overlapping sub-window of stdscr configured by the display
* routines to minimize update work by curses.
wnd
= (*curcmd
->c_open
)();
fprintf(stderr
, "Couldn't initialize display.\n");
wload
= newwin(1, 0, 3, 20);
fprintf(stderr
, "Couldn't set up load average window.\n");
gethostname(hostname
, sizeof (hostname
));
lseek(kmem
, nlst
[X_CCPU
].n_value
, 0);
read(kmem
, &ccpu
, sizeof (ccpu
));
known
[0].k_name
[0] = '\0';
strcpy(procs
[0].cmd
, "<idle>");
signal(SIGALRM
, display
);
signal(SIGTSTP
, suspend
);
"/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10");
mvaddstr(3, 5, "Load Average");
mvprintw(21, 25, "CPU usage on %s", hostname
);
/* Get the load average over the last minute. */
lseek(kmem
, nlst
[X_AVENRUN
].n_value
, L_SET
);
read(kmem
, &lave
, sizeof (lave
));
wmove(wload
, 0, 0); wclrtoeol(wload
);
for (i
= (j
> 50) ? 50 : j
; i
> 0; i
--)
wprintw(wload
, " %4.1f", lave
);
lseek(kmem
, nlst
[X_AVENRUN
].n_value
, L_SET
);
read(kmem
, &lave
, sizeof (lave
));
mvprintw(22, 0, "%4.1f", lave
);
mvprintw(22, 0, fmt
, a1
, a2
, a3
);