mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:26:56 +08:00
sched/pthread: save pid before task activate
When a high-priority pthread is created, ptcb may be released after nxtask_activate. Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user