00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <queue.h> 00011 #include <semaphore.h> 00012 00018 syscall signal(semaphore sem) 00019 { 00020 irqmask ps; 00021 register struct sentry *psem; 00022 00023 ps = disable(); /* disable interrupts */ 00024 if ( isbadsem(sem) ) /* safety check */ 00025 { 00026 restore(ps); 00027 return SYSERR; 00028 } 00029 psem = &semtab[sem]; /* retrieve semaphore entry */ 00030 if ( (psem->count++) < 0 ) /* release one process from wait queue */ 00031 { ready(dequeue(psem->queue), RESCHED_YES); } 00032 restore(ps); /* restore interrupts */ 00033 return OK; 00034 } 00035 00036