|
|
1.1 root 1: /* suspend.c - suspend */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <proc.h>
6:
7: /*------------------------------------------------------------------------
8: * suspend -- suspend a process, placing it in hibernation
9: *------------------------------------------------------------------------
10: */
11: SYSCALL suspend(pid)
12: int pid; /* id of process to suspend */
13: {
14: struct pentry *pptr; /* pointer to proc. tab. entry */
15: int prio; /* priority returned */
16:
1.1.1.2 ! root 17: disable();
1.1 root 18: if (isbadpid(pid) || pid==NULLPROC ||
19: ((pptr= &proctab[pid])->pstate!=PRCURR && pptr->pstate!=PRREADY)) {
1.1.1.2 ! root 20: restore();
1.1 root 21: return(SYSERR);
22: }
23: if (pptr->pstate == PRREADY) {
24: pptr->pstate = PRSUSP;
1.1.1.2 ! root 25: dequeue(pid);
! 26: }
! 27: else {
1.1 root 28: pptr->pstate = PRSUSP;
29: resched();
30: }
31: prio = pptr->pprio;
1.1.1.2 ! root 32: restore();
1.1 root 33: return(prio);
34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.