aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src/chthreads.c
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-11-27 19:55:59 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-11-27 19:55:59 +0000
commit47654dcc4c7b8b1cc6c1fc5ec160cd18a449c215 (patch)
treefb344c8f0a469e5eb68701f08e417d1037215081 /os/kernel/src/chthreads.c
parent076e7453bf812c59f38cda94dd0379b6f03af0d0 (diff)
parente5ce81050f699c61b43aa74384d011c861fb31f2 (diff)
downloadChibiOS-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/src/chthreads.c')
-rw-r--r--os/kernel/src/chthreads.c26
1 files changed, 23 insertions, 3 deletions
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__)