Annotation of xinu/sys/pcreate.c, revision 1.1

1.1     ! root        1: /* pcreate.c - pcreate */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <mark.h>
        !             6: #include <ports.h>
        !             7: 
        !             8: /*------------------------------------------------------------------------
        !             9:  *  pcreate  --  create a port that allows "count" outstanding messages
        !            10:  *------------------------------------------------------------------------
        !            11:  */
        !            12: SYSCALL        pcreate(count)
        !            13: int    count;
        !            14: {
        !            15:        PStype  ps;
        !            16:        int     i, p;
        !            17:        struct  pt      *ptptr;
        !            18: 
        !            19:        if (count < 0)
        !            20:                return(SYSERR);
        !            21:        disable(ps);
        !            22: #ifdef MEMMARK
        !            23:        if (mark(ptmark) == OK)
        !            24:                pinit(MAXMSGS);
        !            25: #endif
        !            26:        for (i=0 ; i<NPORTS ; i++) {
        !            27:                if ( (p=ptnextp--) <= 0)
        !            28:                        ptnextp = NPORTS - 1;
        !            29:                if ( (ptptr= &ports[p])->ptstate == PTFREE) {
        !            30:                        ptptr->ptstate = PTALLOC;
        !            31:                        ptptr->ptssem = screate(count);
        !            32:                        ptptr->ptrsem = screate(0);
        !            33:                        ptptr->pthead = ptptr->pttail
        !            34:                                = (struct ptnode *)NULL;
        !            35:                        ptptr->ptseq++;
        !            36:                        ptptr->ptmaxcnt = count;
        !            37:                        restore(ps);
        !            38:                        return(p);
        !            39:                }
        !            40:        }
        !            41:        restore(ps);
        !            42:        return(SYSERR);
        !            43: }

unix.superglobalmegacorp.com

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