More queues-related changes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.2.x@2985 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
f1bc362a3d
commit
c26a7e5035
|
@ -142,8 +142,10 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) {
|
||||||
*iqp->q_wrptr++ = b;
|
*iqp->q_wrptr++ = b;
|
||||||
if (iqp->q_wrptr >= iqp->q_top)
|
if (iqp->q_wrptr >= iqp->q_top)
|
||||||
iqp->q_wrptr = iqp->q_buffer;
|
iqp->q_wrptr = iqp->q_buffer;
|
||||||
|
|
||||||
if (notempty(&iqp->q_waiting))
|
if (notempty(&iqp->q_waiting))
|
||||||
chSchReadyI(fifo_remove(&iqp->q_waiting))->p_u.rdymsg = Q_OK;
|
chSchReadyI(fifo_remove(&iqp->q_waiting))->p_u.rdymsg = Q_OK;
|
||||||
|
|
||||||
return Q_OK;
|
return Q_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +154,9 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) {
|
||||||
* @details This function reads a byte value from an input queue. If the queue
|
* @details This function reads a byte value from an input queue. If the queue
|
||||||
* is empty then the calling thread is suspended until a byte arrives
|
* is empty then the calling thread is suspended until a byte arrives
|
||||||
* in the queue or a timeout occurs.
|
* in the queue or a timeout occurs.
|
||||||
|
* @note The callback is invoked if the queue is empty before entering the
|
||||||
|
* @p THD_STATE_WTQUEUE state in order to solicit the low level to
|
||||||
|
* start queue filling.
|
||||||
*
|
*
|
||||||
* @param[in] iqp pointer to an @p InputQueue structure
|
* @param[in] iqp pointer to an @p InputQueue structure
|
||||||
* @param[in] time the number of ticks before the operation timeouts,
|
* @param[in] time the number of ticks before the operation timeouts,
|
||||||
|
@ -198,8 +203,9 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) {
|
||||||
* been reset.
|
* been reset.
|
||||||
* @note The function is not atomic, if you need atomicity it is suggested
|
* @note The function is not atomic, if you need atomicity it is suggested
|
||||||
* to use a semaphore or a mutex for mutual exclusion.
|
* to use a semaphore or a mutex for mutual exclusion.
|
||||||
* @note The queue callback is invoked before entering a sleep state and at
|
* @note The callback is invoked if the queue is empty before entering the
|
||||||
* the end of the transfer.
|
* @p THD_STATE_WTQUEUE state in order to solicit the low level to
|
||||||
|
* start queue filling.
|
||||||
*
|
*
|
||||||
* @param[in] iqp pointer to an @p InputQueue structure
|
* @param[in] iqp pointer to an @p InputQueue structure
|
||||||
* @param[out] bp pointer to the data buffer
|
* @param[out] bp pointer to the data buffer
|
||||||
|
@ -226,6 +232,7 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
|
||||||
while (chIQIsEmptyI(iqp)) {
|
while (chIQIsEmptyI(iqp)) {
|
||||||
if (nfy)
|
if (nfy)
|
||||||
nfy(iqp);
|
nfy(iqp);
|
||||||
|
|
||||||
if (qwait((GenericQueue *)iqp, time) != Q_OK) {
|
if (qwait((GenericQueue *)iqp, time) != Q_OK) {
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return r;
|
return r;
|
||||||
|
@ -236,15 +243,12 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
|
||||||
*bp++ = *iqp->q_rdptr++;
|
*bp++ = *iqp->q_rdptr++;
|
||||||
if (iqp->q_rdptr >= iqp->q_top)
|
if (iqp->q_rdptr >= iqp->q_top)
|
||||||
iqp->q_rdptr = iqp->q_buffer;
|
iqp->q_rdptr = iqp->q_buffer;
|
||||||
|
|
||||||
chSysUnlock(); /* Gives a preemption chance in a controlled point.*/
|
chSysUnlock(); /* Gives a preemption chance in a controlled point.*/
|
||||||
r++;
|
r++;
|
||||||
if (--n == 0) {
|
if (--n == 0)
|
||||||
chSysLock();
|
|
||||||
if (nfy)
|
|
||||||
nfy(iqp);
|
|
||||||
chSysUnlock();
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +301,8 @@ void chOQResetI(OutputQueue *oqp) {
|
||||||
* @details This function writes a byte value to an output queue. If the queue
|
* @details This function writes a byte value to an output queue. If the queue
|
||||||
* is full then the calling thread is suspended until there is space
|
* is full then the calling thread is suspended until there is space
|
||||||
* in the queue or a timeout occurs.
|
* in the queue or a timeout occurs.
|
||||||
|
* @note The callback is invoked after writing the character into the
|
||||||
|
* buffer.
|
||||||
*
|
*
|
||||||
* @param[in] oqp pointer to an @p OutputQueue structure
|
* @param[in] oqp pointer to an @p OutputQueue structure
|
||||||
* @param[in] b the byte value to be written in the queue
|
* @param[in] b the byte value to be written in the queue
|
||||||
|
@ -356,8 +362,10 @@ msg_t chOQGetI(OutputQueue *oqp) {
|
||||||
b = *oqp->q_rdptr++;
|
b = *oqp->q_rdptr++;
|
||||||
if (oqp->q_rdptr >= oqp->q_top)
|
if (oqp->q_rdptr >= oqp->q_top)
|
||||||
oqp->q_rdptr = oqp->q_buffer;
|
oqp->q_rdptr = oqp->q_buffer;
|
||||||
|
|
||||||
if (notempty(&oqp->q_waiting))
|
if (notempty(&oqp->q_waiting))
|
||||||
chSchReadyI(fifo_remove(&oqp->q_waiting))->p_u.rdymsg = Q_OK;
|
chSchReadyI(fifo_remove(&oqp->q_waiting))->p_u.rdymsg = Q_OK;
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,8 +377,8 @@ msg_t chOQGetI(OutputQueue *oqp) {
|
||||||
* been reset.
|
* been reset.
|
||||||
* @note The function is not atomic, if you need atomicity it is suggested
|
* @note The function is not atomic, if you need atomicity it is suggested
|
||||||
* to use a semaphore or a mutex for mutual exclusion.
|
* to use a semaphore or a mutex for mutual exclusion.
|
||||||
* @note The queue callback is invoked before entering a sleep state and at
|
* @note The callback is invoked after writing each character into the
|
||||||
* the end of the transfer.
|
* buffer.
|
||||||
*
|
*
|
||||||
* @param[in] oqp pointer to an @p OutputQueue structure
|
* @param[in] oqp pointer to an @p OutputQueue structure
|
||||||
* @param[out] bp pointer to the data buffer
|
* @param[out] bp pointer to the data buffer
|
||||||
|
@ -395,8 +403,6 @@ size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp,
|
||||||
chSysLock();
|
chSysLock();
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
while (chOQIsFullI(oqp)) {
|
while (chOQIsFullI(oqp)) {
|
||||||
if (nfy)
|
|
||||||
nfy(oqp);
|
|
||||||
if (qwait((GenericQueue *)oqp, time) != Q_OK) {
|
if (qwait((GenericQueue *)oqp, time) != Q_OK) {
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return w;
|
return w;
|
||||||
|
@ -406,15 +412,14 @@ size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp,
|
||||||
*oqp->q_wrptr++ = *bp++;
|
*oqp->q_wrptr++ = *bp++;
|
||||||
if (oqp->q_wrptr >= oqp->q_top)
|
if (oqp->q_wrptr >= oqp->q_top)
|
||||||
oqp->q_wrptr = oqp->q_buffer;
|
oqp->q_wrptr = oqp->q_buffer;
|
||||||
|
|
||||||
|
if (nfy)
|
||||||
|
nfy(oqp);
|
||||||
|
|
||||||
chSysUnlock(); /* Gives a preemption chance in a controlled point.*/
|
chSysUnlock(); /* Gives a preemption chance in a controlled point.*/
|
||||||
w++;
|
w++;
|
||||||
if (--n == 0) {
|
if (--n == 0)
|
||||||
chSysLock();
|
|
||||||
if (nfy)
|
|
||||||
nfy(oqp);
|
|
||||||
chSysUnlock();
|
|
||||||
return w;
|
return w;
|
||||||
}
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,10 @@
|
||||||
- NEW: Added an option to the kernel to not spawn the Idle Thread from within
|
- NEW: Added an option to the kernel to not spawn the Idle Thread from within
|
||||||
chSysInit(), this way the application can spawn a custom idle thread or
|
chSysInit(), this way the application can spawn a custom idle thread or
|
||||||
even use the main() thread as idle thread.
|
even use the main() thread as idle thread.
|
||||||
|
- CHANGE: chiQGetFullI() and chOQGetFullI() become macros. The queues
|
||||||
|
subsystem has been optimized and is no more dependent on semaphores.
|
||||||
|
Note that the queues callbacks invocation policy has been slightly
|
||||||
|
changed, see the documentation.
|
||||||
|
|
||||||
*** 2.2.3 ***
|
*** 2.2.3 ***
|
||||||
- FIX: Fixed insufficient idle thread stack in Cortex-M0-GCC port
|
- FIX: Fixed insufficient idle thread stack in Cortex-M0-GCC port
|
||||||
|
|
Loading…
Reference in New Issue