|
|
1.1 root 1: /* send.c - send */
2:
3: #include <conf.h>
4: #include <kernel.h>
5: #include <proc.h>
6:
7: /*------------------------------------------------------------------------
8: * send -- send a message to another process
9: *------------------------------------------------------------------------
10: */
11: SYSCALL send(pid, msg)
12: int pid;
13: int msg;
14: {
15: struct pentry *pptr; /* receiver's proc. table addr. */
16: PStype ps;
17:
18: disable(ps);
19: if (isbadpid(pid) || ( (pptr= &proctab[pid])->pstate == PRFREE)
20: || pptr->phasmsg) {
21: restore(ps);
22: return(SYSERR);
23: }
24: pptr->pmsg = msg; /* deposit message */
25: pptr->phasmsg = TRUE;
26: if (pptr->pstate == PRRECV) /* if receiver waits, start it */
27: ready(pid, RESCHYES);
28: else if (pptr->pstate == PRTRECV) {
29: unsleep(pid);
30: ready(pid, RESCHYES);
31: }
32: restore(ps);
33: return(OK);
34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.