From 8f89ec3c0bb6f4bc5a77afd37ebb3919181f7a4d Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 21 Feb 2016 10:45:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8919 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/oslib/include/chdynamic.h | 7 +++--- os/common/oslib/src/chdynamic.c | 39 ++++++++++++++++++------------ os/common/ports/ARMCMx/cmsis_os/cmsis_os.c | 1 + os/common/ports/ARMCMx/cmsis_os/cmsis_os.h | 14 ++++++----- 4 files changed, 37 insertions(+), 24 deletions(-) (limited to 'os/common') diff --git a/os/common/oslib/include/chdynamic.h b/os/common/oslib/include/chdynamic.h index 35b47cd93..fa42bf3ae 100644 --- a/os/common/oslib/include/chdynamic.h +++ b/os/common/oslib/include/chdynamic.h @@ -73,12 +73,13 @@ extern "C" { #endif #if CH_CFG_USE_HEAP == TRUE thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); + const char *name, tprio_t prio, + tfunc_t pf, void *arg); void chThdFreeToHeap(thread_t *tp); #endif #if CH_CFG_USE_MEMPOOLS == TRUE - thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, - tfunc_t pf, void *arg); + thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name, + tprio_t prio, tfunc_t pf, void *arg); void chThdFreeToMemoryPool(thread_t *tp, memory_pool_t *mp); #endif #ifdef __cplusplus diff --git a/os/common/oslib/src/chdynamic.c b/os/common/oslib/src/chdynamic.c index 80555a928..3865c318a 100644 --- a/os/common/oslib/src/chdynamic.c +++ b/os/common/oslib/src/chdynamic.c @@ -69,6 +69,7 @@ * @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] name thread name * @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 @@ -80,7 +81,8 @@ * @api */ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, - tprio_t prio, tfunc_t pf, void *arg) { + const char *name, tprio_t prio, + tfunc_t pf, void *arg) { void *wsp; wsp = chHeapAllocAligned(heapp, size, PORT_WORKING_AREA_ALIGN); @@ -88,13 +90,16 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size, return NULL; } -#if CH_DBG_FILL_THREADS == TRUE - _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + size, - CH_DBG_STACK_FILL_VALUE); -#endif + thread_descriptor_t td = { + name, + wsp, + (stkalign_t *)((uint8_t *)wsp + size), + prio, + pf, + arg + }; - return chThdCreateStatic(wsp, size, prio, pf, arg); + return chThdCreate(&td); } /** @@ -131,6 +136,7 @@ void chThdFreeToHeap(thread_t *tp) { * and then release the allocated memory. * * @param[in] mp pointer to the memory pool object + * @param[in] name thread name * @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 @@ -141,8 +147,8 @@ void chThdFreeToHeap(thread_t *tp) { * * @api */ -thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, - tfunc_t pf, void *arg) { +thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name, + tprio_t prio, tfunc_t pf, void *arg) { void *wsp; chDbgCheck(mp != NULL); @@ -152,13 +158,16 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio, return NULL; } -#if CH_DBG_FILL_THREADS == TRUE - _thread_memfill((uint8_t *)wsp, - (uint8_t *)wsp + mp->object_size, - CH_DBG_STACK_FILL_VALUE); -#endif + thread_descriptor_t td = { + name, + wsp, + (stkalign_t *)((uint8_t *)wsp + mp->object_size), + prio, + pf, + arg + }; - return chThdCreateStatic(wsp, mp->object_size, prio, pf, arg); + return chThdCreate(&td); } /** diff --git a/os/common/ports/ARMCMx/cmsis_os/cmsis_os.c b/os/common/ports/ARMCMx/cmsis_os/cmsis_os.c index 6b328ea7f..04bebeb1d 100644 --- a/os/common/ports/ARMCMx/cmsis_os/cmsis_os.c +++ b/os/common/ports/ARMCMx/cmsis_os/cmsis_os.c @@ -119,6 +119,7 @@ osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument) { thread_def->stacksize; return (osThreadId)chThdCreateFromHeap(0, THD_WORKING_AREA_SIZE(size), + thread_def->name, NORMALPRIO+thread_def->tpriority, (tfunc_t)thread_def->pthread, argument); diff --git a/os/common/ports/ARMCMx/cmsis_os/cmsis_os.h b/os/common/ports/ARMCMx/cmsis_os/cmsis_os.h index 41d96baed..1c0998baf 100644 --- a/os/common/ports/ARMCMx/cmsis_os/cmsis_os.h +++ b/os/common/ports/ARMCMx/cmsis_os/cmsis_os.h @@ -243,6 +243,7 @@ typedef struct os_thread_def { os_pthread pthread; osPriority tpriority; uint32_t stacksize; + const char *name; } osThreadDef_t; /** @@ -301,14 +302,15 @@ typedef struct os_messageQ_def { * @brief Create a Thread definition. */ #if defined(osObjectsExternal) -#define osThreadDef(name, priority, instances, stacksz) \ - extern const osThreadDef_t os_thread_def_##name +#define osThreadDef(thd, priority, stacksz, name) \ + extern const osThreadDef_t os_thread_def_##thd #else -#define osThreadDef(name, priority, stacksz) \ -const osThreadDef_t os_thread_def_##name = { \ - (name), \ +#define osThreadDef(thd, priority, stacksz, name) \ +const osThreadDef_t os_thread_def_##thd = { \ + (thd), \ (priority), \ - (stacksz) \ + (stacksz), \ + (name) \ } #endif -- cgit v1.2.3