diff --git a/arch/z80/src/common/up_assert.c b/arch/z80/src/common/up_assert.c index a848172b24c..ee290781e09 100644 --- a/arch/z80/src/common/up_assert.c +++ b/arch/z80/src/common/up_assert.c @@ -91,7 +91,7 @@ static void _up_assert(int errorcode) /* noreturn_function */ { /* Are we in an interrupt handler or the idle task? */ - if (up_interrupt_context() || ((FAR struct tcb_s*)g_readytorun.head)->pid == 0) + if (up_interrupt_context() || this_task()->pid == 0) { (void)irqsave(); for (;;) @@ -150,7 +150,7 @@ void up_assert(void) #endif { #if CONFIG_TASK_NAME_SIZE > 0 - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); #endif board_autoled_on(LED_ASSERTION); @@ -181,7 +181,7 @@ void up_assert(void) #endif #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), g_readytorun.head, filename, lineno); + board_crashdump(up_getsp(), this_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/z80/src/common/up_blocktask.c b/arch/z80/src/common/up_blocktask.c index 5ba6faebd59..831de41317d 100644 --- a/arch/z80/src/common/up_blocktask.c +++ b/arch/z80/src/common/up_blocktask.c @@ -77,7 +77,7 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); bool switch_needed; /* Verify that the context switch can be performed */ @@ -100,7 +100,7 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) sched_addblocked(tcb, (tstate_t)task_state); - /* If there are any pending tasks, then add them to the g_readytorun + /* If there are any pending tasks, then add them to the ready-to-run * task list now */ @@ -128,10 +128,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) SAVE_IRQCONTEXT(rtcb); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Reset scheduler parameters */ @@ -146,17 +146,17 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) } /* Copy the user C context into the TCB at the (old) head of the - * g_readytorun Task list. if SAVE_USERCONTEXT returns a non-zero + * ready-to-run Task list. if SAVE_USERCONTEXT returns a non-zero * value, then this is really the previously running task restarting! */ else if (!SAVE_USERCONTEXT(rtcb)) { /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/z80/src/common/up_exit.c b/arch/z80/src/common/up_exit.c index 2514ceb1240..3488fdbdc83 100644 --- a/arch/z80/src/common/up_exit.c +++ b/arch/z80/src/common/up_exit.c @@ -164,7 +164,7 @@ void _exit(int status) * head of the list. */ - tcb = (FAR struct tcb_s*)g_readytorun.head; + tcb = this_task(); slldbg("New Active Task TCB=%p\n", tcb); #ifdef CONFIG_ARCH_ADDRENV diff --git a/arch/z80/src/common/up_releasepending.c b/arch/z80/src/common/up_releasepending.c index 4350c15dc81..e4bc07a78fb 100644 --- a/arch/z80/src/common/up_releasepending.c +++ b/arch/z80/src/common/up_releasepending.c @@ -68,11 +68,11 @@ void up_release_pending(void) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); slldbg("From TCB=%p\n", rtcb); - /* Merge the g_pendingtasks list into the g_readytorun task list */ + /* Merge the g_pendingtasks list into the ready-to-run task list */ /* sched_lock(); */ if (sched_mergepending()) @@ -96,10 +96,10 @@ void up_release_pending(void) SAVE_IRQCONTEXT(rtcb); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -122,10 +122,10 @@ void up_release_pending(void) else if (!SAVE_USERCONTEXT(rtcb)) { /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/z80/src/common/up_reprioritizertr.c b/arch/z80/src/common/up_reprioritizertr.c index 99ed783d7a7..d7102775631 100644 --- a/arch/z80/src/common/up_reprioritizertr.c +++ b/arch/z80/src/common/up_reprioritizertr.c @@ -95,7 +95,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) } else { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); bool switch_needed; slldbg("TCB=%p PRI=%d\n", tcb, priority); @@ -150,10 +150,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) SAVE_IRQCONTEXT(rtcb); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -168,17 +168,17 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) } /* Copy the exception context into the TCB at the (old) head of the - * g_readytorun Task list. if SAVE_USERCONTEXT returns a non-zero + * ready-to-run Task list. if SAVE_USERCONTEXT returns a non-zero * value, then this is really the previously running task restarting! */ else if (!SAVE_USERCONTEXT(rtcb)) { /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/z80/src/common/up_stackdump.c b/arch/z80/src/common/up_stackdump.c index dc19f76ed8f..32a3fc68302 100644 --- a/arch/z80/src/common/up_stackdump.c +++ b/arch/z80/src/common/up_stackdump.c @@ -78,7 +78,7 @@ static void up_stackdump(void) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); uint16_t sp = up_getsp(); uint16_t stack_base = (uint16_t)rtcb->adj_stack_ptr; uint16_t stack_size = (uint16_t)rtcb->adj_stack_size; diff --git a/arch/z80/src/common/up_unblocktask.c b/arch/z80/src/common/up_unblocktask.c index c0ad48ecac5..f110172052b 100644 --- a/arch/z80/src/common/up_unblocktask.c +++ b/arch/z80/src/common/up_unblocktask.c @@ -74,7 +74,7 @@ void up_unblock_task(FAR struct tcb_s *tcb) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); /* Verify that the context switch can be performed */ @@ -88,7 +88,7 @@ void up_unblock_task(FAR struct tcb_s *tcb) sched_removeblocked(tcb); /* Add the task in the correct location in the prioritized - * g_readytorun task list + * ready-to-run task list */ if (sched_addreadytorun(tcb)) @@ -112,10 +112,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) SAVE_IRQCONTEXT(rtcb); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -139,10 +139,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) { /* Restore the exception context of the new task that is ready to * run (probably tcb). This is the new rtcb at the head of the - * g_readytorun task list. + * ready-to-run task list. */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; + rtcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/z80/src/ez80/ez80_schedulesigaction.c b/arch/z80/src/ez80/ez80_schedulesigaction.c index b98e61701fa..05e634558b7 100644 --- a/arch/z80/src/ez80/ez80_schedulesigaction.c +++ b/arch/z80/src/ez80/ez80_schedulesigaction.c @@ -139,7 +139,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver) * to the currently executing task. */ - if (tcb == (FAR struct tcb_s*)g_readytorun.head) + if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is * signalling itself for some reason. diff --git a/arch/z80/src/ez80/ez80_sigdeliver.c b/arch/z80/src/ez80/ez80_sigdeliver.c index 12db8846aa7..cbd1ad223d8 100644 --- a/arch/z80/src/ez80/ez80_sigdeliver.c +++ b/arch/z80/src/ez80/ez80_sigdeliver.c @@ -82,7 +82,7 @@ void up_sigdeliver(void) { #ifndef CONFIG_DISABLE_SIGNALS - FAR struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); chipreg_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver; diff --git a/arch/z80/src/z180/z180_schedulesigaction.c b/arch/z80/src/z180/z180_schedulesigaction.c index e212bf0ff8f..1ae1af9627f 100644 --- a/arch/z80/src/z180/z180_schedulesigaction.c +++ b/arch/z80/src/z180/z180_schedulesigaction.c @@ -139,7 +139,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver) * to the currently executing task. */ - if (tcb == (FAR struct tcb_s*)g_readytorun.head) + if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is * signalling itself for some reason. diff --git a/arch/z80/src/z180/z180_sigdeliver.c b/arch/z80/src/z180/z180_sigdeliver.c index 58e9aa9c949..076435270d4 100644 --- a/arch/z80/src/z180/z180_sigdeliver.c +++ b/arch/z80/src/z180/z180_sigdeliver.c @@ -81,7 +81,7 @@ void up_sigdeliver(void) { #ifndef CONFIG_DISABLE_SIGNALS - FAR struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); chipreg_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver; diff --git a/arch/z80/src/z8/z8_schedulesigaction.c b/arch/z80/src/z8/z8_schedulesigaction.c index 8d876a52c50..633bdc8bb6e 100644 --- a/arch/z80/src/z8/z8_schedulesigaction.c +++ b/arch/z80/src/z8/z8_schedulesigaction.c @@ -139,7 +139,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver) * to the currently executing task. */ - if (tcb == (FAR struct tcb_s*)g_readytorun.head) + if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is * signalling itself for some reason. diff --git a/arch/z80/src/z8/z8_sigdeliver.c b/arch/z80/src/z8/z8_sigdeliver.c index 6605bba7d5e..5101da26928 100644 --- a/arch/z80/src/z8/z8_sigdeliver.c +++ b/arch/z80/src/z8/z8_sigdeliver.c @@ -96,7 +96,7 @@ static void z8_copystate(FAR chipreg_t *dest, FAR const chipreg_t *src) void up_sigdeliver(void) { #ifndef CONFIG_DISABLE_SIGNALS - FAR struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); chipreg_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver; diff --git a/arch/z80/src/z80/z80_schedulesigaction.c b/arch/z80/src/z80/z80_schedulesigaction.c index f4581314db8..2f11c7e1143 100644 --- a/arch/z80/src/z80/z80_schedulesigaction.c +++ b/arch/z80/src/z80/z80_schedulesigaction.c @@ -139,7 +139,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver) * to the currently executing task. */ - if (tcb == (FAR struct tcb_s*)g_readytorun.head) + if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and a task is * signalling itself for some reason. diff --git a/arch/z80/src/z80/z80_sigdeliver.c b/arch/z80/src/z80/z80_sigdeliver.c index 4e6dafc0bdc..3de591ce4cf 100644 --- a/arch/z80/src/z80/z80_sigdeliver.c +++ b/arch/z80/src/z80/z80_sigdeliver.c @@ -81,7 +81,7 @@ void up_sigdeliver(void) { #ifndef CONFIG_DISABLE_SIGNALS - FAR struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + FAR struct tcb_s *rtcb = this_task(); chipreg_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver;