diff --git a/readme.txt b/readme.txt index 6be900b93..54bac1f56 100644 --- a/readme.txt +++ b/readme.txt @@ -43,7 +43,10 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet. - Size optimization in the events code, now the chEvtWait() reuses the chEvtWaitTimeout() code if it is enabled. - Size optimization in the semaphores code, now the chSemWaitTimeout() just - invokes the chSemWaitTimeoutS() inside its system mutex zone. + invokes the chSemWaitTimeoutS() inside its system mutex zone. Same thing + done with chSemWait() and chSemWaitS(). +- Size optimization in the queues code. +- Modified the return type of chSemWait() and chSemWaitS() from void to t_msg. - Added a threads create/exit/wait benchmark to the test suite, the system is capable of 81712 threads started/terminated per second on the reference LPC2148 board. The figure is inclusive of two context switch operations @@ -54,6 +57,8 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet. - Fixed a chEvtWaitTimeout() documentation error. - Added a new debug switch: CH_USE_TRACE, previously the trace functionality was associated to the CH_USE_DEBUG switch. +- I am meditating to to make a 1.0.0 release from this version, I am out of + things to do on the kernel... *** 0.4.2 *** - Added a minimal ARM7-LPC demo, you can use this one as template in order to diff --git a/src/chqueues.c b/src/chqueues.c index 88eac2184..d0412598b 100644 --- a/src/chqueues.c +++ b/src/chqueues.c @@ -91,11 +91,10 @@ t_msg chIQGet(Queue *qp) { chSysLock(); - chSemWaitS(&qp->q_sem); - if (currp->p_rdymsg < RDY_OK) { + if (chSemWaitS(&qp->q_sem) < RDY_OK) { chSysUnlock(); - return currp->p_rdymsg; + return Q_RESET; } b = *qp->q_rdptr++; if (qp->q_rdptr >= qp->q_top) @@ -324,18 +323,17 @@ void chHDQInit(HalfDuplexQueue *qp, BYTE8 *buffer, t_size size, * Reads a byte from the receive queue, if the queue is empty or is in * transmission mode then the invoking thread is suspended. * @param qp pointer to a \p HalfDuplexQueue structure - * @return the byte value + * @return the byte value or \p Q_RESET if the queue was reset */ t_msg chHDQGetReceive(HalfDuplexQueue *qp) { BYTE8 b; chSysLock(); - chSemWaitS(&qp->hdq_isem); - if (currp->p_rdymsg < RDY_OK) { + if (chSemWaitS(&qp->hdq_isem) < RDY_OK) { chSysUnlock(); - return currp->p_rdymsg; + return Q_RESET; } /* * NOTE: The semaphore can be signaled only if the queue is in 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 diff --git a/src/include/semaphores.h b/src/include/semaphores.h index 4ffb3dc0d..e17d03a6a 100644 --- a/src/include/semaphores.h +++ b/src/include/semaphores.h @@ -43,8 +43,8 @@ extern "C" { void chSemInit(Semaphore *sp, t_cnt n); void chSemReset(Semaphore *sp, t_cnt n); void chSemResetI(Semaphore *sp, t_cnt n); - void chSemWait(Semaphore *sp); - void chSemWaitS(Semaphore *sp); + t_msg chSemWait(Semaphore *sp); + t_msg chSemWaitS(Semaphore *sp); #ifdef CH_USE_SEMAPHORES_TIMEOUT t_msg chSemWaitTimeout(Semaphore *sp, t_time time); t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);