Add scheduler resume/suspend calls to all implementations of up_reprioritize_rtr()

This commit is contained in:
Gregory Nutt
2015-07-26 09:46:28 -06:00
parent 838c5355eb
commit 37969b8279
14 changed files with 258 additions and 252 deletions
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/arm/up_reprioritizertr.c * arch/arm/src/arm/up_reprioritizertr.c
* *
* Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -179,7 +174,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -190,6 +184,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);
+15 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv6-m/up_reprioritizertr.c * arch/arm/src/armv6-m/up_reprioritizertr.c
* *
* Copyright (C) 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2013, 2015 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
@@ -48,18 +48,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
@@ -169,11 +164,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
else else
{ {
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
/* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* Switch context to the context of the task at the head of the /* Switch context to the context of the task at the head of the
* ready to run list. * ready to run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
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
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-a/arm_reprioritizertr.c * arch/arm/src/armv7-a/arm_reprioritizertr.c
* *
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -179,7 +174,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -190,6 +184,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);
+15 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-m/up_reprioritizertr.c * arch/arm/src/armv7-m/up_reprioritizertr.c
* *
* Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2012-2013, 2015 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
@@ -48,18 +48,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
@@ -169,11 +164,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
else else
{ {
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
/* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* Switch context to the context of the task at the head of the /* Switch context to the context of the task at the head of the
* ready to run list. * ready to run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
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
+15 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/avr/src/avr/up_reprioritizertr.c * arch/avr/src/avr/up_reprioritizertr.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013, 2015 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
@@ -48,18 +48,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -142,6 +130,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -157,7 +149,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
@@ -168,11 +163,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
else else
{ {
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
/* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* Switch context to the context of the task at the head of the /* Switch context to the context of the task at the head of the
* ready to run list. * ready to run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
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
+13 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/avr/src/avr32/up_reprioritizertr.c * arch/avr/src/avr32/up_reprioritizertr.c
* *
* Copyright (C) 2010, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -186,6 +181,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(nexttcb); (void)group_addrenv(nexttcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* Then switch contexts */ /* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/hc/src/common/up_reprioritizertr.c * arch/hc/src/common/up_reprioritizertr.c
* *
* Copyright (C) 2010, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -179,7 +174,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -190,6 +184,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);
+13 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/mips/src/mips32/up_reprioritizertr.c * arch/mips/src/mips32/up_reprioritizertr.c
* *
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013-2015 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
@@ -51,18 +51,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -145,6 +133,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -160,7 +152,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -188,6 +183,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(nexttcb); (void)group_addrenv(nexttcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* Then switch contexts */ /* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
+37 -11
View File
@@ -59,23 +59,26 @@
struct tcb_s *current_task = NULL; struct tcb_s *current_task = NULL;
/** /* This function is called in non-interrupt context
* This function is called in non-interrupt context
* to switch tasks. * to switch tasks.
* Assumption: global interrupt is disabled. * Assumption: global interrupt is disabled.
*/ */
static inline void up_switchcontext(struct tcb_s *ctcb, struct tcb_s *ntcb) static inline void up_switchcontext(struct tcb_s *ctcb, struct tcb_s *ntcb)
{ {
// do nothing if two tasks are the same // do nothing if two tasks are the same
if (ctcb == ntcb) if (ctcb == ntcb)
return; return;
// this function can not be called in interrupt // this function can not be called in interrupt
if (up_interrupt_context()) { if (up_interrupt_context()) {
panic("%s: try to switch context in interrupt\n", __func__); panic("%s: try to switch context in interrupt\n", __func__);
} }
// start switch // start switch
current_task = ntcb; current_task = ntcb;
rgmp_context_switch(ctcb ? &ctcb->xcp.ctx : NULL, &ntcb->xcp.ctx); rgmp_context_switch(ctcb ? &ctcb->xcp.ctx : NULL, &ntcb->xcp.ctx);
} }
@@ -434,11 +437,13 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
#if SCHED_PRIORITY_MAX < UINT8_MAX #if SCHED_PRIORITY_MAX < UINT8_MAX
|| priority > SCHED_PRIORITY_MAX || priority > SCHED_PRIORITY_MAX
#endif #endif
) { )
{
warn("%s: task sched error\n", __func__); warn("%s: task sched error\n", __func__);
return; return;
} }
else { else
{
struct tcb_s *rtcb = current_task; struct tcb_s *rtcb = current_task;
bool switch_needed; bool switch_needed;
@@ -446,9 +451,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
* sched_removereadytorun will return true if we just * sched_removereadytorun will return true if we just
* remove the head of the ready to run list. * remove the head of the ready to run list.
*/ */
switch_needed = sched_removereadytorun(tcb); switch_needed = sched_removereadytorun(tcb);
/* Setup up the new task priority */ /* Setup up the new task priority */
tcb->sched_priority = (uint8_t)priority; tcb->sched_priority = (uint8_t)priority;
/* Return the task to the specified blocked task list. /* Return the task to the specified blocked task list.
@@ -458,21 +465,35 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
* (i.e., one and only one the calls changes the head of the * (i.e., one and only one the calls changes the head of the
* ready-to-run list). * ready-to-run list).
*/ */
switch_needed ^= sched_addreadytorun(tcb); switch_needed ^= sched_addreadytorun(tcb);
/* Now, perform the context switch if one is needed */ /* Now, perform the context switch if one is needed */
if (switch_needed && !up_interrupt_context()) {
if (switch_needed && !up_interrupt_context())
{
struct tcb_s *nexttcb; struct tcb_s *nexttcb;
// If there are any pending tasks, then add them to the g_readytorun
// task list now. It should be the up_realease_pending() called from /* If there are any pending tasks, then add them to the g_readytorun
// sched_unlock() to do this for disable preemption. But it block * task list now. It should be the up_realease_pending() called from
// itself, so it's OK. * sched_unlock() to do this for disable preemption. But it block
if (g_pendingtasks.head) { * itself, so it's OK.
*/
if (g_pendingtasks.head)
{
warn("Disable preemption failed for reprioritize task\n"); warn("Disable preemption failed for reprioritize task\n");
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Get the TCB of the new task to run */
nexttcb = (struct tcb_s*)g_readytorun.head; nexttcb = (struct tcb_s*)g_readytorun.head;
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump, * running task is closed down gracefully (data caches dump,
@@ -482,7 +503,12 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(nexttcb); (void)group_addrenv(nexttcb);
#endif #endif
// context switch /* Update scheduler parameters */
sched_resume_scheduler(nexttcb);
/* context switch */
up_switchcontext(rtcb, nexttcb); up_switchcontext(rtcb, nexttcb);
} }
} }
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/sh/src/common/up_reprioritizertr.c * arch/sh/src/common/up_reprioritizertr.c
* *
* Copyright (C) 2008-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2011, 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -179,7 +174,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -190,6 +184,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);
+9 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/sim/src/up_reprioritizertr.c * arch/sim/src/up_reprioritizertr.c
* *
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2013, 2015 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
@@ -49,18 +49,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Copy the exception context into the TCB at the (old) head of the /* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_setjmp returns a non-zero * g_readytorun Task list. if up_setjmp returns a non-zero
* value, then this is really the previously running task restarting! * value, then this is really the previously running task restarting!
@@ -169,6 +161,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
rtcb->xcp.sigdeliver = NULL; rtcb->xcp.sigdeliver = NULL;
} }
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_longjmp(rtcb->xcp.regs, 1); up_longjmp(rtcb->xcp.regs, 1);
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/arm/up_reprioritizertr.c * arch/arm/src/arm/up_reprioritizertr.c
* *
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013-2015 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
@@ -49,18 +49,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (current_regs) if (current_regs)
@@ -158,7 +150,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts. Any necessary address environment /* Then switch contexts. Any necessary address environment
* changes will be made when the interrupt returns. * changes will be made when the interrupt returns.
@@ -179,7 +174,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (struct tcb_s*)g_readytorun.head; rtcb = (struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -190,6 +184,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* common/up_reprioritizertr.c * common/up_reprioritizertr.c
* *
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2013, 2015 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
@@ -50,18 +50,6 @@
#include "sched/sched.h" #include "sched/sched.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -144,6 +132,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (IN_INTERRUPT) if (IN_INTERRUPT)
@@ -159,7 +151,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(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.
@@ -180,7 +175,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
+13 -15
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/z80/src/common/up_reprioritizertr.c * arch/z80/src/common/up_reprioritizertr.c
* *
* Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2013-2015 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
@@ -52,18 +52,6 @@
#include "group/group.h" #include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -146,6 +134,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
sched_mergepending(); sched_mergepending();
} }
/* Update scheduler parameters */
sched_suspend_scheduler(rtcb);
/* Are we in an interrupt handler? */ /* Are we in an interrupt handler? */
if (IN_INTERRUPT()) if (IN_INTERRUPT())
@@ -161,7 +153,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
/* Update scheduler parameters */
sched_resume_scheduler(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. Any necessary address environment * from the interrupt. Any necessary address environment
@@ -183,7 +178,6 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
slldbg("New Active Task TCB=%p\n", rtcb);
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously
@@ -194,6 +188,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority)
(void)group_addrenv(rtcb); (void)group_addrenv(rtcb);
#endif #endif
/* Update scheduler parameters */
sched_resume_scheduler(rtcb);
/* Then switch contexts */ /* Then switch contexts */
RESTORE_USERCONTEXT(rtcb); RESTORE_USERCONTEXT(rtcb);