00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <proc.h> 00011 00019 syscall send(ushort pid, long msg, bool block) 00020 { 00021 irqmask ps; 00022 pcb *ppcb; 00023 00024 ppcb = &proctab[pid]; /* acquire pcb from process table */ 00025 ps = disable(); /* disable interrupts */ 00026 if (isbadpid(pid) || (ppcb->state == PRFREE) || ppcb->hasmsg != FALSE) 00027 { 00028 restore(ps); 00029 return SYSERR; 00030 } 00031 ppcb->msg = msg; /* deliver message */ 00032 ppcb->hasmsg = TRUE; /* raise mailbox flag */ 00033 if (ppcb->state == PRRECV) { ready(pid, RESCHED_NO); } 00034 restore(ps); /* restore interrupts */ 00035 if (BLOCK == block) { resched(); } 00036 return OK; 00037 }