diff --git a/arch/sh/src/common/up_assert.c b/arch/sh/src/common/up_assert.c index 3499e9404d..523be95688 100644 --- a/arch/sh/src/common/up_assert.c +++ b/arch/sh/src/common/up_assert.c @@ -93,7 +93,7 @@ static void _up_assert(int errorcode) { /* Are we in an interrupt handler or the idle task? */ - if (current_regs || ((struct tcb_s*)g_readytorun.head)->pid == 0) + if (current_regs || this_task()->pid == 0) { (void)irqsave(); 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) - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); #endif board_autoled_on(LED_ASSERTION); @@ -170,7 +170,7 @@ void up_assert(const uint8_t *filename, int lineno) #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/sh/src/common/up_blocktask.c b/arch/sh/src/common/up_blocktask.c index 342e8948ef..3ba48846d5 100644 --- a/arch/sh/src/common/up_blocktask.c +++ b/arch/sh/src/common/up_blocktask.c @@ -75,7 +75,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); bool switch_needed; /* Verify that the context switch can be performed */ @@ -96,7 +96,7 @@ void up_block_task(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 */ @@ -124,10 +124,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) up_copystate(rtcb->xcp.regs, current_regs); /* 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 = (struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Reset scheduler parameters */ @@ -141,17 +141,17 @@ void up_block_task(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 up_saveusercontext returns a non-zero + * ready-to-run Task list. if up_saveusercontext returns a non-zero * value, then this is really the previously running task restarting! */ else if (!up_saveusercontext(rtcb->xcp.regs)) { /* 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 = (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/sh/src/common/up_exit.c b/arch/sh/src/common/up_exit.c index d923724ae8..4f7e4ab049 100644 --- a/arch/sh/src/common/up_exit.c +++ b/arch/sh/src/common/up_exit.c @@ -147,7 +147,7 @@ void _exit(int status) (void)irqsave(); - slldbg("TCB=%p exiting\n", g_readytorun.head); + slldbg("TCB=%p exiting\n", this_task()); #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) slldbg("Other tasks:\n"); @@ -162,7 +162,7 @@ void _exit(int status) * head of the list. */ - tcb = (struct tcb_s*)g_readytorun.head; + tcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously running diff --git a/arch/sh/src/common/up_releasepending.c b/arch/sh/src/common/up_releasepending.c index 3c312b5fff..d080e89dfb 100644 --- a/arch/sh/src/common/up_releasepending.c +++ b/arch/sh/src/common/up_releasepending.c @@ -65,11 +65,11 @@ void up_release_pending(void) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + 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()) @@ -93,10 +93,10 @@ void up_release_pending(void) up_copystate(rtcb->xcp.regs, current_regs); /* 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 = (struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -118,10 +118,10 @@ void up_release_pending(void) else if (!up_saveusercontext(rtcb->xcp.regs)) { /* 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 = (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/sh/src/common/up_reprioritizertr.c b/arch/sh/src/common/up_reprioritizertr.c index 4154d45583..9986a0cd5d 100644 --- a/arch/sh/src/common/up_reprioritizertr.c +++ b/arch/sh/src/common/up_reprioritizertr.c @@ -92,7 +92,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) } else { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); bool switch_needed; slldbg("TCB=%p PRI=%d\n", tcb, priority); @@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) up_copystate(rtcb->xcp.regs, current_regs); /* 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 = (struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -164,17 +164,17 @@ void up_reprioritize_rtr(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 up_saveusercontext returns a non-zero + * ready-to-run Task list. if up_saveusercontext returns a non-zero * value, then this is really the previously running task restarting! */ else if (!up_saveusercontext(rtcb->xcp.regs)) { /* 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 = (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/sh/src/common/up_unblocktask.c b/arch/sh/src/common/up_unblocktask.c index dd862a7b7d..182cdcdd46 100644 --- a/arch/sh/src/common/up_unblocktask.c +++ b/arch/sh/src/common/up_unblocktask.c @@ -71,7 +71,7 @@ void up_unblock_task(struct tcb_s *tcb) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + struct tcb_s *rtcb = this_task(); /* Verify that the context switch can be performed */ @@ -83,7 +83,7 @@ void up_unblock_task(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)) @@ -107,10 +107,10 @@ void up_unblock_task(struct tcb_s *tcb) up_copystate(rtcb->xcp.regs, current_regs); /* 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 = (struct tcb_s*)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -133,10 +133,10 @@ void up_unblock_task(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 = (struct tcb_s*)g_readytorun.head; + rtcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously