aboutsummaryrefslogtreecommitdiffstats
path: root/os/common/oslib/src/chdynamic.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-02-20 13:51:02 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-02-20 13:51:02 +0000
commit27e1398be3821f814aee4eaf7627b2d8fb5c4934 (patch)
tree6a21849d04864f2c5d0b231862c3641aa2aa0773 /os/common/oslib/src/chdynamic.c
parent4f3674f5f22d41dd58a6ea51d3a5fed89ef1990b (diff)
downloadChibiOS-27e1398be3821f814aee4eaf7627b2d8fb5c4934.tar.gz
ChibiOS-27e1398be3821f814aee4eaf7627b2d8fb5c4934.tar.bz2
ChibiOS-27e1398be3821f814aee4eaf7627b2d8fb5c4934.zip
Shell reorganization.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8913 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/common/oslib/src/chdynamic.c')
-rw-r--r--os/common/oslib/src/chdynamic.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/os/common/oslib/src/chdynamic.c b/os/common/oslib/src/chdynamic.c
index 7d8b609be..80555a928 100644
--- a/os/common/oslib/src/chdynamic.c
+++ b/os/common/oslib/src/chdynamic.c
@@ -96,6 +96,23 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
return chThdCreateStatic(wsp, size, prio, pf, arg);
}
+
+/**
+ * @brief Releases a thread working area into the owner heap.
+ * @pre The thread must have been created using @p chThdCreateFromHeap().
+ * @pre The thread must be in the state @p CH_STATE_FINAL (terminated).
+ *
+ * @param[in] tp the pointer to the thread
+ *
+ * @api
+ */
+void chThdFreeToHeap(thread_t *tp) {
+
+ chDbgCheck(tp != NULL);
+ chDbgAssert(tp->state == CH_STATE_FINAL, "not terminated");
+
+ chHeapFree(chthdGetStackLimitX(tp));
+}
#endif /* CH_CFG_USE_HEAP == TRUE */
#if (CH_CFG_USE_MEMPOOLS == TRUE) || defined(__DOXYGEN__)
@@ -143,6 +160,24 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
return chThdCreateStatic(wsp, mp->object_size, prio, pf, arg);
}
+
+/**
+ * @brief Releases a thread working area into a memory pool.
+ * @pre The thread must have been created using @p chThdCreateFromMemoryPool().
+ * @pre The thread must be in the state @p CH_STATE_FINAL (terminated).
+ *
+ * @param[in] tp the pointer to the thread
+ * @param[in] mp pointer to a @p memory_pool_t structure
+ *
+ * @api
+ */
+void chThdFreeToMemoryPool(thread_t *tp, memory_pool_t *mp) {
+
+ chDbgCheck((tp != NULL) && (mp != NULL));
+ chDbgAssert(tp->state == CH_STATE_FINAL, "not terminated");
+
+ chPoolFree(mp, (void *)chthdGetStackLimitX(tp));
+}
#endif /* CH_CFG_USE_MEMPOOLS == TRUE */
#endif /* CH_CFG_USE_DYNAMIC == TRUE */