From c303a8a06e68fb30c082a4f1a4fcc675ff0bd39e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 30 Nov 2007 09:00:50 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@121 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chsem.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/chsem.c') diff --git a/src/chsem.c b/src/chsem.c index 61fff37a1..01ec80649 100644 --- a/src/chsem.c +++ b/src/chsem.c @@ -82,33 +82,35 @@ void chSemResetI(Semaphore *sp, t_cnt n) { /** * Performs a wait operation on a semaphore. * @param sp pointer to a \p Semaphore structure + * @return the function can return \p RDY_OK or \p RDY_RESET. */ -void chSemWait(Semaphore *sp) { +t_msg chSemWait(Semaphore *sp) { + t_msg msg; chSysLock(); - if (--sp->s_cnt < 0) { - fifo_insert(currp, &sp->s_queue); - currp->p_semp = sp; - chSchGoSleepS(PRWTSEM); - } + msg = chSemWaitS(sp); chSysUnlock(); + return msg; } /** * Performs a wait operation on a semaphore. * @param sp pointer to a \p Semaphore structure + * @return the function can return \p RDY_OK or \p RDY_RESET. * @note This function must be called with interrupts disabled. * @note This function cannot be called by an interrupt handler. */ -void chSemWaitS(Semaphore *sp) { +t_msg chSemWaitS(Semaphore *sp) { if (--sp->s_cnt < 0) { fifo_insert(currp, &sp->s_queue); currp->p_semp = sp; chSchGoSleepS(PRWTSEM); + return currp->p_rdymsg; } + return RDY_OK; } #ifdef CH_USE_SEMAPHORES_TIMEOUT @@ -126,7 +128,7 @@ static void wakeup(void *p) { * Performs a wait operation on a semaphore with timeout specification. * @param sp pointer to a \p Semaphore structure * @param time the number of ticks before the operation fails - * @return the function can return \p RDY_OK. \p RDY_TIMEOUT or \p RDY_RESET. + * @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET. */ t_msg chSemWaitTimeout(Semaphore *sp, t_time time) { t_msg msg; @@ -143,7 +145,7 @@ t_msg chSemWaitTimeout(Semaphore *sp, t_time time) { * Performs a wait operation on a semaphore with timeout specification. * @param sp pointer to a \p Semaphore structure * @param time the number of ticks before the operation fails - * @return the function can return \p RDY_OK. \p RDY_TIMEOUT or \p RDY_RESET. + * @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET. * @note This function must be called with interrupts disabled. * @note This function cannot be called by an interrupt handler. * @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT -- cgit v1.2.3