%%s 5/5/488 %%d D 1.3.2 30-Jul-83 08:55:03 tools 5 4 %%c Removed trailing periods from quoted strings. %%s 43/16/450 %%d D 1.3.1 12-Jul-82 18:44:56 dpm 4 3 %%c Added base/current priority display after PID column. %%c Required changes to ps.w`pssym, ps.w`cllist, ps.w`ps.r`main %%c and ps.w`ps.r`dispone. %%s 8/6/458 %%d D 1.3 05-Apr-82 20:37:25 tools 3 2 %%c Added variable ifhead to `cps', such that the `-h' flag is handled. %%c Also modified the header strings in ps.r`main to reflect the new %%c column widths implemented in update 1.2 %%s 3/3/461 %%d D 1.2 05-Apr-82 20:07:26 tools 2 1 %%c Modified the constants IMAG_WIDTH and PROC_WIDTH in `pssym' to reflect %%c the maximums possble (9 for image and 15 for process name). %%s 0/0/0 %%d D 1.1 27-Mar-82 14:59:39 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- pssym 878 asc 25-mar-82 09:38:28 v1.1 (sw-tools v1.1) %%E 2 %%I 2 %%D 4 #-h- pssym 878 asc 05-apr-82 20:06:06 tools (lblh csam sventek) %%E 4 %%E 2 %%I 4 #-h- pssym 975 asc 12-jul-82 18:35:27 dpm (dave martin) %%E 4 # definitions used by the ps tool # DEC defined symbols define(JPI_USERNAME,16%202) define(JPI_PRCNAM,16%31c) define(JPI_IMAGNAME,16%207) define(JPI_LOGINTIM,16%206) define(JPI_TERMINAL,16%31d) define(JPI_PID,16%319) define(JPI_CPUTIM,16%407) define(JPI_OWNER,16%303) %%I 4 define(JPI_PRI,16%302) define(JPI_PRIB,16%309) %%E 4 define(DIBK_LENGTH,24) define(SS_NOSUCHDEV,16%908) define(SS_NORMAL,1) define(SS_NOMOREPROC,16%9a8) define(SS_NOPRIV,16%24) define(SS_SUSPENDED,16%3a4) # symbols used to format buffer define(TTY_WIDTH,6) define(USER_WIDTH,13) %%D 2 define(PROC_WIDTH,13) %%E 2 %%I 2 define(PROC_WIDTH,16) %%E 2 %%D 4 define(PID_WIDTH,8) %%E 4 %%I 4 define(PID_WIDTH,9) %%E 4 define(CPU_WIDTH,11) %%D 2 define(IMAG_WIDTH,13) %%E 2 %%I 2 define(IMAG_WIDTH,10) %%E 2 %%I 4 define(BASPRI_WIDTH,3) define(CURPRI_WIDTH,3) %%E 4 define(JPI_EVENT_FLAG,1) # symbols for linked list define(MAX_PROCESSES,100) define(HEAD,1) define(TAIL,arith(MAX_PROCESSES,+,2)) define(FLINK,1) define(BLINK,2) define(PIDVAL,3) define(DATAPTR,4) define(SUBPTR,5) define(CHILD,2) define(MAXDEPTH,20) define(DUMMY_TERM,":") %%D 3 #-h- cps 172 asc 25-mar-82 09:38:29 v1.1 (sw-tools v1.1) common / cps / ifterm, pat(MAXPAT) %%E 3 %%I 3 #-h- cps 250 asc 05-apr-82 20:36:19 tools (lblh csam sventek) common / cps / ifterm, ifhead, pat(MAXPAT) %%E 3 integer ifterm # YES/NO if match to be done on terminal name # if NO, done on username; init=YES %%I 3 integer ifhead # YES/NO if header lines to be output # init = NO %%E 3 integer pat # pattern to match %%D 4 #-h- cllist 772 asc 25-mar-82 09:38:29 v1.1 (sw-tools v1.1) %%E 4 %%I 4 #-h- cllist 914 asc 12-jul-82 18:35:28 dpm (dave martin) %%E 4 common / cllist / llist(5, TAIL), tlist(2, MAX_PROCESSES), nprocs, nextnode, prid(MAX_PROCESSES), owid(MAX_PROCESSES), %%I 4 baspri(MAX_PROCESSES), curpri(MAX_PROCESSES), %%E 4 cput(MAX_PROCESSES), term(8, MAX_PROCESSES), user(13, MAX_PROCESSES), proc(16, MAX_PROCESSES), imag(10, MAX_PROCESSES) integer llist # doubly linked list of process headers integer tlist # singly linked list of trailers pointing to sub-procs integer nprocs # current value of next free data block integer nextnode # current value of next tree header or trailer integer prid # process id integer owid # process id of owning process (parent) %%I 4 integer baspri # base priority of process integer curpri # current priority of process %%E 4 integer cput # elapsed cpu time for process character term # terminal name character user # user name character proc # process name character imag # de-noised image name %%D 3 #-h- ps.r 8166 asc 25-mar-82 09:38:31 v1.1 (sw-tools v1.1) #-h- main 2908 asc 25-mar-82 09:38:10 v1.1 (sw-tools v1.1) %%E 3 %%I 3 %%D 4 #-h- ps.r 8171 asc 05-apr-82 20:36:20 tools (lblh csam sventek) #-h- main 2908 asc 05-apr-82 20:34:13 tools (lblh csam sventek) %%E 4 %%E 3 %%I 4 %%D 5 #-h- ps.r 8625 asc 12-jul-82 18:35:29 dpm (dave martin) %%E 5 %%I 5 #-h- ps.r 8627 asc 30-jul-83 08:54:19 tools (lblh csam sventek) %%E 5 #-h- main 3122 asc 12-jul-82 17:44:36 dpm (dave martin) %%E 4 include pssym DRIVER(ps) %%D 4 integer*2 list(44), iosb(4) %%E 4 %%I 4 integer*2 list(56), iosb(4) %%E 4 %%D 4 integer ub, ul, pb, pl, ib, il, tb, tl, pidb, ownb, cpub, %%E 4 %%I 4 integer ub, ul, pb, pl, ib, il, tb, tl, pidb, ownb, cpub, bb, cb, %%E 4 userlen, proclen, imaglen, ttylen, ownid, cputime, %%D 4 junk, fmttim, pid, sys$getjpi, i, index, status, equal, wildpid %%E 4 %%I 4 junk, fmttim, pid, sys$getjpi, i, index, status, equal, wildpid, bpri, cpri %%E 4 integer prev, j, k, match character temp(30), userbuf(13), procbuf(16), imagbuf(65), buf(MAXLINE), tty(8) equivalence (ub, list(3)), (ul, list(5)), (ib, list(9)), (il, list(11)), (pb, list(15)), (pl, list(17)), (tb, list(21)), (tl, list(23)), (pidb, list(27)), (ownb, list(33)), %%D 4 (cpub, list(39)) %%E 4 %%I 4 (cpub, list(39)), (bb, list(45)), (cb, list(51)) %%E 4 include cps include cllist string dummy DUMMY_TERM %%D 3 string hdr1 "Term User Name Process Name Image Name CPU Time PID@n" string hdr2 "===== ============ ============ ============ ============== ========@n" %%E 3 %%I 3 %%D 4 string hdr1 "Term User Name Process Name Image CPU Time PID@n" string hdr2 "===== ============ =============== ========= ============== ========@n" %%E 4 %%E 3 %%I 4 string hdr1 "Term User Name Process Name Image CPU Time PID Prior@n" string hdr2 "===== ============ =============== ========= ============== ======== =====@n" %%E 4 %%D 4 data list/12, JPI_USERNAME, 4*0, 64, JPI_IMAGNAME, 4*0, 15, JPI_PRCNAM, 4*0, 7, JPI_TERMINAL, 4*0, 4, JPI_PID, 4*0, 4, JPI_OWNER, 4*0, 4, JPI_CPUTIM, 6*0/ %%E 4 %%I 4 data list / 12, JPI_USERNAME, 4*0, 64, JPI_IMAGNAME, 4*0, 15, JPI_PRCNAM, 4*0, 7, JPI_TERMINAL, 4*0, 4, JPI_PID, 4*0, 4, JPI_OWNER, 4*0, 4, JPI_CPUTIM, 4*0, 4, JPI_PRIB, 4*0, 4, JPI_PRI, 4*0, 2*0/ %%E 4 data wildpid /-1/ call psarg # process arguments ub = %loc(userbuf) # JPI list initialization ul = %loc(userlen) pb = %loc(procbuf) pl = %loc(proclen) ib = %loc(imagbuf) il = %loc(imaglen) tb = %loc(tty) tl = %loc(ttylen) pidb = %loc(pid) ownb = %loc(ownid) cpub = %loc(cputime) %%I 4 bb = %loc(bpri) cb = %loc(cpri) %%E 4 call initll # initialize linked list of headers repeat { call sys$clref(%val(JPI_EVENT_FLAG)) status = sys$getjpi(%val(JPI_EVENT_FLAG), wildpid,, list, iosb,,) if (status == SS_NOPRIV | status == SS_SUSPENDED) next if (status == SS_NOMOREPROC) break call sys$waitfr(%val(JPI_EVENT_FLAG)) userbuf(userlen+1) = EOS call fold(userbuf) imagbuf(imaglen+1) = EOS i = index(imagbuf, ']') + 1 call scopy(imagbuf, i, imagbuf, 1) i = index(imagbuf, '.') if (i > 0) imagbuf(i) = EOS call fold(imagbuf) procbuf(proclen+1) = EOS tty(ttylen+1) = EOS call fold(tty) if (tty(1) == EOS) call scopy(dummy, 1, term(1, nprocs), 1) else call scopy(tty, 1, term(1, nprocs), 1) call scopy(userbuf, 1, user(1, nprocs), 1) call scopy(procbuf, 1, proc(1, nprocs), 1) call scopy(imagbuf, 1, imag(1, nprocs), 1) prid(nprocs) = pid owid(nprocs) = ownid cput(nprocs) = cputime %%I 4 baspri(nprocs) = bpri curpri(nprocs) = cpri %%E 4 llist(PIDVAL, nextnode) = pid llist(DATAPTR, nextnode) = nprocs call insertll(nextnode) nprocs = nprocs + 1 nextnode = nextnode + 1 } call trailer # build trailer list call unlinksub # unlink headers of sub-processes if (ifhead == YES) { call putlin(hdr1, STDOUT) call putlin(hdr2, STDOUT) call putch('@n', STDOUT) } while(llist(FLINK, HEAD) != TAIL) # now display tree { j = llist(FLINK, HEAD) k = llist(DATAPTR, j) if (ifterm == YES) if (match(term(1,k), pat) == YES) call display(j) else call removell(j) else if (match(user(1,k), pat) == YES) call display(j) else call removell(j) } DRETURN end #-h- cpystr 212 asc 25-mar-82 09:38:12 v1.1 (sw-tools v1.1) subroutine cpystr(in, out, i, w) integer i, w, j character in(ARB), out(ARB) for (j=1; in(j) != EOS; j=j+1) call chcopy(in(j), out, i) for ( ; j <= w; j=j+1) call chcopy(' ', out, i) return end #-h- display 682 asc 25-mar-82 09:38:13 v1.1 (sw-tools v1.1) # subroutine to iteratively perform a prefix display of the tree starting # at node j subroutine display(j) integer j, header(MAXDEPTH), done(MAXDEPTH), trailer(MAXDEPTH), level, i include cllist header(1) = j trailer(1) = llist(SUBPTR, j) done(1) = NO for (level=1; level > 0; ) { if (done(level) == NO) { call dispone(header(level)) done(level) = YES if (level == 1) call removell(header(level)) } if (trailer(level) != 0) { i = trailer(level) trailer(level) = tlist(FLINK, i) level = level + 1 header(level) = tlist(CHILD, i) done(level) = NO trailer(level) = llist(SUBPTR, header(level)) } else level = level - 1 } return end %%D 4 #-h- dispone 751 asc 25-mar-82 09:38:14 v1.1 (sw-tools v1.1) %%E 4 %%I 4 #-h- dispone 1002 asc 12-jul-82 17:42:41 dpm (dave martin) %%E 4 # subroutine to display the information on one header subroutine dispone(j) integer j, i, k, junk %%D 4 integer fmttim, equal %%E 4 %%I 4 integer fmttim, equal, itoc %%E 4 character buf(MAXLINE), temp(30) include cllist string twoblk " " string dummy DUMMY_TERM k = llist(DATAPTR, j) i = 1 if (equal(term(1,k), dummy) == YES) call cpystr(EOS, buf, i, TTY_WIDTH) else call cpystr(term(1,k), buf, i, TTY_WIDTH) call cpystr(user(1,k), buf, i, USER_WIDTH) call cpystr(proc(1,k), buf, i, PROC_WIDTH) call cpystr(imag(1,k), buf, i, IMAG_WIDTH) junk = fmttim(EOS, cput(k), temp) call cpystr(temp, buf, i, CPU_WIDTH) call cpystr(twoblk, buf, i, 0) call puthex(prid(k), temp) call cpystr(temp, buf, i, PID_WIDTH) %%I 4 if( itoc( baspri(k), temp, BASPRI_WIDTH) == 1 ) call chcopy( ' ', buf, i) call stcopy( temp, 1, buf, i) call chcopy( '/', buf, i) if( itoc( curpri(k), temp, CURPRI_WIDTH) == 1 ) call chcopy( ' ', buf, i) call stcopy( temp, 1, buf, i) %%E 4 call chcopy('@n', buf, i) call putlin(buf, STDOUT) return end #-h- initll 315 asc 25-mar-82 09:38:15 v1.1 (sw-tools v1.1) # subroutine to initialize the doubly linked list of process headers subroutine initll integer bigpid include cllist % data bigpid /'7fffffff'x/ nprocs = 1 nextnode = arith(HEAD,+,1) llist(FLINK, HEAD) = TAIL llist(PIDVAL, HEAD) = 0 llist(BLINK, TAIL) = HEAD llist(PIDVAL, TAIL) = bigpid return end #-h- insertll 391 asc 25-mar-82 09:38:16 v1.1 (sw-tools v1.1) # insert node pointed to by i into the doubly linked list, ordered by PID subroutine insertll(i) integer i, j, pid, prev include cllist pid = llist(PIDVAL, i) for (j=llist(FLINK, HEAD); j != TAIL; j=llist(FLINK, j)) if (pid < llist(PIDVAL, j)) break prev = llist(BLINK, j) llist(FLINK, i) = j llist(BLINK, i) = prev llist(BLINK, j) = i llist(FLINK, prev) = i return end %%D 5 #-h- psarg 1136 asc 25-mar-82 09:38:17 v1.1 (sw-tools v1.1) %%E 5 %%I 5 #-h- psarg 1133 asc 30-jul-83 08:51:59 tools (lblh csam sventek) %%E 5 subroutine psarg integer junk, i integer getarg, index, trnlog, getpat character arg(FILENAMESIZE), term(FILENAMESIZE), buf(FILENAMESIZE) include cps string bol "%" string any "?" string anyclose "?*" string atoz "[a-z]" string tt "TT" %%D 5 call query("usage: ps [-ahx] [-tttname] [-uusername].") %%E 5 %%I 5 call query("usage: ps [-ahx] [-tttname] [-uusername]") %%E 5 ifterm = YES ifhead = NO junk = trnlog(tt, term) call fold(term) for (i=1; term(i) == '_'; i=i+1) ; call scopy(term, i, term, 1) call concat(bol, term, buf) for (i=1; getarg(i, arg, FILENAMESIZE) != EOF; i=i+1) if (arg(1) == '-') { call fold(arg) if (arg(2) == 't') { call concat(bol, anyclose, buf) call concat(buf, arg(3), buf) } else if (arg(2) == 'u') { call concat(bol, anyclose, buf) call concat(buf, arg(3), buf) ifterm = NO } else { if (index(arg, 'a') > 0) call concat(bol, atoz, buf) if (index(arg, 'h') > 0) ifhead = YES if (index(arg, 'x') > 0) call concat(bol, any, buf) } } else %%D 5 call remark("Ignoring invalid argument.") %%E 5 %%I 5 call remark("Ignoring invalid argument") %%E 5 if (getpat(buf, pat) == ERR) %%D 5 call error("Error generating pattern.") %%E 5 %%I 5 call error("Error generating pattern") %%E 5 return end #-h- removell 205 asc 25-mar-82 09:38:18 v1.1 (sw-tools v1.1) # subroutine to remove header from linked list subroutine removell(j) integer j, i, k include cllist i = llist(BLINK, j) k = llist(FLINK, j) llist(FLINK, i) = k llist(BLINK, k) = i return end #-h- trailer 520 asc 25-mar-82 09:38:19 v1.1 (sw-tools v1.1) # build trailer list subroutine trailer integer j, pid, k, l include cllist nextnode = 1 for (j=llist(FLINK, HEAD); j != TAIL; j=llist(FLINK, j)) { llist(SUBPTR, j) = 0 pid = llist(PIDVAL, j) for (k=llist(BLINK, TAIL); k != HEAD; k=llist(BLINK, k)) { l = llist(DATAPTR, k) if (owid(l) == pid) # found a child of j { tlist(CHILD, nextnode) = k tlist(FLINK, nextnode) = llist(SUBPTR, j) llist(SUBPTR, j) = nextnode nextnode = nextnode + 1 } } } return end #-h- unlinksub 316 asc 25-mar-82 09:38:21 v1.1 (sw-tools v1.1) # subroutine to unlink all headers of subprocesses subroutine unlinksub integer j, prev, k include cllist for (j=llist(FLINK, HEAD); j != TAIL; j = llist(FLINK, prev)) { k = llist(DATAPTR, j) if (owid(k) != 0) { prev = llist(BLINK, j) call removell(j) } else prev = j } return end #-h- ps.fmt 1274 asc 25-mar-82 09:38:34 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Ps (1) 29-Oct-80 list process status information .sy ps [-ahx] [-tttname] [-uusername] .ds ps lists information concerning processes in the system. The processes are listed in order by process id, with all child processes appearing in heirarchical order immediately below their respective parents. The default is to list all processes active at the invoking terminal. The switches cause other information to be displayed as follows: .sp .in +7 .ti -3 -a list information on processes associated with all logged in terminals on the system .ti -3 -h place header labels above the columns of information .ti -3 -x list information on all processes in the system .ti -7 -tname list information on all processes associated with terminals which contain the pattern `name'. .ti -7 -uname list information on all processes owned by users whose names contain the pattern `name'. .sp .in -7 The display consists of the following information: .sp .in +5 .ti -3 1. The terminal name .ti -3 2. The owning user name .ti -3 3. The process name .ti -3 4. The de-noised image name being run by the process, or blank for DCL. .ti -3 5. The total elapsed CPU time of the process .ti -3 6. The process id .in -5 .fl .sa who - who is on the system .di .au Joe Sventek .bu %%E 1