task_restart: Make sure new task starts with pre-emption disabled and not in a critical section.

This commit is contained in:
Gregory Nutt 2016-11-21 07:33:23 -06:00
parent d83ad6296c
commit 0029c04dad

View File

@ -164,6 +164,15 @@ int task_restart(pid_t pid)
tcb->cmn.sched_priority = tcb->cmn.init_priority;
/* The task should restart with pre-emption disabled and not in a critical
* secton.
*/
tcb->cmn.lockcount = 0;
#ifdef CONFIG_SMP
tcb->cmn.irqcount = 0;
#endif
/* Reset the base task priority and the number of pending reprioritizations */
#ifdef CONFIG_PRIORITY_INHERITANCE
@ -198,7 +207,9 @@ int task_restart(pid_t pid)
}
#endif /* CONFIG_SMP */
/* Activate the task */
leave_critical_section(flags);
/* Activate the task. */
ret = task_activate((FAR struct tcb_s *)tcb);
if (ret != OK)
@ -208,7 +219,6 @@ int task_restart(pid_t pid)
goto errout_with_lock;
}
leave_critical_section(flags);
return OK;
errout_with_lock: