From 27e1398be3821f814aee4eaf7627b2d8fb5c4934 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 20 Feb 2016 13:51:02 +0000 Subject: Shell reorganization. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8913 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/oslib/src/chdynamic.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'os/common/oslib/src') 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 */ -- cgit v1.2.3