git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@121 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
f6e46bac2e
commit
c303a8a06e
|
@ -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
|
- Size optimization in the events code, now the chEvtWait() reuses the
|
||||||
chEvtWaitTimeout() code if it is enabled.
|
chEvtWaitTimeout() code if it is enabled.
|
||||||
- Size optimization in the semaphores code, now the chSemWaitTimeout() just
|
- 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
|
- 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
|
is capable of 81712 threads started/terminated per second on the reference
|
||||||
LPC2148 board. The figure is inclusive of two context switch operations
|
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.
|
- Fixed a chEvtWaitTimeout() documentation error.
|
||||||
- Added a new debug switch: CH_USE_TRACE, previously the trace functionality
|
- Added a new debug switch: CH_USE_TRACE, previously the trace functionality
|
||||||
was associated to the CH_USE_DEBUG switch.
|
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 ***
|
*** 0.4.2 ***
|
||||||
- Added a minimal ARM7-LPC demo, you can use this one as template in order to
|
- Added a minimal ARM7-LPC demo, you can use this one as template in order to
|
||||||
|
|
|
@ -91,11 +91,10 @@ t_msg chIQGet(Queue *qp) {
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
|
|
||||||
chSemWaitS(&qp->q_sem);
|
if (chSemWaitS(&qp->q_sem) < RDY_OK) {
|
||||||
if (currp->p_rdymsg < RDY_OK) {
|
|
||||||
|
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return currp->p_rdymsg;
|
return Q_RESET;
|
||||||
}
|
}
|
||||||
b = *qp->q_rdptr++;
|
b = *qp->q_rdptr++;
|
||||||
if (qp->q_rdptr >= qp->q_top)
|
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
|
* Reads a byte from the receive queue, if the queue is empty or is in
|
||||||
* transmission mode then the invoking thread is suspended.
|
* transmission mode then the invoking thread is suspended.
|
||||||
* @param qp pointer to a \p HalfDuplexQueue structure
|
* @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) {
|
t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
|
||||||
BYTE8 b;
|
BYTE8 b;
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
|
|
||||||
chSemWaitS(&qp->hdq_isem);
|
if (chSemWaitS(&qp->hdq_isem) < RDY_OK) {
|
||||||
if (currp->p_rdymsg < RDY_OK) {
|
|
||||||
|
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return currp->p_rdymsg;
|
return Q_RESET;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* NOTE: The semaphore can be signaled only if the queue is in
|
* NOTE: The semaphore can be signaled only if the queue is in
|
||||||
|
|
20
src/chsem.c
20
src/chsem.c
|
@ -82,33 +82,35 @@ void chSemResetI(Semaphore *sp, t_cnt n) {
|
||||||
/**
|
/**
|
||||||
* Performs a wait operation on a semaphore.
|
* Performs a wait operation on a semaphore.
|
||||||
* @param sp pointer to a \p Semaphore structure
|
* @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();
|
chSysLock();
|
||||||
|
|
||||||
if (--sp->s_cnt < 0) {
|
msg = chSemWaitS(sp);
|
||||||
fifo_insert(currp, &sp->s_queue);
|
|
||||||
currp->p_semp = sp;
|
|
||||||
chSchGoSleepS(PRWTSEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a wait operation on a semaphore.
|
* Performs a wait operation on a semaphore.
|
||||||
* @param sp pointer to a \p Semaphore structure
|
* @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 must be called with interrupts disabled.
|
||||||
* @note This function cannot be called by an interrupt handler.
|
* @note This function cannot be called by an interrupt handler.
|
||||||
*/
|
*/
|
||||||
void chSemWaitS(Semaphore *sp) {
|
t_msg chSemWaitS(Semaphore *sp) {
|
||||||
|
|
||||||
if (--sp->s_cnt < 0) {
|
if (--sp->s_cnt < 0) {
|
||||||
fifo_insert(currp, &sp->s_queue);
|
fifo_insert(currp, &sp->s_queue);
|
||||||
currp->p_semp = sp;
|
currp->p_semp = sp;
|
||||||
chSchGoSleepS(PRWTSEM);
|
chSchGoSleepS(PRWTSEM);
|
||||||
|
return currp->p_rdymsg;
|
||||||
}
|
}
|
||||||
|
return RDY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CH_USE_SEMAPHORES_TIMEOUT
|
#ifdef CH_USE_SEMAPHORES_TIMEOUT
|
||||||
|
@ -126,7 +128,7 @@ static void wakeup(void *p) {
|
||||||
* Performs a wait operation on a semaphore with timeout specification.
|
* Performs a wait operation on a semaphore with timeout specification.
|
||||||
* @param sp pointer to a \p Semaphore structure
|
* @param sp pointer to a \p Semaphore structure
|
||||||
* @param time the number of ticks before the operation fails
|
* @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 chSemWaitTimeout(Semaphore *sp, t_time time) {
|
||||||
t_msg msg;
|
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.
|
* Performs a wait operation on a semaphore with timeout specification.
|
||||||
* @param sp pointer to a \p Semaphore structure
|
* @param sp pointer to a \p Semaphore structure
|
||||||
* @param time the number of ticks before the operation fails
|
* @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 must be called with interrupts disabled.
|
||||||
* @note This function cannot be called by an interrupt handler.
|
* @note This function cannot be called by an interrupt handler.
|
||||||
* @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT
|
* @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT
|
||||||
|
|
|
@ -43,8 +43,8 @@ extern "C" {
|
||||||
void chSemInit(Semaphore *sp, t_cnt n);
|
void chSemInit(Semaphore *sp, t_cnt n);
|
||||||
void chSemReset(Semaphore *sp, t_cnt n);
|
void chSemReset(Semaphore *sp, t_cnt n);
|
||||||
void chSemResetI(Semaphore *sp, t_cnt n);
|
void chSemResetI(Semaphore *sp, t_cnt n);
|
||||||
void chSemWait(Semaphore *sp);
|
t_msg chSemWait(Semaphore *sp);
|
||||||
void chSemWaitS(Semaphore *sp);
|
t_msg chSemWaitS(Semaphore *sp);
|
||||||
#ifdef CH_USE_SEMAPHORES_TIMEOUT
|
#ifdef CH_USE_SEMAPHORES_TIMEOUT
|
||||||
t_msg chSemWaitTimeout(Semaphore *sp, t_time time);
|
t_msg chSemWaitTimeout(Semaphore *sp, t_time time);
|
||||||
t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);
|
t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);
|
||||||
|
|
Loading…
Reference in New Issue