Annotation of coherent/b/bin/ps/ps3.0/proc.c, revision 1.1

1.1     ! root        1: #include <sys/seg.h>
        !             2: #include <sys/proc.h>
        !             3: #include "ps.h"
        !             4: 
        !             5: /*
        !             6:  * Determine the size of a process in K.
        !             7:  */
        !             8: unsigned long
        !             9: proc_size( segp, real_flag )
        !            10:        SEG *segp[];
        !            11:        unsigned real_flag;     /* Determine real process size?  */
        !            12: {
        !            13:        long len;
        !            14:        register SEG *sp;
        !            15:        register int n;
        !            16: 
        !            17:        len = 0;
        !            18:        for (n=0; n<NUSEG+1; n++) {
        !            19:                if ( !real_flag ) {
        !            20:                        if (n==SIUSERP || n==SIAUXIL) {
        !            21:                                continue;
        !            22:                        }
        !            23:                }
        !            24:                if ( (sp = segp[n]) == NULL ) {
        !            25:                        continue;
        !            26:                }
        !            27:                /*
        !            28:                 * If one segment can't be mapped, give up.
        !            29:                 */
        !            30:                if ( NULL == ( sp = kumap(sp, sizeof(SEG) ) ) ) {
        !            31:                        return 0;
        !            32:                }
        !            33: 
        !            34:                /*
        !            35:                 * Add to the running total of segment sizes.
        !            36:                 */
        !            37:                len += sp->s_size;
        !            38: 
        !            39:                /*
        !            40:                 * We're done with this segment.
        !            41:                 */
        !            42:                free(sp);
        !            43:        }
        !            44:        return( len );
        !            45: } /* proc_size() */
        !            46: 
        !            47: /*
        !            48:  * What state is the process in; asleep, running, stopped, or zombie?
        !            49:  * Returns a single character indicating which.
        !            50:  */
        !            51: char
        !            52: state( pp )
        !            53:        PROC *pp;
        !            54: {
        !            55:        register unsigned s;
        !            56: 
        !            57:        s = pp->p_state;
        !            58:        if (s == PSSLEEP) {
        !            59:                if ((pp->p_flags&PFSTOP) != 0)
        !            60:                        return ('T');
        !            61:                return ('S');
        !            62:        }
        !            63:        if (s == PSRUN)
        !            64:                return ('R');
        !            65:        if (s == PSDEAD)
        !            66:                return ('Z');
        !            67:        return ('?');
        !            68: } /* state() */
        !            69: 
        !            70: /*
        !            71:  * Read in the process table.  Allocate memory for the whole process
        !            72:  * table, which will be returned.  Returns NULL if something goes
        !            73:  * wrong.  Also fills in a value for the number processes (num_procs).
        !            74:  */
        !            75: PROC *
        !            76: create_proc_table( num_procs, pargs )
        !            77:        int *num_procs;
        !            78:        PROC_ARGS pargs;
        !            79: {
        !            80: } /* create_proc_table() */
        !            81: 
        !            82: /*
        !            83:  * Fill in data about each process.  Allocate memory for
        !            84:  * a table of PROC_DATA structs and fill it in to return.  Returns
        !            85:  * NULL if anything goes wrong.
        !            86:  */
        !            87: PROC_DATA *
        !            88: create_proc_data( proc_table, num_procs, pargs )
        !            89:        PROC proc_table[];
        !            90:        int num_procs;
        !            91:        PROC_ARGS pargs;
        !            92: {
        !            93: } /* create_proc_data() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.