diff --git a/arch/arm/src/arm/up_assert.c b/arch/arm/src/arm/up_assert.c index 9e4b4088d8b..059de0fa0c7 100644 --- a/arch/arm/src/arm/up_assert.c +++ b/arch/arm/src/arm/up_assert.c @@ -190,7 +190,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -310,7 +310,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || this_task()->pid == 0) + if (CURRENT_REGS || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -346,7 +346,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -370,7 +370,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/arm/src/armv6-m/up_assert.c b/arch/arm/src/armv6-m/up_assert.c index 56bcde7c9d3..1f487b286a9 100644 --- a/arch/arm/src/armv6-m/up_assert.c +++ b/arch/arm/src/armv6-m/up_assert.c @@ -227,7 +227,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -367,7 +367,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || this_task()->pid == 0) + if (CURRENT_REGS || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -403,7 +403,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -427,7 +427,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index 1c6acda57ca..3d6781a26b8 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -228,7 +228,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -395,7 +395,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || this_task()->pid == 0) + if (CURRENT_REGS || running_task()->pid == 0) { /* Disable interrupts on this CPU */ @@ -442,7 +442,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -476,7 +476,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/arm/src/armv7-m/up_assert.c b/arch/arm/src/armv7-m/up_assert.c index 96fef46dbf3..10ddd6a0c6c 100644 --- a/arch/arm/src/armv7-m/up_assert.c +++ b/arch/arm/src/armv7-m/up_assert.c @@ -235,7 +235,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -389,7 +389,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || (this_task())->pid == 0) + if (CURRENT_REGS || (running_task())->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -431,7 +431,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -465,7 +465,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/arm/src/armv7-r/arm_assert.c b/arch/arm/src/armv7-r/arm_assert.c index c4d7c169545..2c7163aee22 100644 --- a/arch/arm/src/armv7-r/arm_assert.c +++ b/arch/arm/src/armv7-r/arm_assert.c @@ -224,7 +224,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -374,7 +374,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || (this_task())->pid == 0) + if (CURRENT_REGS || (running_task())->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -410,7 +410,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -434,7 +434,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/avr/src/avr/up_dumpstate.c b/arch/avr/src/avr/up_dumpstate.c index 7893419d69b..effb20d4210 100644 --- a/arch/avr/src/avr/up_dumpstate.c +++ b/arch/avr/src/avr/up_dumpstate.c @@ -160,7 +160,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint16_t sp = up_getsp(); uint16_t ustackbase; uint16_t ustacksize; diff --git a/arch/avr/src/avr32/up_dumpstate.c b/arch/avr/src/avr32/up_dumpstate.c index 13aa72c77f1..5a0696f6681 100644 --- a/arch/avr/src/avr32/up_dumpstate.c +++ b/arch/avr/src/avr32/up_dumpstate.c @@ -126,7 +126,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/avr/src/common/up_assert.c b/arch/avr/src/common/up_assert.c index c7bf7af932f..cd67e8483de 100644 --- a/arch/avr/src/common/up_assert.c +++ b/arch/avr/src/common/up_assert.c @@ -87,7 +87,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || this_task()->pid == 0) + if (g_current_regs || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -172,7 +172,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif #ifdef CONFIG_ARCH_USBDUMP diff --git a/arch/hc/src/m9s12/m9s12_assert.c b/arch/hc/src/m9s12/m9s12_assert.c index aea6a309556..8496741a70e 100644 --- a/arch/hc/src/m9s12/m9s12_assert.c +++ b/arch/hc/src/m9s12/m9s12_assert.c @@ -184,7 +184,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint16_t sp = up_getsp(); uint16_t ustackbase; uint16_t ustacksize; @@ -294,7 +294,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || (this_task())->pid == 0) + if (g_current_regs || (running_task())->pid == 0) { (void)up_irq_save(); for (;;) @@ -330,7 +330,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -354,7 +354,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/mips/src/mips32/up_assert.c b/arch/mips/src/mips32/up_assert.c index 890f081487b..356d6786319 100644 --- a/arch/mips/src/mips32/up_assert.c +++ b/arch/mips/src/mips32/up_assert.c @@ -86,7 +86,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || this_task()->pid == 0) + if (g_current_regs || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -147,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -177,7 +177,7 @@ void up_assert(const uint8_t *filename, int lineno) #endif #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/mips/src/mips32/up_dumpstate.c b/arch/mips/src/mips32/up_dumpstate.c index ba1d1ccfbec..a74da499315 100644 --- a/arch/mips/src/mips32/up_dumpstate.c +++ b/arch/mips/src/mips32/up_dumpstate.c @@ -139,7 +139,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/misoc/src/lm32/lm32_assert.c b/arch/misoc/src/lm32/lm32_assert.c index 3f66f2d74c6..b23a9f518fe 100644 --- a/arch/misoc/src/lm32/lm32_assert.c +++ b/arch/misoc/src/lm32/lm32_assert.c @@ -87,7 +87,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || this_task()->pid == 0) + if (g_current_regs || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -178,7 +178,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/misoc/src/lm32/lm32_dumpstate.c b/arch/misoc/src/lm32/lm32_dumpstate.c index 96a25c323d7..4b9bb977bae 100644 --- a/arch/misoc/src/lm32/lm32_dumpstate.c +++ b/arch/misoc/src/lm32/lm32_dumpstate.c @@ -135,7 +135,7 @@ static inline void up_registerdump(void) void lm32_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/or1k/src/common/up_assert.c b/arch/or1k/src/common/up_assert.c index b01704a0b4e..9845d2ff8eb 100644 --- a/arch/or1k/src/common/up_assert.c +++ b/arch/or1k/src/common/up_assert.c @@ -232,7 +232,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -372,7 +372,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || this_task()->pid == 0) + if (CURRENT_REGS || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -408,7 +408,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -432,7 +432,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/renesas/src/common/up_assert.c b/arch/renesas/src/common/up_assert.c index ac214875c6b..c5ff8c991da 100644 --- a/arch/renesas/src/common/up_assert.c +++ b/arch/renesas/src/common/up_assert.c @@ -88,7 +88,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || this_task()->pid == 0) + if (g_current_regs || running_task()->pid == 0) { (void)up_irq_save(); for (;;) @@ -149,7 +149,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -179,7 +179,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/renesas/src/m16c/m16c_dumpstate.c b/arch/renesas/src/m16c/m16c_dumpstate.c index 5e67741aaca..0bf822f475e 100644 --- a/arch/renesas/src/m16c/m16c_dumpstate.c +++ b/arch/renesas/src/m16c/m16c_dumpstate.c @@ -151,7 +151,7 @@ static inline void m16c_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint16_t sp = m16c_getsp(); uint16_t ustackbase; uint16_t ustacksize; diff --git a/arch/renesas/src/sh1/sh1_dumpstate.c b/arch/renesas/src/sh1/sh1_dumpstate.c index 84c512e7739..8476d97040c 100644 --- a/arch/renesas/src/sh1/sh1_dumpstate.c +++ b/arch/renesas/src/sh1/sh1_dumpstate.c @@ -141,7 +141,7 @@ static inline void sh1_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = sh1_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/risc-v/src/rv32im/up_assert.c b/arch/risc-v/src/rv32im/up_assert.c index a46ac79b9c0..07d7dd55631 100644 --- a/arch/risc-v/src/rv32im/up_assert.c +++ b/arch/risc-v/src/rv32im/up_assert.c @@ -87,7 +87,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || this_task()->pid == 0) + if (g_current_regs || running_task()->pid == 0) { (void)up_irq_save(); for (; ; ) @@ -148,7 +148,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -178,7 +178,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/risc-v/src/rv32im/up_dumpstate.c b/arch/risc-v/src/rv32im/up_dumpstate.c index 795f7933673..20de866b2ea 100644 --- a/arch/risc-v/src/rv32im/up_dumpstate.c +++ b/arch/risc-v/src/rv32im/up_dumpstate.c @@ -144,7 +144,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c index c2182bba1c5..1566b70586e 100644 --- a/arch/x86/src/common/up_assert.c +++ b/arch/x86/src/common/up_assert.c @@ -135,7 +135,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; @@ -255,7 +255,7 @@ static void _up_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (g_current_regs || (this_task())->pid == 0) + if (g_current_regs || (running_task())->pid == 0) { (void)up_irq_save(); for (;;) @@ -291,7 +291,7 @@ static void _up_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -315,7 +315,7 @@ void up_assert(const uint8_t *filename, int lineno) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/xtensa/src/common/xtensa_assert.c b/arch/xtensa/src/common/xtensa_assert.c index f5f36518b05..850996bf362 100644 --- a/arch/xtensa/src/common/xtensa_assert.c +++ b/arch/xtensa/src/common/xtensa_assert.c @@ -117,7 +117,7 @@ static void xtensa_assert(int errorcode) #ifdef CONFIG_BOARD_CRASHDUMP /* Perform board-specific crash dump */ - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif /* Flush any buffered SYSLOG data (from the above) */ @@ -126,7 +126,7 @@ static void xtensa_assert(int errorcode) /* Are we in an interrupt handler or the idle task? */ - if (CURRENT_REGS || this_task()->pid == 0) + if (CURRENT_REGS || running_task()->pid == 0) { /* Blink the LEDs forever */ @@ -166,7 +166,7 @@ static void xtensa_assert(int errorcode) void up_assert(const uint8_t *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -211,7 +211,7 @@ void up_assert(const uint8_t *filename, int lineno) void xtensa_panic(int xptcode, uint32_t *regs) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif /* We get here when a un-dispatch-able, irrecoverable exception occurs */ @@ -315,7 +315,7 @@ void xtensa_panic(int xptcode, uint32_t *regs) void xtensa_user(int exccause, uint32_t *regs) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif /* We get here when a un-dispatch-able, irrecoverable exception occurs */ diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index bb34dedaeb5..c47049c9e73 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -193,7 +193,7 @@ static inline void xtensa_registerdump(void) void xtensa_dumpstate(void) { - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = xtensa_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/z16/src/common/up_assert.c b/arch/z16/src/common/up_assert.c index baabf551bc1..c26d04f1612 100644 --- a/arch/z16/src/common/up_assert.c +++ b/arch/z16/src/common/up_assert.c @@ -87,7 +87,7 @@ static void _up_assert(int errorcode) /* noreturn_function */ /* Are we in an interrupt handler or the idle task? */ - if (up_interrupt_context() || this_task()->pid == 0) + if (up_interrupt_context() || running_task()->pid == 0) { (void)up_irq_save(); for (;;) @@ -152,7 +152,7 @@ void up_assert(void) #endif { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -191,7 +191,7 @@ void up_assert(void) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/z80/src/common/up_assert.c b/arch/z80/src/common/up_assert.c index 7df2e07889a..f770d4b9e43 100644 --- a/arch/z80/src/common/up_assert.c +++ b/arch/z80/src/common/up_assert.c @@ -86,7 +86,7 @@ static void _up_assert(int errorcode) /* noreturn_function */ /* Are we in an interrupt handler or the idle task? */ - if (up_interrupt_context() || this_task()->pid == 0) + if (up_interrupt_context() || running_task()->pid == 0) { (void)up_irq_save(); for (;;) @@ -151,7 +151,7 @@ void up_assert(void) #endif { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = running_task(); #endif board_autoled_on(LED_ASSERTION); @@ -190,7 +190,7 @@ void up_assert(void) (void)syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), this_task(), filename, lineno); + board_crashdump(up_getsp(), running_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/sched/init/os_start.c b/sched/init/os_start.c index d4a105b1350..6faaa85c3a6 100644 --- a/sched/init/os_start.c +++ b/sched/init/os_start.c @@ -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 * * 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); diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index afb19fac2c0..e217c8bc79a 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -46,6 +46,7 @@ #include "irq/irq.h" #include "clock/clock.h" +#include "sched/sched.h" /**************************************************************************** * Pre-processor Definitions @@ -159,4 +160,10 @@ void irq_dispatch(int irq, FAR void *context) CALL_VECTOR(ndx, vector, irq, context, arg); UNUSED(ndx); + + /* Record the new "running" task. g_running_tasks[] is only used by + * assertion logic for reporting crashes. + */ + + g_running_tasks[this_cpu()] = this_task(); } diff --git a/sched/sched/sched.h b/sched/sched/sched.h index 038398472a6..f84adcf9922 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -89,6 +89,13 @@ # define this_task() (current_task(this_cpu())) #endif +/* This macro returns the running task which may different from this_task() + * during interrupt level context switches. + */ + +#define running_task() \ + (up_interrupt_context() ? g_running_tasks[this_cpu()] : this_task()) + /* List attribute flags */ #define TLIST_ATTR_PRIORITIZED (1 << 0) /* Bit 0: List is prioritized */ @@ -201,6 +208,17 @@ extern volatile dq_queue_t g_readytorun; */ extern 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. + */ + +extern FAR struct tcb_s *g_running_tasks[CONFIG_SMP_NCPUS]; + +#else + +extern 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