mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then activate the task */
|
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
|
|
||||||
nxtask_activate((FAR struct tcb_s *)ptcb);
|
|
||||||
|
|
||||||
/* Return the thread information to the caller */
|
/* Return the thread information to the caller */
|
||||||
|
|
||||||
if (thread != NULL)
|
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;
|
*thread = (pthread_t)ptcb->cmn.pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Then activate the task */
|
||||||
|
|
||||||
|
nxtask_activate((FAR struct tcb_s *)ptcb);
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user