sched/task_exit.c: Refresh current CPU instead of relying on stale value
The comment about the CPU index remaining stable is incorrect. There is no guarantee the task does not yield during the exit process, meaning the CPU can most definitely change. Also, there is no reason why it should not be allowed to change. This fixes a full system crash during process exit when the CPU changes and we query the current task from the old CPU.
This commit is contained in:
parent
a5f8dfdae0
commit
112b8cf470
|
@ -76,17 +76,11 @@ int nxtask_exit(void)
|
|||
FAR struct tcb_s *rtcb;
|
||||
int ret;
|
||||
#ifdef CONFIG_SMP
|
||||
int cpu;
|
||||
|
||||
/* Get the current CPU. By assumption, we are within a critical section
|
||||
* and, hence, the CPU index will remain stable.
|
||||
*
|
||||
* Avoid using this_task() because it may assume a state that is not
|
||||
/* Avoid using this_task() because it may assume a state that is not
|
||||
* appropriate for an exiting task.
|
||||
*/
|
||||
|
||||
cpu = this_cpu();
|
||||
dtcb = current_task(cpu);
|
||||
dtcb = current_task(this_cpu());
|
||||
#else
|
||||
dtcb = this_task();
|
||||
#endif
|
||||
|
@ -111,7 +105,7 @@ int nxtask_exit(void)
|
|||
/* Get the new task at the head of the ready to run list */
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
rtcb = current_task(cpu);
|
||||
rtcb = current_task(this_cpu());
|
||||
#else
|
||||
rtcb = this_task();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue