|
|
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: PStype ps; /* saved processor status */
16: int prio; /* priority returned */
17:
18: disable(ps);
19: if (isbadpid(pid) || pid==NULLPROC ||
20: ((pptr= &proctab[pid])->pstate!=PRCURR && pptr->pstate!=PRREADY)) {
21: restore(ps);
22: return(SYSERR);
23: }
24: if (pptr->pstate == PRREADY) {
25: dequeue(pid);
26: pptr->pstate = PRSUSP;
27: } else {
28: pptr->pstate = PRSUSP;
29: resched();
30: }
31: prio = pptr->pprio;
32: restore(ps);
33: return(prio);
34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.