kernel/sched/sched_releasetcb : Skip releasing some of task's resources if pid is 0
If there is a failure before assinging pid when creating a task/thread, we don't need to release some of task's resources.
Skipped resources : terminated stackinfo, heapinfo tcbinfo, heapinfo groupinfo, timer, pid
If not, IDLE task's resources are spoiled.
@@ -150,6 +150,12 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype)
int ret = OK;
if (tcb) {
+ /* Release the some of task's resources if PID was assigned.
+ * PID zero is reserved for the IDLE task. The TCB of the IDLE
+ * task is never release so a value of zero simply means that
+ * the process ID was never allocated to this TCB.
+ */
+ if (tcb->pid) {
#if defined(CONFIG_ENABLE_STACKMONITOR) && defined(CONFIG_DEBUG)
sched_save_terminated_stackinfo(tcb);
#endif
@@ -177,13 +183,6 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype)
}
#endif
- /* Release the task's process ID if one was assigned. PID
- * zero is reserved for the IDLE task. The TCB of the IDLE
- * task is never release so a value of zero simply means that
- * the process ID was never allocated to this TCB.
- */
-
- if (tcb->pid) {
sched_releasepid(tcb->pid);
}
