diff --git a/arch/arm/src/arm/up_blocktask.c b/arch/arm/src/arm/up_blocktask.c index 13a6e646afd..51245103183 100644 --- a/arch/arm/src/arm/up_blocktask.c +++ b/arch/arm/src/arm/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_blocktask.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 ****************************************************************************/ @@ -121,6 +109,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -137,6 +129,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -166,6 +162,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/arm/src/arm/up_unblocktask.c b/arch/arm/src/arm/up_unblocktask.c index 91dd890d3a6..ec2e3152d17 100644 --- a/arch/arm/src/arm/up_unblocktask.c +++ b/arch/arm/src/arm/up_unblocktask.c @@ -48,18 +48,6 @@ #include "clock/clock.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/arm/src/armv6-m/up_blocktask.c b/arch/arm/src/armv6-m/up_blocktask.c index a3395e66401..667e07f9999 100644 --- a/arch/arm/src/armv6-m/up_blocktask.c +++ b/arch/arm/src/armv6-m/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv6-m/up_blocktask.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 ****************************************************************************/ @@ -119,6 +107,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -135,6 +127,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -144,11 +140,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) else { + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + + /* Reset 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_blocktask.c b/arch/arm/src/armv7-a/arm_blocktask.c index 493e884350a..f3ab9094ae9 100644 --- a/arch/arm/src/armv7-a/arm_blocktask.c +++ b/arch/arm/src/armv7-a/arm_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/up_blocktask.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 ****************************************************************************/ @@ -121,6 +109,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -137,6 +129,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -166,6 +162,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/arm/src/armv7-m/up_blocktask.c b/arch/arm/src/armv7-m/up_blocktask.c index 3b316eca536..834b5ea8ab9 100644 --- a/arch/arm/src/armv7-m/up_blocktask.c +++ b/arch/arm/src/armv7-m/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_blocktask.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 ****************************************************************************/ @@ -120,6 +108,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -136,6 +128,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -145,11 +141,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) else { + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + + /* Reset 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_blocktask.c b/arch/avr/src/avr/up_blocktask.c index 243e883f1e7..2e3cf037077 100644 --- a/arch/avr/src/avr/up_blocktask.c +++ b/arch/avr/src/avr/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_blocktask.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 ****************************************************************************/ @@ -120,6 +108,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -136,6 +128,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_restorestate(rtcb->xcp.regs); @@ -145,11 +141,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) else { + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + + /* Reset 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_blocktask.c b/arch/avr/src/avr32/up_blocktask.c index c9d49c8d746..a4ad45e210f 100644 --- a/arch/avr/src/avr32/up_blocktask.c +++ b/arch/avr/src/avr32/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_blocktask.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 ****************************************************************************/ @@ -121,6 +109,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -137,6 +129,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset 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. @@ -164,6 +160,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(nexttcb); #endif + /* Reset 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_blocktask.c b/arch/hc/src/common/up_blocktask.c index 93b3cbe66c3..ecc07474387 100644 --- a/arch/hc/src/common/up_blocktask.c +++ b/arch/hc/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/hc/src/common/up_blocktask.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 ****************************************************************************/ @@ -121,6 +109,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -137,6 +129,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -166,6 +162,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/mips/src/mips32/up_blocktask.c b/arch/mips/src/mips32/up_blocktask.c index 69304c522e4..a2dd1208781 100644 --- a/arch/mips/src/mips32/up_blocktask.c +++ b/arch/mips/src/mips32/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/mips32/up_blocktask.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 @@ -50,18 +50,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -122,6 +110,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -138,6 +130,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -164,6 +160,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(nexttcb); #endif + /* Reset 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 5b545597b37..c5cc7b499b6 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -250,55 +250,79 @@ void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) ****************************************************************************/ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || - (tcb->task_state > LAST_READY_TO_RUN_STATE)) { - warn("%s: task sched error\n", __func__); - return; + /* Verify that the context switch can be performed */ + + if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || + (tcb->task_state > LAST_READY_TO_RUN_STATE)) + { + 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. If we - * are blocking the task at the head of the task list (the - * most likely case), then a context switch to the next - * ready-to-run task is needed. In this case, it should - * also be true that rtcb == tcb. - */ - switch_needed = sched_removereadytorun(tcb); + /* Remove the tcb task from the ready-to-run list. If we + * are blocking the task at the head of the task list (the + * most likely case), then a context switch to the next + * ready-to-run task is needed. In this case, it should + * also be true that rtcb == tcb. + */ - /* Add the task to the specified blocked task list */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* Now, perform the context switch if one is needed */ - if (switch_needed) { - struct tcb_s *nexttcb; - // this part should not be executed in interrupt context - if (up_interrupt_context()) { - panic("%s: %d\n", __func__, __LINE__); - } - // 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 task block itself\n"); - sched_mergepending(); + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) + { + struct tcb_s *nexttcb; + + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* this part should not be executed in interrupt context */ + + if (up_interrupt_context()) + { + panic("%s: %d\n", __func__, __LINE__); } - nexttcb = (struct tcb_s*)g_readytorun.head; + /* 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 task block itself\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. + /* 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 - up_switchcontext(rtcb, nexttcb); + /* Reset scheduler parameters */ + + sched_resume_scheduler(nexttcb); + + /* context switch */ + + up_switchcontext(rtcb, nexttcb); } } } diff --git a/arch/sh/src/common/up_blocktask.c b/arch/sh/src/common/up_blocktask.c index f81d9c53906..fb7cd99ab52 100644 --- a/arch/sh/src/common/up_blocktask.c +++ b/arch/sh/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sh/src/common/up_blocktask.c * - * Copyright (C) 2008-2009, 2013-2014 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 @@ -48,18 +48,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -120,6 +108,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -136,6 +128,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -165,6 +161,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/sim/src/up_blocktask.c b/arch/sim/src/up_blocktask.c index 58ec9310760..4afbf2718ff 100644 --- a/arch/sim/src/up_blocktask.c +++ b/arch/sim/src/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sim/src/up_blocktask.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 @@ -48,18 +48,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -122,6 +110,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* 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! @@ -148,6 +140,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb->xcp.sigdeliver = NULL; } + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_longjmp(rtcb->xcp.regs, 1); diff --git a/arch/x86/src/common/up_blocktask.c b/arch/x86/src/common/up_blocktask.c index 680f3cfa649..136373fb9b9 100644 --- a/arch/x86/src/common/up_blocktask.c +++ b/arch/x86/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_blocktask.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 ****************************************************************************/ @@ -120,6 +108,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (current_regs) @@ -136,6 +128,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) rtcb = (struct tcb_s*)g_readytorun.head; + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts. Any necessary address environment * changes will be made when the interrupt returns. */ @@ -165,6 +161,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); diff --git a/arch/z16/src/common/up_blocktask.c b/arch/z16/src/common/up_blocktask.c index a2f8f6f7b1b..c991d2a74cb 100644 --- a/arch/z16/src/common/up_blocktask.c +++ b/arch/z16/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_blocktask.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 @@ -48,18 +48,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -122,6 +110,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (IN_INTERRUPT) @@ -137,7 +129,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) */ rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then setup so that the context will be performed on exit * from the interrupt. @@ -158,7 +153,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) */ rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then switch contexts */ diff --git a/arch/z80/src/common/up_blocktask.c b/arch/z80/src/common/up_blocktask.c index 700a29a60af..6a4916b1837 100644 --- a/arch/z80/src/common/up_blocktask.c +++ b/arch/z80/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/common/up_blocktask.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 @@ -50,18 +50,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -124,6 +112,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) if (switch_needed) { + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + /* Are we in an interrupt handler? */ if (IN_INTERRUPT()) @@ -139,7 +131,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) */ rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); /* Then setup so that the context will be performed on exit * from the interrupt. Any necessary address environment @@ -171,6 +166,10 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) (void)group_addrenv(rtcb); #endif + /* Reset scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(rtcb);