aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src/chthreads.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel/src/chthreads.c')
-rw-r--r--os/kernel/src/chthreads.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 73236c850..b2231ef17 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -335,6 +335,27 @@ void chThdYield(void) {
* @api
*/
void chThdExit(msg_t msg) {
+
+ 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;
chSysLock();
@@ -353,7 +374,8 @@ void chThdExit(msg_t msg) {
REG_REMOVE(tp);
#endif
chSchGoSleepS(THD_STATE_FINAL);
- chSysUnlock();
+ /* The thread never returns here.*/
+ chDbgAssert(FALSE, "chThdExitS(), #1", "zombies apocalypse");
}
#if CH_USE_WAITEXIT || defined(__DOXYGEN__)