aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/common/oslib/include/chdynamic.h7
-rw-r--r--os/common/oslib/src/chdynamic.c39
-rw-r--r--os/common/ports/ARMCMx/cmsis_os/cmsis_os.c1
-rw-r--r--os/common/ports/ARMCMx/cmsis_os/cmsis_os.h14
-rw-r--r--os/various/lwip_bindings/arch/sys_arch.c26
-rw-r--r--os/various/shell/shell.c1
-rw-r--r--os/various/shell/shell_cmd.c3
7 files changed, 41 insertions, 50 deletions
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
diff --git a/os/various/lwip_bindings/arch/sys_arch.c b/os/various/lwip_bindings/arch/sys_arch.c
index 950213ef1..40577f2bc 100644
--- a/os/various/lwip_bindings/arch/sys_arch.c
+++ b/os/various/lwip_bindings/arch/sys_arch.c
@@ -204,32 +204,10 @@ void sys_mbox_set_invalid(sys_mbox_t *mbox) {
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread,
void *arg, int stacksize, int prio) {
- size_t wsz;
- void *wsp;
- syssts_t sts;
thread_t *tp;
- (void)name;
- wsz = THD_WORKING_AREA_SIZE(stacksize);
- wsp = chCoreAlloc(wsz);
- if (wsp == NULL)
- return NULL;
-
-#if CH_DBG_FILL_THREADS == TRUE
- _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 + wsz,
- CH_DBG_STACK_FILL_VALUE);
-#endif
-
- sts = chSysGetStatusAndLockX();
- tp = chThdCreateI(wsp, wsz, prio, (tfunc_t)thread, arg);
- chRegSetThreadNameX(tp, name);
- chThdStartI(tp);
- chSysRestoreStatusX(sts);
-
+ tp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(stacksize),
+ name, prio, (tfunc_t)thread, arg);
return (sys_thread_t)tp;
}
diff --git a/os/various/shell/shell.c b/os/various/shell/shell.c
index 958afcaf1..0cbaedc81 100644
--- a/os/various/shell/shell.c
+++ b/os/various/shell/shell.c
@@ -130,7 +130,6 @@ THD_FUNCTION(shellThread, p) {
char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
char *args[SHELL_MAX_ARGUMENTS + 1];
- chRegSetThreadName("shell");
chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
while (true) {
chprintf(chp, "ch> ");
diff --git a/os/various/shell/shell_cmd.c b/os/various/shell/shell_cmd.c
index 7d592286b..6432f59d3 100644
--- a/os/various/shell/shell_cmd.c
+++ b/os/various/shell/shell_cmd.c
@@ -165,7 +165,8 @@ static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Usage: test\r\n");
return;
}
- tp = chThdCreateFromHeap(NULL, SHELL_CMD_TEST_WA_SIZE, chThdGetPriorityX(),
+ tp = chThdCreateFromHeap(NULL, SHELL_CMD_TEST_WA_SIZE,
+ "test", chThdGetPriorityX(),
TestThread, chp);
if (tp == NULL) {
chprintf(chp, "out of memory\r\n");