diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-11-27 19:55:59 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-11-27 19:55:59 +0000 |
commit | 47654dcc4c7b8b1cc6c1fc5ec160cd18a449c215 (patch) | |
tree | fb344c8f0a469e5eb68701f08e417d1037215081 /os/kernel | |
parent | 076e7453bf812c59f38cda94dd0379b6f03af0d0 (diff) | |
parent | e5ce81050f699c61b43aa74384d011c861fb31f2 (diff) | |
download | ChibiOS-47654dcc4c7b8b1cc6c1fc5ec160cd18a449c215.tar.gz ChibiOS-47654dcc4c7b8b1cc6c1fc5ec160cd18a449c215.tar.bz2 ChibiOS-47654dcc4c7b8b1cc6c1fc5ec160cd18a449c215.zip |
I2C branch. Goals: DMA-based driver, stm32f4x port.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3541 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel')
-rw-r--r-- | os/kernel/include/ch.h | 4 | ||||
-rw-r--r-- | os/kernel/include/chthreads.h | 17 | ||||
-rw-r--r-- | os/kernel/src/chqueues.c | 23 | ||||
-rw-r--r-- | os/kernel/src/chsys.c | 5 | ||||
-rw-r--r-- | os/kernel/src/chthreads.c | 26 | ||||
-rw-r--r-- | os/kernel/templates/chcore.c | 2 |
6 files changed, 51 insertions, 26 deletions
diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h index 35b01af2c..e751e0fc5 100644 --- a/os/kernel/include/ch.h +++ b/os/kernel/include/ch.h @@ -40,7 +40,7 @@ /**
* @brief Kernel version string.
*/
-#define CH_KERNEL_VERSION "2.3.3unstable"
+#define CH_KERNEL_VERSION "2.3.4unstable"
/**
* @name Kernel version
@@ -59,7 +59,7 @@ /**
* @brief Kernel version patch number.
*/
-#define CH_KERNEL_PATCH 3
+#define CH_KERNEL_PATCH 4
/** @} */
/*
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index bd3f21296..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"
/** @} */
/**
@@ -291,7 +301,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock.
* @note The maximum specified value is implementation dependent.
*
- * @param[in] sec time in seconds
+ * @param[in] sec time in seconds, must be different from zero
*
* @api
*/
@@ -304,7 +314,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock.
* @note The maximum specified value is implementation dependent.
*
- * @param[in] msec time in milliseconds
+ * @param[in] msec time in milliseconds, must be different from zero
*
* @api
*/
@@ -317,7 +327,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock.
* @note The maximum specified value is implementation dependent.
*
- * @param[in] usec time in microseconds
+ * @param[in] usec time in microseconds, must be different from zero
*
* @api
*/
@@ -345,6 +355,7 @@ extern "C" { void chThdSleepUntil(systime_t time);
void chThdYield(void);
void chThdExit(msg_t msg);
+ void chThdExitS(msg_t msg);
#if CH_USE_WAITEXIT
msg_t chThdWait(Thread *tp);
#endif
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;
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index 866ee81a8..78caa88f6 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -36,10 +36,7 @@ #include "ch.h"
#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
-/**
- * @brief Idle thread working area.
- * @see PORT_IDLE_THREAD_STACK_SIZE
- */
+/* Idle thread working area.*/
WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
/**
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index 46039561b..7b48f2b00 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -32,8 +32,6 @@ * area. In this scenario static variables are shared among all
* threads while automatic variables are local to the thread.<br>
* Operations defined for threads:
- * - <b>Init</b>, a thread is prepared and put in the suspended
- * state.
* - <b>Create</b>, a thread is started on the specified thread
* function. This operation is available in multiple variants,
* both static and dynamic.
@@ -335,9 +333,29 @@ void chThdYield(void) { * @api
*/
void chThdExit(msg_t msg) {
- Thread *tp = currp;
chSysLock();
+ chThdExitS(msg);
+ /* The thread never returns here.*/
+}
+
+/**
+ * @brief Terminates the current thread.
+ * @details The thread goes in the @p THD_STATE_FINAL state holding the
+ * specified exit status code, other threads can retrieve the
+ * exit status code by invoking the function @p chThdWait().
+ * @post Eventual code after this function will never be executed,
+ * this function never returns. The compiler has no way to
+ * know this so do not assume that the compiler would remove
+ * the dead code.
+ *
+ * @param[in] msg thread exit code
+ *
+ * @sclass
+ */
+void chThdExitS(msg_t msg) {
+ Thread *tp = currp;
+
tp->p_u.exitcode = msg;
#if defined(THREAD_EXT_EXIT_HOOK)
THREAD_EXT_EXIT_HOOK(tp);
@@ -353,6 +371,8 @@ void chThdExit(msg_t msg) { REG_REMOVE(tp);
#endif
chSchGoSleepS(THD_STATE_FINAL);
+ /* The thread never returns here.*/
+ chDbgAssert(FALSE, "chThdExitS(), #1", "zombies apocalypse");
}
#if CH_USE_WAITEXIT || defined(__DOXYGEN__)
diff --git a/os/kernel/templates/chcore.c b/os/kernel/templates/chcore.c index 74281f759..25a3b42a0 100644 --- a/os/kernel/templates/chcore.c +++ b/os/kernel/templates/chcore.c @@ -50,7 +50,7 @@ void port_lock(void) { /**
* @brief Kernel-unlock action.
- * @details Usually this function just disables interrupts but may perform more
+ * @details Usually this function just enables interrupts but may perform more
* actions.
*/
void port_unlock(void) {
|