diff --git a/arch/z16/src/common/up_assert.c b/arch/z16/src/common/up_assert.c index 45537de5993..4ad4d77fdde 100644 --- a/arch/z16/src/common/up_assert.c +++ b/arch/z16/src/common/up_assert.c @@ -76,10 +76,6 @@ # undef CONFIG_ARCH_USBDUMP #endif -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -92,7 +88,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 (;;) @@ -151,7 +147,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); @@ -182,7 +178,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/z16/src/common/up_blocktask.c b/arch/z16/src/common/up_blocktask.c index 4685da2ebe3..e165e74a730 100644 --- a/arch/z16/src/common/up_blocktask.c +++ b/arch/z16/src/common/up_blocktask.c @@ -75,7 +75,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 */ @@ -98,7 +98,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 */ @@ -126,10 +126,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 */ @@ -143,17 +143,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(); /* Reset scheduler parameters */ diff --git a/arch/z16/src/common/up_exit.c b/arch/z16/src/common/up_exit.c index bbdab6015f2..3d7313dbf6d 100644 --- a/arch/z16/src/common/up_exit.c +++ b/arch/z16/src/common/up_exit.c @@ -53,14 +53,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -162,7 +154,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); /* Then switch contexts */ diff --git a/arch/z16/src/common/up_releasepending.c b/arch/z16/src/common/up_releasepending.c index bdd03546377..2d0e09b5ac3 100644 --- a/arch/z16/src/common/up_releasepending.c +++ b/arch/z16/src/common/up_releasepending.c @@ -66,11 +66,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()) @@ -94,10 +94,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 */ @@ -119,10 +119,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(); /* Update scheduler parameters */ diff --git a/arch/z16/src/common/up_reprioritizertr.c b/arch/z16/src/common/up_reprioritizertr.c index 1ceea43d54d..4872db37f26 100644 --- a/arch/z16/src/common/up_reprioritizertr.c +++ b/arch/z16/src/common/up_reprioritizertr.c @@ -93,7 +93,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); @@ -148,10 +148,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 */ @@ -165,17 +165,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(); /* Update scheduler parameters */ diff --git a/arch/z16/src/common/up_schedulesigaction.c b/arch/z16/src/common/up_schedulesigaction.c index f71d6be7eb5..63af438d733 100644 --- a/arch/z16/src/common/up_schedulesigaction.c +++ b/arch/z16/src/common/up_schedulesigaction.c @@ -51,18 +51,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -118,9 +106,9 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver) * being delivered to the currently executing task. */ - dbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs); + dbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs); - 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/z16/src/common/up_sigdeliver.c b/arch/z16/src/common/up_sigdeliver.c index 0fc52262737..df00c1c1b47 100644 --- a/arch/z16/src/common/up_sigdeliver.c +++ b/arch/z16/src/common/up_sigdeliver.c @@ -53,18 +53,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -82,7 +70,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]; FAR uint32_t *regs32 = (FAR uint32_t*)regs; sig_deliver_t sigdeliver; diff --git a/arch/z16/src/common/up_stackdump.c b/arch/z16/src/common/up_stackdump.c index ee70a0c040d..f6d9e41236d 100644 --- a/arch/z16/src/common/up_stackdump.c +++ b/arch/z16/src/common/up_stackdump.c @@ -54,14 +54,6 @@ #ifdef CONFIG_ARCH_STACKDUMP -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -77,7 +69,7 @@ static void up_stackdump(void) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); chipreg_t sp = up_getsp(); chipreg_t stack_base = (chipreg_t)rtcb->adj_stack_ptr; chipreg_t stack_size = (chipreg_t)rtcb->adj_stack_size; diff --git a/arch/z16/src/common/up_unblocktask.c b/arch/z16/src/common/up_unblocktask.c index b222f4f91c4..96eb7675ac5 100644 --- a/arch/z16/src/common/up_unblocktask.c +++ b/arch/z16/src/common/up_unblocktask.c @@ -72,7 +72,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 */ @@ -86,7 +86,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)) @@ -110,10 +110,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 */ @@ -136,10 +136,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(); /* Update scheduler parameters */