Assertions: Identify the running task correctly when dumping task state information. It takes time to switch to the target task after g_readytorun has been modified. If panic/assert happen during this period, the dump will contain the incorrect and confusing information due to the difference between the real running task and the return value of this_task(). This change resolve this problem by adding g_running_task to track the real running task through the context switch.

This commit is contained in:
Xiang Xiao
2018-11-15 07:11:51 -06:00
committed by Gregory Nutt
parent a087df2647
commit dbf01d12b7
27 changed files with 107 additions and 67 deletions
+16 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/init/os_start.c
*
* Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2014, 2016, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -140,6 +140,17 @@ volatile dq_queue_t g_readytorun;
*/
volatile dq_queue_t g_assignedtasks[CONFIG_SMP_NCPUS];
/* g_running_tasks[] holds a references to the running task for each cpu.
* It is valid only when up_interrupt_context() returns true.
*/
FAR struct tcb_s *g_running_tasks[CONFIG_SMP_NCPUS];
#else
FAR struct tcb_s *g_running_tasks[1];
#endif
/* This is the list of all tasks that are ready-to-run, but cannot be placed
@@ -546,6 +557,10 @@ void os_start(void)
#endif
dq_addfirst((FAR dq_entry_t *)&g_idletcb[cpu], tasklist);
/* Mark the idle task as the running task */
g_running_tasks[cpu] = &g_idletcb[cpu].cmn;
/* Initialize the processor-specific portion of the TCB */
up_initial_state(&g_idletcb[cpu].cmn);