diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 88a87c5ad1c..1568bd1863b 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -58,16 +58,6 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER; -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#if CONFIG_TASK_NAME_SIZE > 0 -/* This is the name for name-less pthreads */ - -static const char g_pthreadname[] = ""; -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -95,13 +85,14 @@ static const char g_pthreadname[] = ""; ****************************************************************************/ static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb, + FAR struct tcb_s *parent, pthread_trampoline_t trampoline, pthread_addr_t arg) { #if CONFIG_TASK_NAME_SIZE > 0 /* Copy the pthread name into the TCB */ - strncpy(ptcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE); + strncpy(ptcb->cmn.name, parent->name, CONFIG_TASK_NAME_SIZE); ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; #endif /* CONFIG_TASK_NAME_SIZE */ @@ -404,11 +395,14 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, } #endif + parent = this_task(); + DEBUGASSERT(parent != NULL); + /* Configure the TCB for a pthread receiving on parameter * passed by value */ - pthread_tcb_setup(ptcb, trampoline, arg); + pthread_tcb_setup(ptcb, parent, trampoline, arg); /* Join the parent's task group */ @@ -473,9 +467,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, * so it has the same priority as the parent thread. */ - parent = this_task(); - DEBUGASSERT(parent != NULL); - if (ptcb->cmn.sched_priority < parent->sched_priority) { ret = nxsched_set_priority(&ptcb->cmn, parent->sched_priority);