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

1.1       root        1: /* kill.c - kill */
                      2: 
                      3: #include <conf.h>
                      4: #include <kernel.h>
                      5: #include <proc.h>
                      6: #include <sem.h>
                      7: #include <mem.h>
                      8: 
                      9: /*------------------------------------------------------------------------
                     10:  * kill  --  kill a process and remove it from the system
                     11:  *------------------------------------------------------------------------
                     12:  */
                     13: SYSCALL kill(pid)
                     14:        int     pid;                    /* process to kill              */
                     15: {
                     16:        struct  pentry  *pptr;          /* points to proc. table for pid*/
                     17: 
1.1.1.2 ! root       18:        disable();
1.1       root       19:        if (isbadpid(pid) || (pptr= &proctab[pid])->pstate==PRFREE) {
1.1.1.2 ! root       20:                restore();
1.1       root       21:                return(SYSERR);
                     22:        }
                     23:        if (--numproc == 0)
                     24:                xdone();
                     25:        freestk(pptr->pbase, pptr->pstklen);
                     26:        switch (pptr->pstate) {
                     27: 
1.1.1.2 ! root       28:        case PRCURR:    pptr->pstate = PRFREE; /* suicide */
1.1       root       29:                        resched();
                     30: 
1.1.1.2 ! root       31:        case PRWAIT:    semaph[pptr->psem].semcnt++;
        !            32: 
        !            33:        case PRSLEEP:
        !            34:        case PRREADY:   dequeue(pid);
        !            35: 
        !            36:        default:        pptr->pstate = PRFREE;
1.1       root       37:        }
1.1.1.2 ! root       38:        restore();
1.1       root       39:        return(OK);
                     40: }

unix.superglobalmegacorp.com

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