diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index a158af4518..df054c9cd2 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -185,14 +185,21 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, pid_t pid; int ret; bool group_joined = false; + pthread_attr_t default_attr = g_default_pthread_attr; DEBUGASSERT(trampoline != NULL); + parent = this_task(); + DEBUGASSERT(parent != NULL); + /* If attributes were not supplied, use the default attributes */ if (!attr) { - attr = &g_default_pthread_attr; + /* Inherit parent priority by default */ + + default_attr.priority = parent->sched_priority; + attr = &default_attr; } /* Allocate a TCB for the new task. */ @@ -395,9 +402,6 @@ 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 */