diff --git a/arch/arm/src/arm/up_reprioritizertr.c b/arch/arm/src/arm/up_reprioritizertr.c index bf6d7e8833..bdadfdc33c 100644 --- a/arch/arm/src/arm/up_reprioritizertr.c +++ b/arch/arm/src/arm/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,7 +131,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } - /* Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/arm/src/armv6-m/up_reprioritizertr.c b/arch/arm/src/armv6-m/up_reprioritizertr.c index 48629f57c0..bd10a78990 100644 --- a/arch/arm/src/armv6-m/up_reprioritizertr.c +++ b/arch/arm/src/armv6-m/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -48,18 +48,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts */ @@ -169,11 +164,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) 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 * ready to run list. */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); /* up_switchcontext forces a context switch to the task at the diff --git a/arch/arm/src/armv7-a/arm_reprioritizertr.c b/arch/arm/src/armv7-a/arm_reprioritizertr.c index d4c66cdf59..4d58a311d3 100644 --- a/arch/arm/src/armv7-a/arm_reprioritizertr.c +++ b/arch/arm/src/armv7-a/arm_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/arm/src/armv7-m/up_reprioritizertr.c b/arch/arm/src/armv7-m/up_reprioritizertr.c index 8e48ab8df9..b66e72da8d 100644 --- a/arch/arm/src/armv7-m/up_reprioritizertr.c +++ b/arch/arm/src/armv7-m/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -48,18 +48,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts */ @@ -169,11 +164,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) 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 * ready to run list. */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); /* up_switchcontext forces a context switch to the task at the diff --git a/arch/avr/src/avr/up_reprioritizertr.c b/arch/avr/src/avr/up_reprioritizertr.c index 74b7ab48ea..bce0b1360a 100644 --- a/arch/avr/src/avr/up_reprioritizertr.c +++ b/arch/avr/src/avr/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -48,18 +48,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -142,6 +130,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts */ @@ -168,11 +163,16 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) 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 * ready to run list. */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); /* up_switchcontext forces a context switch to the task at the diff --git a/arch/avr/src/avr32/up_reprioritizertr.c b/arch/avr/src/avr32/up_reprioritizertr.c index 9ddafe37c4..d41331d3f7 100644 --- a/arch/avr/src/avr32/up_reprioritizertr.c +++ b/arch/avr/src/avr32/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,7 +131,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } - /* Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(nexttcb); + /* Then switch contexts */ up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); diff --git a/arch/hc/src/common/up_reprioritizertr.c b/arch/hc/src/common/up_reprioritizertr.c index 9592f1d811..60a136d208 100644 --- a/arch/hc/src/common/up_reprioritizertr.c +++ b/arch/hc/src/common/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,7 +131,11 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } - /* Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/mips/src/mips32/up_reprioritizertr.c b/arch/mips/src/mips32/up_reprioritizertr.c index 7057ce23a3..9832b92aa6 100644 --- a/arch/mips/src/mips32/up_reprioritizertr.c +++ b/arch/mips/src/mips32/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -51,18 +51,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -145,6 +133,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(nexttcb); + /* Then switch contexts */ up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); diff --git a/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index 55e259077f..30dba34d11 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -59,25 +59,28 @@ 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. * Assumption: global interrupt is disabled. */ + static inline void up_switchcontext(struct tcb_s *ctcb, struct tcb_s *ntcb) { - // do nothing if two tasks are the same - if (ctcb == ntcb) - return; + // do nothing if two tasks are the same - // this function can not be called in interrupt - if (up_interrupt_context()) { - panic("%s: try to switch context in interrupt\n", __func__); - } + if (ctcb == ntcb) + return; - // start switch - current_task = ntcb; - rgmp_context_switch(ctcb ? &ctcb->xcp.ctx : NULL, &ntcb->xcp.ctx); + // this function can not be called in interrupt + + if (up_interrupt_context()) { + panic("%s: try to switch context in interrupt\n", __func__); + } + + // start switch + + current_task = ntcb; + rgmp_context_switch(ctcb ? &ctcb->xcp.ctx : NULL, &ntcb->xcp.ctx); } void up_initialize(void) @@ -424,66 +427,89 @@ void up_release_pending(void) void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) { - /* Verify that the caller is sane */ + /* Verify that the caller is sane */ - if (tcb->task_state < FIRST_READY_TO_RUN_STATE || - tcb->task_state > LAST_READY_TO_RUN_STATE + if (tcb->task_state < FIRST_READY_TO_RUN_STATE || + tcb->task_state > LAST_READY_TO_RUN_STATE #if SCHED_PRIORITY_MIN > UINT8_MIN - || priority < SCHED_PRIORITY_MIN + || priority < SCHED_PRIORITY_MIN #endif #if SCHED_PRIORITY_MAX < UINT8_MAX - || priority > SCHED_PRIORITY_MAX + || priority > SCHED_PRIORITY_MAX #endif - ) { - warn("%s: task sched error\n", __func__); - return; + ) + { + warn("%s: task sched error\n", __func__); + return; } - else { - struct tcb_s *rtcb = current_task; - bool switch_needed; + else + { + struct tcb_s *rtcb = current_task; + bool switch_needed; - /* Remove the tcb task from the ready-to-run list. - * sched_removereadytorun will return true if we just - * remove the head of the ready to run list. - */ - switch_needed = sched_removereadytorun(tcb); + /* Remove the tcb task from the ready-to-run list. + * sched_removereadytorun will return true if we just + * remove the head of the ready to run list. + */ - /* Setup up the new task priority */ - tcb->sched_priority = (uint8_t)priority; + switch_needed = sched_removereadytorun(tcb); - /* Return the task to the specified blocked task list. - * sched_addreadytorun will return true if the task was - * added to the new list. We will need to perform a context - * switch only if the EXCLUSIVE or of the two calls is non-zero - * (i.e., one and only one the calls changes the head of the - * ready-to-run list). - */ - switch_needed ^= sched_addreadytorun(tcb); + /* Setup up the new task priority */ - /* Now, perform the context switch if one is needed */ - if (switch_needed && !up_interrupt_context()) { - 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 - // sched_unlock() to do this for disable preemption. But it block - // itself, so it's OK. - if (g_pendingtasks.head) { - warn("Disable preemption failed for reprioritize task\n"); - sched_mergepending(); + tcb->sched_priority = (uint8_t)priority; + + /* Return the task to the specified blocked task list. + * sched_addreadytorun will return true if the task was + * added to the new list. We will need to perform a context + * switch only if the EXCLUSIVE or of the two calls is non-zero + * (i.e., one and only one the calls changes the head of the + * ready-to-run list). + */ + + switch_needed ^= sched_addreadytorun(tcb); + + /* Now, perform the context switch if one is needed */ + + if (switch_needed && !up_interrupt_context()) + { + 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 + * sched_unlock() to do this for disable preemption. But it block + * itself, so it's OK. + */ + + if (g_pendingtasks.head) + { + warn("Disable preemption failed for reprioritize task\n"); + sched_mergepending(); } - 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. - */ + /* Update scheduler parameters */ - (void)group_addrenv(nexttcb); + sched_suspend_scheduler(rtcb); + + /* Get the TCB of the new task to run */ + + 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 - up_switchcontext(rtcb, nexttcb); + /* Update scheduler parameters */ + + sched_resume_scheduler(nexttcb); + + /* context switch */ + + up_switchcontext(rtcb, nexttcb); } } } diff --git a/arch/sh/src/common/up_reprioritizertr.c b/arch/sh/src/common/up_reprioritizertr.c index 50c5528dda..fb367918e2 100644 --- a/arch/sh/src/common/up_reprioritizertr.c +++ b/arch/sh/src/common/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/sim/src/up_reprioritizertr.c b/arch/sim/src/up_reprioritizertr.c index 125542a71f..2c241a4f84 100644 --- a/arch/sim/src/up_reprioritizertr.c +++ b/arch/sim/src/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + 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 * 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; } + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_longjmp(rtcb->xcp.regs, 1); diff --git a/arch/x86/src/common/up_reprioritizertr.c b/arch/x86/src/common/up_reprioritizertr.c index a9f650b71d..807783f0fd 100644 --- a/arch/x86/src/common/up_reprioritizertr.c +++ b/arch/x86/src/common/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -49,18 +49,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -143,6 +131,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts. Any necessary address environment * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/z16/src/common/up_reprioritizertr.c b/arch/z16/src/common/up_reprioritizertr.c index 640c63e839..8dab4f518b 100644 --- a/arch/z16/src/common/up_reprioritizertr.c +++ b/arch/z16/src/common/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -50,18 +50,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -144,6 +132,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - 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 * 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; - slldbg("New Active Task TCB=%p\n", rtcb); + + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts */ diff --git a/arch/z80/src/common/up_reprioritizertr.c b/arch/z80/src/common/up_reprioritizertr.c index 7a3171af64..bab9d6c9b6 100644 --- a/arch/z80/src/common/up_reprioritizertr.c +++ b/arch/z80/src/common/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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 * * Redistribution and use in source and binary forms, with or without @@ -52,18 +52,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -146,6 +134,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) sched_mergepending(); } + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ 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; - 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 * 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; - slldbg("New Active Task TCB=%p\n", rtcb); #ifdef CONFIG_ARCH_ADDRENV /* 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); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(rtcb);