x86: Replace explict references to g_readytorun with indirect references via the this_task() macro

This commit is contained in:
Gregory Nutt
2016-02-06 17:10:44 -06:00
parent a1126361da
commit b0bcd82ba7
8 changed files with 35 additions and 39 deletions
+4 -8
View File
@@ -89,10 +89,6 @@
# define CONFIG_PRINT_TASKNAME 1
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -150,7 +146,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 = (struct tcb_s*)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@@ -255,7 +251,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 (;;)
@@ -285,7 +281,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@@ -301,7 +297,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#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);
+7 -7
View File
@@ -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_savestate(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();
/* 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
+2 -2
View File
@@ -146,7 +146,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");
@@ -161,7 +161,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
+6 -6
View File
@@ -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_savestate(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();
/* 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
+6 -6
View File
@@ -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_savestate(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();
/* 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
+6 -6
View File
@@ -70,7 +70,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 */
@@ -82,7 +82,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))
@@ -106,10 +106,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(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();
/* Update scheduler parameters */
@@ -132,10 +132,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
+3 -3
View File
@@ -114,9 +114,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (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.
@@ -137,7 +137,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch to
* another task has occurred so that current_regs does not refer to
* the thread at g_readytorun.head!
* the thread of this_task()!
*/
else
+1 -1
View File
@@ -82,7 +82,7 @@
void up_sigdeliver(void)
{
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;