diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-10-23 11:39:45 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-10-23 11:39:45 +0000 |
commit | 309b1e411426e8d36d9a552ef2870da3db912a80 (patch) | |
tree | 5567c549d2ec3ed75d9deb228f2f6542e4b21b25 /os/kernel | |
parent | 78325ebdf2db30514e6b61e25b0c1894a8e29b79 (diff) | |
download | ChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.tar.gz ChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.tar.bz2 ChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.zip |
Improvements to the USB driver, first phase.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3449 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel')
-rw-r--r-- | os/kernel/include/chthreads.h | 10 | ||||
-rw-r--r-- | os/kernel/src/chqueues.c | 23 |
2 files changed, 20 insertions, 13 deletions
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 582b4e1e1..5848d5643 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -51,6 +51,16 @@ #define THD_STATE_WTMSG 12 /**< @brief Waiting for a message. */
#define THD_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */
#define THD_STATE_FINAL 14 /**< @brief Thread terminated. */
+
+/**
+ * @brief Thread states as array of strings.
+ * @details Each element in an array initialized with this macro can be
+ * indexed using the numeric thread state values.
+ */
+#define THD_STATE_NAMES \
+ "READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \
+ "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \
+ "FINAL"
/** @} */
/**
diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c index cf3d21732..b32ccf803 100644 --- a/os/kernel/src/chqueues.c +++ b/os/kernel/src/chqueues.c @@ -152,9 +152,8 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) { * @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
* 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.
+ * @note The callback is invoked before reading the character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
*
* @param[in] iqp pointer to an @p InputQueue structure
* @param[in] time the number of ticks before the operation timeouts,
@@ -172,12 +171,11 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { uint8_t b;
chSysLock();
+ if (iqp->q_notify)
+ iqp->q_notify(iqp);
+
while (chIQIsEmptyI(iqp)) {
msg_t msg;
-
- if (iqp->q_notify)
- iqp->q_notify(iqp);
-
if ((msg = qwait((GenericQueue *)iqp, time)) < Q_OK) {
chSysUnlock();
return msg;
@@ -201,9 +199,8 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { * been reset.
* @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore or a mutex for mutual exclusion.
- * @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.
+ * @note The callback is invoked before reading each character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
*
* @param[in] iqp pointer to an @p InputQueue structure
* @param[out] bp pointer to the data buffer
@@ -227,10 +224,10 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, chSysLock();
while (TRUE) {
- while (chIQIsEmptyI(iqp)) {
- if (nfy)
- nfy(iqp);
+ if (nfy)
+ nfy(iqp);
+ while (chIQIsEmptyI(iqp)) {
if (qwait((GenericQueue *)iqp, time) != Q_OK) {
chSysUnlock();
return r;
|