|
|
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: #include <io.h> ! 9: ! 10: /*------------------------------------------------------------------------ ! 11: * kill -- kill a process and remove it from the system ! 12: *------------------------------------------------------------------------ ! 13: */ ! 14: SYSCALL kill(pid) ! 15: int pid; /* process to kill */ ! 16: { ! 17: struct pentry *pptr; /* points to proc. table for pid*/ ! 18: int dev; ! 19: PStype ps; ! 20: ! 21: disable(ps); ! 22: if (isbadpid(pid) || (pptr= &proctab[pid])->pstate==PRFREE) { ! 23: restore(ps); ! 24: return(SYSERR); ! 25: } ! 26: if (--numproc == 0) ! 27: xdone(); ! 28: dev = pptr->pdevs[0]; ! 29: if (! isbaddev(dev) ) ! 30: close(dev); ! 31: dev = pptr->pdevs[1]; ! 32: if (! isbaddev(dev) ) ! 33: close(dev); ! 34: send(pptr->pnxtkin, pid); ! 35: freestk(pptr->pbase, pptr->pstklen); ! 36: switch (pptr->pstate) { ! 37: ! 38: case PRCURR: pptr->pstate = PRFREE; /* suicide */ ! 39: resched(); ! 40: ! 41: case PRWAIT: semaph[pptr->psem].semcnt++; ! 42: /* fall through */ ! 43: case PRREADY: dequeue(pid); ! 44: pptr->pstate = PRFREE; ! 45: break; ! 46: ! 47: #ifdef RTCLOCK ! 48: case PRSLEEP: ! 49: case PRTRECV: unsleep(pid); ! 50: #endif ! 51: /* fall through */ ! 52: default: pptr->pstate = PRFREE; ! 53: } ! 54: restore(ps); ! 55: return(OK); ! 56: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.