Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sched/task/task_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@ int nxtask_exit(void)
FAR struct tcb_s *dtcb;
FAR struct tcb_s *rtcb;
int ret;
#ifdef CONFIG_SMP
/* Avoid using this_task() because it may assume a state that is not
* appropriate for an exiting task.
* appropriate for an exiting task: if a higher-priority task became
* ready and was placed at the head of the ready-to-run list while
* the context switch away from the exiting task is still deferred,
* this_task() (the ready-to-run head) no longer identifies the task
* that is actually exiting.
*/

#ifdef CONFIG_SMP
dtcb = current_task(this_cpu());
#else
dtcb = this_task();
dtcb = g_running_tasks[this_cpu()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you replaced this_task() with g_running_tasks[this_cpu()]. Could you explain under what circumstances these two might not be equal in nxtask_exit?

#endif

sinfo("%s pid=%d,TCB=%p\n", get_task_name(dtcb),
Expand Down
Loading