diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-11-23 20:26:17 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-11-23 20:26:17 +0000 |
commit | d973c3f25a6ab56e12b9f858b0692ec4297d84c9 (patch) | |
tree | 3a28d4ddb63bd852867237ca6bfd8e013a5663b7 /os/kernel/src/chdynamic.c | |
parent | a5bdf86e5b89a7abb281ac5514c7d6cb4d64c365 (diff) | |
download | ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.tar.gz ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.tar.bz2 ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.zip |
Fixed bug 3116888.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2425 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src/chdynamic.c')
-rw-r--r-- | os/kernel/src/chdynamic.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 06e5bd00a..5f1fc3401 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -71,17 +71,24 @@ void chThdRelease(Thread *tp) { refs = --tp->p_refs;
chSysUnlock();
- /* If the references counter reaches zero then the memory can be returned
- to the proper allocator. Of course static threads are not affected.*/
- if (refs == 0) {
+ /* If the references counter reaches zero and the thread is in its
+ terminated state then the memory can be returned to the proper
+ allocator. Of course static threads are not affected.*/
+ if ((refs == 0) && (tp->p_state == THD_STATE_FINAL)) {
switch (tp->p_flags & THD_MEM_MODE_MASK) {
#if CH_USE_HEAP
case THD_MEM_MODE_HEAP:
+#if CH_USE_REGISTRY
+ REG_REMOVE(tp);
+#endif
chHeapFree(tp);
break;
#endif
#if CH_USE_MEMPOOLS
case THD_MEM_MODE_MEMPOOL:
+#if CH_USE_REGISTRY
+ REG_REMOVE(tp);
+#endif
chPoolFree(tp->p_mpool, tp);
break;
#endif
|