Add ADDRENV support to ALL implementations of up_unblock_task()

This commit is contained in:
Gregory Nutt 2014-08-27 16:15:46 -06:00
parent 0b919b6381
commit 4d24c48901
9 changed files with 200 additions and 22 deletions

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/arm/up_unblocktask.c * arch/arm/src/arm/up_unblocktask.c
* *
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -75,7 +76,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -129,6 +130,16 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -146,6 +157,15 @@ void up_unblock_task(struct tcb_s *tcb)
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-a/arm_unblocktask.c * arch/arm/src/armv7-a/arm_unblocktask.c
* *
* Copyright (C) 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -75,7 +76,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -129,6 +130,16 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -146,6 +157,15 @@ void up_unblock_task(struct tcb_s *tcb)
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/avr/src/avr32/up_unblocktask.c * arch/avr/src/avr32/up_unblocktask.c
* *
* Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -75,7 +76,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -129,17 +130,40 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* No, then we will need to perform the user context switch */ /* No, then we will need to perform the user context switch */
else else
{ {
/* Switch context to the context of the task at the head of the /* Restore the exception context of the new task that is ready to
* ready to run list. * run (probably tcb). This is the new rtcb at the head of the
* g_readytorun task list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(nexttcb);
#endif
/* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
/* up_switchcontext forces a context switch to the task at the /* up_switchcontext forces a context switch to the task at the

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/hc/src/common/up_unblocktask.c * arch/hc/src/common/up_unblocktask.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -75,7 +76,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -129,6 +130,16 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -146,6 +157,15 @@ void up_unblock_task(struct tcb_s *tcb)
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/mips/src/mips32/up_unblocktask.c * arch/mips/src/mips32/up_unblocktask.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -77,7 +78,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -131,17 +132,40 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* No, then we will need to perform the user context switch */ /* No, then we will need to perform the user context switch */
else else
{ {
/* Switch context to the context of the task at the head of the /* Restore the exception context of the new task that is ready to
* ready to run list. * run (probably tcb). This is the new rtcb at the head of the
* g_readytorun task list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(nexttcb);
#endif
/* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
/* up_switchcontext forces a context switch to the task at the /* up_switchcontext forces a context switch to the task at the

View File

@ -288,6 +288,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
warn("Disable preemption failed for task block itself\n"); warn("Disable preemption failed for task block itself\n");
sched_mergepending(); sched_mergepending();
} }
nexttcb = (struct tcb_s*)g_readytorun.head; nexttcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
@ -344,8 +345,19 @@ void up_unblock_task(struct tcb_s *tcb)
// g_readytorun task list. // g_readytorun task list.
if (sched_addreadytorun(tcb) && !up_interrupt_context()) { if (sched_addreadytorun(tcb) && !up_interrupt_context()) {
/* The currently active task has changed! */ /* The currently active task has changed! */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
// Make sure that the address environment for the previously
// running task is closed down gracefully (data caches dump,
// MMU flushed) and set up the address environment for the new
// thread at the head of the ready-to-run list.
(void)group_addrenv(nexttcb);
#endif
// context switch // context switch
up_switchcontext(rtcb, nexttcb); up_switchcontext(rtcb, nexttcb);
} }
} }

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/sh/src/common/up_unblocktask.c * arch/sh/src/common/up_unblocktask.c
* *
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -75,7 +76,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -129,6 +130,16 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
current_regs = rtcb->xcp.regs; current_regs = rtcb->xcp.regs;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -146,6 +157,15 @@ void up_unblock_task(struct tcb_s *tcb)
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/x86/src/common/up_unblocktask.c * arch/x86/src/common/up_unblocktask.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -74,7 +75,7 @@
* Inputs: * Inputs:
* tcb: Refers to the tcb to be unblocked. This tcb is in one of the * tcb: Refers to the tcb to be unblocked. This tcb is in one of the
* waiting tasks lists. It must be moved to the ready-to-run list and, * waiting tasks lists. It must be moved to the ready-to-run list and,
* if it is the highest priority ready to run taks, executed. * if it is the highest priority ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -128,6 +129,16 @@ void up_unblock_task(struct tcb_s *tcb)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); up_restorestate(rtcb->xcp.regs);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -145,6 +156,15 @@ void up_unblock_task(struct tcb_s *tcb)
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/z80/src/common/up_unblocktask.c * arch/z80/src/common/up_unblocktask.c
* *
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -47,6 +47,7 @@
#include "chip/chip.h" #include "chip/chip.h"
#include "chip/switch.h" #include "chip/switch.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "clock/clock.h" #include "clock/clock.h"
#include "up_internal.h" #include "up_internal.h"
@ -78,7 +79,7 @@
* tcb: Refers to the tcb to be unblocked. This tcb is * tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to * in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority * the ready-to-run list and, if it is the highest priority
* ready to run taks, executed. * ready to run task, executed.
* *
****************************************************************************/ ****************************************************************************/
@ -130,13 +131,22 @@ void up_unblock_task(FAR struct tcb_s *tcb)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
/* dbg("New Active Task TCB=%p\n", rtcb); */
/* Then setup so that the context will be performed on exit /* Then setup so that the context will be performed on exit
* from the interrupt. * from the interrupt.
*/ */
SET_IRQCONTEXT(rtcb); SET_IRQCONTEXT(rtcb);
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
} }
/* We are not in an interrupt handler. Copy the user C context /* We are not in an interrupt handler. Copy the user C context
@ -153,8 +163,16 @@ void up_unblock_task(FAR struct tcb_s *tcb)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
/* dbg("New Active Task TCB=%p\n", rtcb); */
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
* MMU flushed) and set up the address environment for the new
* thread at the head of the ready-to-run list.
*/
(void)group_addrenv(rtcb);
#endif
/* Then switch contexts */ /* Then switch contexts */
RESTORE_USERCONTEXT(rtcb); RESTORE_USERCONTEXT(rtcb);