Annotation of xinu/sys/psend.c, revision 1.1.1.1

1.1       root        1: /* psend.c - psend */
                      2: 
                      3: #include <conf.h>
                      4: #include <kernel.h>
                      5: #include <mark.h>
                      6: #include <ports.h>
                      7: 
                      8: /*------------------------------------------------------------------------
                      9:  *  psend  --  send a message to a port by enqueuing it
                     10:  *------------------------------------------------------------------------
                     11:  */
                     12: SYSCALL        psend(portid, msg)
                     13: int    portid;
                     14: int    msg;
                     15: {
                     16:        PStype  ps;
                     17:        struct  pt      *ptptr;
                     18:        int     seq;
                     19:        struct  ptnode  *freenode;
                     20:        
                     21: 
                     22:        disable(ps);
                     23:        if ( isbadport(portid) ||
                     24: #ifdef MEMMARK
                     25:             unmarked(ptmark) ||
                     26: #endif
                     27:             (ptptr= &ports[portid])->ptstate != PTALLOC ) {
                     28:                restore(ps);
                     29:                return(SYSERR);
                     30:        }
                     31: 
                     32:        /* wait for space and verify port is still allocated */
                     33: 
                     34:        seq = ptptr->ptseq;
                     35:        if (wait(ptptr->ptssem) == SYSERR
                     36:            || ptptr->ptstate != PTALLOC
                     37:            || ptptr->ptseq != seq) {
                     38:                restore(ps);
                     39:                return(SYSERR);
                     40:        }
                     41:        if (ptfree == (struct ptnode *)NULL)
                     42:                panic("psend: out of nodes");
                     43:        freenode = ptfree;
                     44:        ptfree  = freenode->ptnext;
                     45:        freenode->ptnext = (struct ptnode *)NULL;
                     46:        freenode->ptmsg  = msg;
                     47:        if (ptptr->pttail == (struct ptnode *)NULL)     /* empty queue */
                     48:                ptptr->pttail = ptptr->pthead = freenode;
                     49:        else {
                     50:                (ptptr->pttail)->ptnext = freenode;
                     51:                ptptr->pttail = freenode;
                     52:        }
                     53:        signal(ptptr->ptrsem);
                     54:        restore(ps);
                     55:        return(OK);
                     56: }

unix.superglobalmegacorp.com

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