diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index c9cf0316277..5ca05f46485 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -442,12 +442,8 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, #endif } - /* Then activate the task */ - sched_lock(); - nxtask_activate((FAR struct tcb_s *)ptcb); - /* Return the thread information to the caller */ if (thread != NULL) @@ -455,6 +451,10 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, *thread = (pthread_t)ptcb->cmn.pid; } + /* Then activate the task */ + + nxtask_activate((FAR struct tcb_s *)ptcb); + sched_unlock(); return OK;