00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <queue.h> 00011 #include <semaphore.h> 00012 00020 syscall signaln(semaphore sem, short count) 00021 { 00022 irqmask ps; 00023 register struct sentry *psem; 00024 00025 /* 00026 * The implementation of signaln() is essentially like 00027 * signal(), but with a loop to make ready 'n' processes 00028 * instead of one. Signaln() should be non-blocking, that is, 00029 * it should not call resched() or otherwise yield the processor. 00030 */ 00031 00032 ps = disable(); /* disable interrupts */ 00033 if ( isbadsem(sem) || (count <= 0) ) /* safety check */ 00034 { 00035 restore(ps); 00036 return SYSERR; 00037 } 00038 psem = &semtab[sem]; /* retrieve semaphore entry */ 00039 for ( ; count > 0; count-- ) /* release n processes from wait */ 00040 { 00041 if ((psem->count++) < 0) 00042 { ready(dequeue(psem->queue), RESCHED_NO); } 00043 } 00044 restore(ps); /* restore interrupts */ 00045 return OK; 00046 } 00047 00048