From 838c5355ebbe93d141af3d023b6fe3a95624f77f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 26 Jul 2015 09:07:47 -0600 Subject: [PATCH] Correct resume scheduler hooks and add suspend scheduler hooks to all implementations of up_unblock_task --- arch/arm/src/arm/up_unblocktask.c | 20 ++++++--- arch/arm/src/armv6-m/up_unblocktask.c | 35 +++++++-------- arch/arm/src/armv7-a/arm_unblocktask.c | 20 ++++++--- arch/arm/src/armv7-m/up_unblocktask.c | 35 +++++++-------- arch/avr/src/avr/up_unblocktask.c | 35 +++++++-------- arch/avr/src/avr32/up_unblocktask.c | 32 ++++++------- arch/hc/src/common/up_unblocktask.c | 32 ++++++------- arch/mips/src/mips32/up_unblocktask.c | 32 ++++++------- arch/rgmp/src/nuttx.c | 62 +++++++++++++++----------- arch/sh/src/common/up_unblocktask.c | 32 ++++++------- arch/sim/src/up_unblocktask.c | 16 +++++-- arch/x86/src/common/up_unblocktask.c | 32 ++++++------- arch/z16/src/common/up_unblocktask.c | 34 ++++++-------- arch/z80/src/common/up_unblocktask.c | 32 ++++++------- 14 files changed, 223 insertions(+), 226 deletions(-) diff --git a/arch/arm/src/arm/up_unblocktask.c b/arch/arm/src/arm/up_unblocktask.c index ec2e3152d1..3d7fd2e9b3 100644 --- a/arch/arm/src/arm/up_unblocktask.c +++ b/arch/arm/src/arm/up_unblocktask.c @@ -81,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -93,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -111,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -142,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/arm/src/armv6-m/up_unblocktask.c index 2389a1acac..77a999e17b 100644 --- a/arch/arm/src/armv6-m/up_unblocktask.c +++ b/arch/arm/src/armv6-m/up_unblocktask.c @@ -47,18 +47,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -91,10 +79,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -103,10 +87,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -121,6 +109,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -130,11 +122,16 @@ void up_unblock_task(struct tcb_s *tcb) 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_unblocktask.c b/arch/arm/src/armv7-a/arm_unblocktask.c index 8e5c48b967..5aa0c2d6e1 100644 --- a/arch/arm/src/armv7-a/arm_unblocktask.c +++ b/arch/arm/src/armv7-a/arm_unblocktask.c @@ -93,10 +93,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -105,10 +101,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -123,6 +123,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -154,6 +158,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/arm/src/armv7-m/up_unblocktask.c index 878e4a49fe..d456609fe2 100644 --- a/arch/arm/src/armv7-m/up_unblocktask.c +++ b/arch/arm/src/armv7-m/up_unblocktask.c @@ -47,18 +47,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -131,11 +123,16 @@ void up_unblock_task(struct tcb_s *tcb) 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_unblocktask.c b/arch/avr/src/avr/up_unblocktask.c index b5e4478663..45e3249f7f 100644 --- a/arch/avr/src/avr/up_unblocktask.c +++ b/arch/avr/src/avr/up_unblocktask.c @@ -47,18 +47,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -131,11 +123,16 @@ void up_unblock_task(struct tcb_s *tcb) 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_unblocktask.c b/arch/avr/src/avr32/up_unblocktask.c index 2fd062403b..c85d6052eb 100644 --- a/arch/avr/src/avr32/up_unblocktask.c +++ b/arch/avr/src/avr32/up_unblocktask.c @@ -48,18 +48,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any new address environment needed by * the new thread will be instantiated before the return from * interrupt. @@ -151,6 +143,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/hc/src/common/up_unblocktask.c index 5a1e5bf00f..dce93330b2 100644 --- a/arch/hc/src/common/up_unblocktask.c +++ b/arch/hc/src/common/up_unblocktask.c @@ -48,18 +48,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -154,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/mips/src/mips32/up_unblocktask.c index 5c4d46a90a..2775b5aa78 100644 --- a/arch/mips/src/mips32/up_unblocktask.c +++ b/arch/mips/src/mips32/up_unblocktask.c @@ -50,18 +50,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -95,10 +83,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -107,10 +91,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -125,6 +113,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -152,6 +144,10 @@ void up_unblock_task(struct tcb_s *tcb) (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 c5cc7b499b..55e259077f 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -342,51 +342,63 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) * ready to run taks, executed. * ****************************************************************************/ + void up_unblock_task(struct tcb_s *tcb) { - /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_BLOCKED_STATE) || - (tcb->task_state > LAST_BLOCKED_STATE)) { - warn("%s: task sched error\n", __func__); - return; + /* Verify that the context switch can be performed */ + + if ((tcb->task_state < FIRST_BLOCKED_STATE) || + (tcb->task_state > LAST_BLOCKED_STATE)) + { + warn("%s: task sched error\n", __func__); + return; } - else { - struct tcb_s *rtcb = current_task; + else + { + struct tcb_s *rtcb = current_task; - /* Remove the task from the blocked task list */ + /* Remove the task from the blocked task list */ - sched_removeblocked(tcb); + sched_removeblocked(tcb); - /* Reset scheduler parameters */ + /* Add the task in the correct location in the prioritized + * g_readytorun task list. + */ - sched_resume_scheduler(tcb); + if (sched_addreadytorun(tcb) && !up_interrupt_context()) + { + /* The currently active task has changed! */ + /* Update scheduler parameters */ - // Add the task in the correct location in the prioritized - // g_readytorun task list. - if (sched_addreadytorun(tcb) && !up_interrupt_context()) { - /* The currently active task has changed! */ + sched_suspend_scheduler(rtcb); - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + /* Are we in an interrupt handler? */ + + 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. + /* 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); + (void)group_addrenv(nexttcb); #endif - // context switch + /* Update scheduler parameters */ - up_switchcontext(rtcb, nexttcb); + sched_resume_scheduler(nexttcb); + + /* context switch */ + + up_switchcontext(rtcb, nexttcb); } } } -/** - * This function is called from sched_unlock() which will check not +/* This function is called from sched_unlock() which will check not * in interrupt context and disable interrupt. */ + void up_release_pending(void) { struct tcb_s *rtcb = current_task; diff --git a/arch/sh/src/common/up_unblocktask.c b/arch/sh/src/common/up_unblocktask.c index 8f46a596dc..3afbc7cdbc 100644 --- a/arch/sh/src/common/up_unblocktask.c +++ b/arch/sh/src/common/up_unblocktask.c @@ -48,18 +48,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -154,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/sim/src/up_unblocktask.c index 39d5dd3791..e759eb8650 100644 --- a/arch/sim/src/up_unblocktask.c +++ b/arch/sim/src/up_unblocktask.c @@ -92,10 +92,14 @@ void up_unblock_task(struct tcb_s *tcb) if (sched_addreadytorun(tcb)) { - /* The currently active task has changed! Copy the exception context - * into the TCB of the task that was previously active. if - * up_setjmp returns a non-zero value, then this is really the - * previously running task restarting! + /* The currently active task has changed! */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Copy the exception context into the TCB of the task that was + * previously active. if up_setjmp returns a non-zero value, then + * this is really the previously running task restarting! */ if (!up_setjmp(rtcb->xcp.regs)) @@ -120,6 +124,10 @@ void up_unblock_task(struct tcb_s *tcb) 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_unblocktask.c b/arch/x86/src/common/up_unblocktask.c index 92870c9aa6..aba45ce0cc 100644 --- a/arch/x86/src/common/up_unblocktask.c +++ b/arch/x86/src/common/up_unblocktask.c @@ -48,18 +48,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb) rtcb = (struct tcb_s*)g_readytorun.head; + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -153,6 +145,10 @@ void up_unblock_task(struct tcb_s *tcb) (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_unblocktask.c b/arch/z16/src/common/up_unblocktask.c index 6e82ce2b8f..64ce6ff86a 100644 --- a/arch/z16/src/common/up_unblocktask.c +++ b/arch/z16/src/common/up_unblocktask.c @@ -49,18 +49,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -96,10 +84,6 @@ void up_unblock_task(FAR struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -108,10 +92,14 @@ void up_unblock_task(FAR struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (IN_INTERRUPT) { /* Yes, then we have to do things differently. @@ -125,7 +113,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) */ rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("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. @@ -148,7 +139,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) */ rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("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_unblocktask.c b/arch/z80/src/common/up_unblocktask.c index db613abbfe..16020ef596 100644 --- a/arch/z80/src/common/up_unblocktask.c +++ b/arch/z80/src/common/up_unblocktask.c @@ -51,18 +51,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -98,10 +86,6 @@ void up_unblock_task(FAR struct tcb_s *tcb) sched_removeblocked(tcb); - /* Reset scheduler parameters */ - - sched_resume_scheduler(tcb); - /* Add the task in the correct location in the prioritized * g_readytorun task list */ @@ -110,10 +94,14 @@ void up_unblock_task(FAR struct tcb_s *tcb) { /* The currently active task has changed! We need to do * a context switch to the new task. - * - * Are we in an interrupt handler? */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we in an interrupt handler? */ + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. @@ -128,6 +116,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* 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 * changes will be made when the interrupt returns. @@ -160,6 +152,10 @@ void up_unblock_task(FAR struct tcb_s *tcb) (void)group_addrenv(rtcb); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(rtcb);