sim: 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:05:55 -06:00
parent edc51a14cd
commit a1126361da
7 changed files with 20 additions and 32 deletions

View File

@ -75,7 +75,7 @@
void up_block_task(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(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
*/
@ -116,17 +116,17 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_suspend_scheduler(rtcb);
/* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_setjmp returns a non-zero
* ready-to-run Task list. if up_setjmp returns a non-zero
* value, then this is really the previously running task restarting!
*/
if (!up_setjmp(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 = (FAR struct tcb_s *)g_readytorun.head;
rtcb = this_task();
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -48,18 +48,6 @@
#include "sched/sched.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -89,7 +77,7 @@ void _exit(int status)
* head of the list.
*/
tcb = (FAR struct tcb_s *)g_readytorun.head;
tcb = this_task();
sdbg("New Active Task TCB=%p\n", tcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -112,7 +112,7 @@ void up_assert(const uint8_t *filename, int line)
/* Allow for any board/configuration specific crash information */
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, line);
board_crashdump(up_getsp(), this_task(), filename, line);
#endif
/* Exit the simulation */

View File

@ -64,11 +64,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();
sdbg("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())
@ -89,10 +89,10 @@ void up_release_pending(void)
if (!up_setjmp(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 = (FAR struct tcb_s *)g_readytorun.head;
rtcb = this_task();
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -92,7 +92,7 @@ void up_reprioritize_rtr(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;
sdbg("TCB=%p PRI=%d\n", tcb, priority);
@ -137,17 +137,17 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_suspend_scheduler(rtcb);
/* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_setjmp returns a non-zero
* ready-to-run Task list. if up_setjmp returns a non-zero
* value, then this is really the previously running task restarting!
*/
if (!up_setjmp(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 = (FAR struct tcb_s *)g_readytorun.head;
rtcb = this_task();
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -100,7 +100,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
{
/* We don't have to anything complex for the simulated target */
if (tcb == (FAR struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
sigdeliver(tcb);
}

View File

@ -70,7 +70,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_resume_scheduler(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(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();
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of