From 84e044f176cee7c6946b24c36c90f63534b5b369 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 12:22:31 +0000 Subject: Renamed Thread to thread_t. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5995 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 632367ca1..3d856a526 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -42,7 +42,7 @@ * * @api */ -Thread *chThdAddRef(Thread *tp) { +thread_t *chThdAddRef(thread_t *tp) { chSysLock(); chDbgAssert(tp->p_refs < 255, "chThdAddRef(), #1", "too many references"); @@ -64,7 +64,7 @@ Thread *chThdAddRef(Thread *tp) { * * @api */ -void chThdRelease(Thread *tp) { +void chThdRelease(thread_t *tp) { trefs_t refs; chSysLock(); @@ -114,16 +114,16 @@ void chThdRelease(Thread *tp) { * @param[in] pf the thread function * @param[in] arg an argument passed to the thread function. It can be * @p NULL. - * @return The pointer to the @p Thread structure allocated for + * @return The pointer to the @p thread_t structure allocated for * the thread into the working space area. * @retval NULL if the memory cannot be allocated. * * @api */ -Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, - tprio_t prio, tfunc_t pf, void *arg) { +thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, + tprio_t prio, tfunc_t pf, void *arg) { void *wsp; - Thread *tp; + thread_t *tp; wsp = chHeapAlloc(heapp, size); if (wsp == NULL) @@ -131,9 +131,9 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, #if CH_DBG_FILL_THREADS _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + sizeof(Thread), + (uint8_t *)wsp + sizeof(thread_t), CH_THREAD_FILL_VALUE); - _thread_memfill((uint8_t *)wsp + sizeof(Thread), + _thread_memfill((uint8_t *)wsp + sizeof(thread_t), (uint8_t *)wsp + size, CH_STACK_FILL_VALUE); #endif @@ -163,16 +163,16 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, * @param[in] pf the thread function * @param[in] arg an argument passed to the thread function. It can be * @p NULL. - * @return The pointer to the @p Thread structure allocated for + * @return The pointer to the @p thread_t structure allocated for * the thread into the working space area. * @retval NULL if the memory pool is empty. * * @api */ -Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, - tfunc_t pf, void *arg) { +thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, + tfunc_t pf, void *arg) { void *wsp; - Thread *tp; + thread_t *tp; chDbgCheck(mp != NULL, "chThdCreateFromMemoryPool"); @@ -182,9 +182,9 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, #if CH_DBG_FILL_THREADS _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + sizeof(Thread), + (uint8_t *)wsp + sizeof(thread_t), CH_THREAD_FILL_VALUE); - _thread_memfill((uint8_t *)wsp + sizeof(Thread), + _thread_memfill((uint8_t *)wsp + sizeof(thread_t), (uint8_t *)wsp + mp->mp_object_size, CH_STACK_FILL_VALUE); #endif -- cgit v1.2.3 From d58064a533743df77e52f9d76385a9e0ea1d0227 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 13:17:42 +0000 Subject: Still work in progress. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5996 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 3d856a526..76d4ba561 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -31,6 +31,30 @@ #if CH_USE_DYNAMIC || defined(__DOXYGEN__) +/*===========================================================================*/ +/* Module local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + /** * @brief Adds a reference to a thread object. * @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order -- cgit v1.2.3 From 25ddb1c801f06a3be7171e20dcfd46d11a75f112 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 14:51:35 +0000 Subject: First cleanup pass finished, queues and streams not yet removed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5999 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 76d4ba561..21c81fc24 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -144,7 +144,7 @@ void chThdRelease(thread_t *tp) { * * @api */ -thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, +thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, tprio_t prio, tfunc_t pf, void *arg) { void *wsp; thread_t *tp; @@ -193,7 +193,7 @@ thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, * * @api */ -thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, +thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, tfunc_t pf, void *arg) { void *wsp; thread_t *tp; -- cgit v1.2.3 From 49d71a01abeefa000a4cd7a556052d826b096d49 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 10:12:44 +0000 Subject: Renamed or added prefix to all hernel configuration options. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6010 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 21c81fc24..cab5556f3 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -29,7 +29,7 @@ #include "ch.h" -#if CH_USE_DYNAMIC || defined(__DOXYGEN__) +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) /*===========================================================================*/ /* Module local definitions. */ @@ -57,7 +57,7 @@ /** * @brief Adds a reference to a thread object. - * @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order + * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order * to use this function. * * @param[in] tp pointer to the thread @@ -80,7 +80,7 @@ thread_t *chThdAddRef(thread_t *tp) { * @details If the references counter reaches zero and the thread * is in the @p THD_STATE_FINAL state then the thread's memory is * returned to the proper allocator. - * @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order + * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order * to use this function. * @note Static threads are not affected. * @@ -101,17 +101,17 @@ void chThdRelease(thread_t *tp) { 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 +#if CH_CFG_USE_HEAP case THD_MEM_MODE_HEAP: -#if CH_USE_REGISTRY +#if CH_CFG_USE_REGISTRY REG_REMOVE(tp); #endif chHeapFree(tp); break; #endif -#if CH_USE_MEMPOOLS +#if CH_CFG_USE_MEMPOOLS case THD_MEM_MODE_MEMPOOL: -#if CH_USE_REGISTRY +#if CH_CFG_USE_REGISTRY REG_REMOVE(tp); #endif chPoolFree(tp->p_mpool, tp); @@ -121,10 +121,10 @@ void chThdRelease(thread_t *tp) { } } -#if CH_USE_HEAP || defined(__DOXYGEN__) +#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) /** * @brief Creates a new thread allocating the memory from the heap. - * @pre The configuration options @p CH_USE_DYNAMIC and @p CH_USE_HEAP + * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_HEAP * must be enabled in order to use this function. * @note A thread can terminate by calling @p chThdExit() or by simply * returning from its main function. @@ -169,13 +169,13 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, chSysUnlock(); return tp; } -#endif /* CH_USE_HEAP */ +#endif /* CH_CFG_USE_HEAP */ -#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) +#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) /** * @brief Creates a new thread allocating the memory from the specified * memory pool. - * @pre The configuration options @p CH_USE_DYNAMIC and @p CH_USE_MEMPOOLS + * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_MEMPOOLS * must be enabled in order to use this function. * @note A thread can terminate by calling @p chThdExit() or by simply * returning from its main function. @@ -221,8 +221,8 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, chSysUnlock(); return tp; } -#endif /* CH_USE_MEMPOOLS */ +#endif /* CH_CFG_USE_MEMPOOLS */ -#endif /* CH_USE_DYNAMIC */ +#endif /* CH_CFG_USE_DYNAMIC */ /** @} */ -- cgit v1.2.3 From 40f413d3c97a7694703938cd031ce15912b29ff7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 24 Jul 2013 14:54:26 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6025 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index cab5556f3..2b12e698f 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -78,7 +78,7 @@ thread_t *chThdAddRef(thread_t *tp) { /** * @brief Releases a reference to a thread object. * @details If the references counter reaches zero and the thread - * is in the @p THD_STATE_FINAL state then the thread's memory is + * is in the @p CH_STATE_FINAL state then the thread's memory is * returned to the proper allocator. * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order * to use this function. @@ -99,10 +99,10 @@ void chThdRelease(thread_t *tp) { /* 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 ((refs == 0) && (tp->p_state == CH_STATE_FINAL)) { + switch (tp->p_flags & CH_FLAG_MODE_MASK) { #if CH_CFG_USE_HEAP - case THD_MEM_MODE_HEAP: + case CH_FLAG_MODE_HEAP: #if CH_CFG_USE_REGISTRY REG_REMOVE(tp); #endif @@ -110,7 +110,7 @@ void chThdRelease(thread_t *tp) { break; #endif #if CH_CFG_USE_MEMPOOLS - case THD_MEM_MODE_MEMPOOL: + case CH_FLAG_MODE_MEMPOOL: #if CH_CFG_USE_REGISTRY REG_REMOVE(tp); #endif @@ -164,7 +164,7 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, chSysLock(); tp = chThdCreateI(wsp, size, prio, pf, arg); - tp->p_flags = THD_MEM_MODE_HEAP; + tp->p_flags = CH_FLAG_MODE_HEAP; chSchWakeupS(tp, RDY_OK); chSysUnlock(); return tp; @@ -215,7 +215,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, chSysLock(); tp = chThdCreateI(wsp, mp->mp_object_size, prio, pf, arg); - tp->p_flags = THD_MEM_MODE_MEMPOOL; + tp->p_flags = CH_FLAG_MODE_MEMPOOL; tp->p_mpool = mp; chSchWakeupS(tp, RDY_OK); chSysUnlock(); -- cgit v1.2.3 From 649decd10516a30886d05f5afca3d425d836db0e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 10:17:45 +0000 Subject: Cleanup debug module. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6120 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 2b12e698f..86e37df14 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -156,10 +156,10 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, #if CH_DBG_FILL_THREADS _thread_memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(thread_t), - CH_THREAD_FILL_VALUE); + CH_DBG_THREAD_FILL_VALUE); _thread_memfill((uint8_t *)wsp + sizeof(thread_t), (uint8_t *)wsp + size, - CH_STACK_FILL_VALUE); + CH_DBG_STACK_FILL_VALUE); #endif chSysLock(); @@ -207,10 +207,10 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, #if CH_DBG_FILL_THREADS _thread_memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(thread_t), - CH_THREAD_FILL_VALUE); + CH_DBG_THREAD_FILL_VALUE); _thread_memfill((uint8_t *)wsp + sizeof(thread_t), (uint8_t *)wsp + mp->mp_object_size, - CH_STACK_FILL_VALUE); + CH_DBG_STACK_FILL_VALUE); #endif chSysLock(); -- cgit v1.2.3 From eb7a1a15b23341693864c6fc13ac5eab5c1d6122 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 14:50:32 +0000 Subject: Removed 2nd parameter to assertion and check macros. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6122 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 86e37df14..5f174eda7 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -69,7 +69,7 @@ thread_t *chThdAddRef(thread_t *tp) { chSysLock(); - chDbgAssert(tp->p_refs < 255, "chThdAddRef(), #1", "too many references"); + chDbgAssert(tp->p_refs < 255, "too many references"); tp->p_refs++; chSysUnlock(); return tp; @@ -92,7 +92,7 @@ void chThdRelease(thread_t *tp) { trefs_t refs; chSysLock(); - chDbgAssert(tp->p_refs > 0, "chThdRelease(), #1", "not referenced"); + chDbgAssert(tp->p_refs > 0, "not referenced"); refs = --tp->p_refs; chSysUnlock(); @@ -198,7 +198,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, void *wsp; thread_t *tp; - chDbgCheck(mp != NULL, "chThdCreateFromMemoryPool"); + chDbgCheck(mp != NULL); wsp = chPoolAlloc(mp); if (wsp == NULL) -- cgit v1.2.3 From a1435e018bfc9919cb76b1356509ecc883767fb4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 14:51:16 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6123 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chdynamic.c | 228 ---------------------------------------------- 1 file changed, 228 deletions(-) delete mode 100644 os/kernel/src/chdynamic.c (limited to 'os/kernel/src/chdynamic.c') diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c deleted file mode 100644 index 5f174eda7..000000000 --- a/os/kernel/src/chdynamic.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file chdynamic.c - * @brief Dynamic threads code. - * - * @addtogroup dynamic_threads - * @details Dynamic threads related APIs and services. - * @{ - */ - -#include "ch.h" - -#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Module local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module exported functions. */ -/*===========================================================================*/ - -/** - * @brief Adds a reference to a thread object. - * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order - * to use this function. - * - * @param[in] tp pointer to the thread - * @return The same thread pointer passed as parameter - * representing the new reference. - * - * @api - */ -thread_t *chThdAddRef(thread_t *tp) { - - chSysLock(); - chDbgAssert(tp->p_refs < 255, "too many references"); - tp->p_refs++; - chSysUnlock(); - return tp; -} - -/** - * @brief Releases a reference to a thread object. - * @details If the references counter reaches zero and the thread - * is in the @p CH_STATE_FINAL state then the thread's memory is - * returned to the proper allocator. - * @pre The configuration option @p CH_CFG_USE_DYNAMIC must be enabled in order - * to use this function. - * @note Static threads are not affected. - * - * @param[in] tp pointer to the thread - * - * @api - */ -void chThdRelease(thread_t *tp) { - trefs_t refs; - - chSysLock(); - chDbgAssert(tp->p_refs > 0, "not referenced"); - refs = --tp->p_refs; - chSysUnlock(); - - /* 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 == CH_STATE_FINAL)) { - switch (tp->p_flags & CH_FLAG_MODE_MASK) { -#if CH_CFG_USE_HEAP - case CH_FLAG_MODE_HEAP: -#if CH_CFG_USE_REGISTRY - REG_REMOVE(tp); -#endif - chHeapFree(tp); - break; -#endif -#if CH_CFG_USE_MEMPOOLS - case CH_FLAG_MODE_MEMPOOL: -#if CH_CFG_USE_REGISTRY - REG_REMOVE(tp); -#endif - chPoolFree(tp->p_mpool, tp); - break; -#endif - } - } -} - -#if CH_CFG_USE_HEAP || defined(__DOXYGEN__) -/** - * @brief Creates a new thread allocating the memory from the heap. - * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_HEAP - * must be enabled in order to use this function. - * @note A thread can terminate by calling @p chThdExit() or by simply - * returning from its main function. - * @note The memory allocated for the thread is not released when the thread - * terminates but when a @p chThdWait() is performed. - * - * @param[in] heapp heap from which allocate the memory or @p NULL for the - * default heap - * @param[in] size size of the working area to be allocated - * @param[in] prio the priority level for the new thread - * @param[in] pf the thread function - * @param[in] arg an argument passed to the thread function. It can be - * @p NULL. - * @return The pointer to the @p thread_t structure allocated for - * the thread into the working space area. - * @retval NULL if the memory cannot be allocated. - * - * @api - */ -thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, - tprio_t prio, tfunc_t pf, void *arg) { - void *wsp; - thread_t *tp; - - wsp = chHeapAlloc(heapp, size); - if (wsp == NULL) - return NULL; - -#if CH_DBG_FILL_THREADS - _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + sizeof(thread_t), - CH_DBG_THREAD_FILL_VALUE); - _thread_memfill((uint8_t *)wsp + sizeof(thread_t), - (uint8_t *)wsp + size, - CH_DBG_STACK_FILL_VALUE); -#endif - - chSysLock(); - tp = chThdCreateI(wsp, size, prio, pf, arg); - tp->p_flags = CH_FLAG_MODE_HEAP; - chSchWakeupS(tp, RDY_OK); - chSysUnlock(); - return tp; -} -#endif /* CH_CFG_USE_HEAP */ - -#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__) -/** - * @brief Creates a new thread allocating the memory from the specified - * memory pool. - * @pre The configuration options @p CH_CFG_USE_DYNAMIC and @p CH_CFG_USE_MEMPOOLS - * must be enabled in order to use this function. - * @note A thread can terminate by calling @p chThdExit() or by simply - * returning from its main function. - * @note The memory allocated for the thread is not released when the thread - * terminates but when a @p chThdWait() is performed. - * - * @param[in] mp pointer to the memory pool object - * @param[in] prio the priority level for the new thread - * @param[in] pf the thread function - * @param[in] arg an argument passed to the thread function. It can be - * @p NULL. - * @return The pointer to the @p thread_t structure allocated for - * the thread into the working space area. - * @retval NULL if the memory pool is empty. - * - * @api - */ -thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, - tfunc_t pf, void *arg) { - void *wsp; - thread_t *tp; - - chDbgCheck(mp != NULL); - - wsp = chPoolAlloc(mp); - if (wsp == NULL) - return NULL; - -#if CH_DBG_FILL_THREADS - _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + sizeof(thread_t), - CH_DBG_THREAD_FILL_VALUE); - _thread_memfill((uint8_t *)wsp + sizeof(thread_t), - (uint8_t *)wsp + mp->mp_object_size, - CH_DBG_STACK_FILL_VALUE); -#endif - - chSysLock(); - tp = chThdCreateI(wsp, mp->mp_object_size, prio, pf, arg); - tp->p_flags = CH_FLAG_MODE_MEMPOOL; - tp->p_mpool = mp; - chSchWakeupS(tp, RDY_OK); - chSysUnlock(); - return tp; -} -#endif /* CH_CFG_USE_MEMPOOLS */ - -#endif /* CH_CFG_USE_DYNAMIC */ - -/** @} */ -- cgit v1.2.3