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

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:        int     i, p;
                     16:        struct  pt      *ptptr;
                     17: 
1.1.1.2 ! root       18: #ifdef DEBUG
        !            19:        dotrace("pcreate", &count, 1);
        !            20: #endif
1.1       root       21:        if (count < 0)
                     22:                return(SYSERR);
1.1.1.2 ! root       23:        disable();
1.1       root       24: #ifdef MEMMARK
                     25:        if (mark(ptmark) == OK)
                     26:                pinit(MAXMSGS);
                     27: #endif
                     28:        for (i=0 ; i<NPORTS ; i++) {
                     29:                if ( (p=ptnextp--) <= 0)
                     30:                        ptnextp = NPORTS - 1;
                     31:                if ( (ptptr= &ports[p])->ptstate == PTFREE) {
                     32:                        ptptr->ptstate = PTALLOC;
                     33:                        ptptr->ptssem = screate(count);
                     34:                        ptptr->ptrsem = screate(0);
1.1.1.2 ! root       35:                        ptptr->pthead = ptptr->pttail = (struct ptnode *)NULL;
1.1       root       36:                        ptptr->ptseq++;
                     37:                        ptptr->ptmaxcnt = count;
1.1.1.2 ! root       38:                        restore();
1.1       root       39:                        return(p);
                     40:                }
                     41:        }
1.1.1.2 ! root       42:        restore();
1.1       root       43:        return(SYSERR);
                     44: }

unix.superglobalmegacorp.com

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