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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 4e8ae1c21..ced8a77e0 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -342,7 +342,10 @@ void chThdExit(msg_t msg) {
chSchReadyI(list_remove(&tp->p_waiting));
#endif
#if CH_USE_REGISTRY
- REG_REMOVE(tp);
+ /* Static threads are immediately removed from the registry because
+ there is no memory to recover.*/
+ if ((tp->p_flags & THD_MEM_MODE_MASK) == THD_MEM_MODE_STATIC)
+ REG_REMOVE(tp);
#endif
chSchGoSleepS(THD_STATE_FINAL);
}