/* * top - a top users display for Unix * * SYNOPSIS: For Intel based System V Release 5 (Unixware7) * * DESCRIPTION: * System V release 5 for i[3456]86 * Works for: * i586-sco-sysv5uw7 i386 SCO UNIX_SVR5 (UnixWare 7) * * LIBS: -lelf -lmas * * CFLAGS: -DHAVE_GETOPT -DORDER * * AUTHORS: Mike Hopkirk <hops@sco.com> * David Cutter <dpc@grail.com> * Andrew Herbert <andrew@werple.apana.org.au> * Robert Boucher <boucher@sofkin.ca> *//* build config * SHOW_NICE - process nice fields don't seem to be being updated so changed * default to display # of threads in use instead. * define this to display nice fields (values always 0) * #define SHOW_NICE 1 */#define _KMEMUSER#define prpsinfo psinfo#include<sys/procfs.h>#define pr_state pr_lwp.pr_state#define pr_nice pr_lwp.pr_nice#define pr_pri pr_lwp.pr_pri#define pr_onpro pr_lwp.pr_onpro#define ZOMBIE(p) ((p)->pr_nlwp == 0)#define SIZE_K(p) pagetok((p)->pr_size)#define RSS_K(p) pagetok((p)->pr_rssize)#include<stdio.h>#include<fcntl.h>#include<unistd.h>#include<stdlib.h>#include<errno.h>#include<dirent.h>#include<nlist.h>#include<string.h>#include<sys/types.h>#include<sys/param.h>#include<sys/proc.h>#include<sys/sysmacros.h>#include<vm/anon.h>#include<sys/priocntl.h>#include<sys/tspriocntl.h>#include<sys/var.h>#include"top.h"#include"machine.h"#include"utils.h"#define UNIX "/stand/unix"#define KMEM "/dev/kmem"#define PROCFS "/proc"#define CPUSTATES 5#ifndef PRIO_MAX#define PRIO_MAX 20#endif#ifndef PRIO_MIN#define PRIO_MIN -20#endif#ifndef FSCALE#define FSHIFT 8 /* bits to right of fixed binary point */#define FSCALE (1<<FSHIFT)#endif#define loaddouble(x) ((double)x/FSCALE)#define pagetok(size) ((size) * pagesz) >> LOG1024/* definitions for the index in the nlist array */#define X_AVENRUN 0#define X_V 1#define X_MPID 2staticstructnlistnlst[]={{"avenrun"},/* 0 */{"v"},/* 1 */{"nextpid"},/* 2 */{NULL}};staticunsignedlongavenrun_offset;staticunsignedlongmpid_offset;staticunsignedintpagesz;staticvoidreallocproc(intn);staticintmaxprocs;/* get_process_info passes back a handle. This is what it looks like: */structhandle{structprpsinfo**next_proc;/* points to next valid proc pointer */intremaining;/* number of pointers remaining */};/*