diff --git a/arch/arm/src/arm/up_releasepending.c b/arch/arm/src/arm/up_releasepending.c index b7d1cd66d39..0e1156b8980 100644 --- a/arch/arm/src/arm/up_releasepending.c +++ b/arch/arm/src/arm/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_releasepending.c * - * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,11 +73,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -103,7 +96,10 @@ void up_release_pending(void) */ 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. @@ -125,7 +121,6 @@ void up_release_pending(void) */ 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 @@ -136,7 +131,11 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); } diff --git a/arch/arm/src/armv6-m/up_releasepending.c b/arch/arm/src/armv6-m/up_releasepending.c index 6c981252500..c94560d6e9f 100644 --- a/arch/arm/src/armv6-m/up_releasepending.c +++ b/arch/arm/src/armv6-m/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv6-m/up_releasepending.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 @@ -46,18 +46,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,10 +72,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to switch - * contexts. First check if we are operating in interrupt context. + /* The currently active task has changed! We will need to + * switch contexts. */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. Just copy the @@ -101,7 +95,10 @@ void up_release_pending(void) */ 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 */ @@ -112,11 +109,16 @@ void up_release_pending(void) 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_releasepending.c b/arch/arm/src/armv7-a/arm_releasepending.c index 6a449f6100b..924e011bcb9 100644 --- a/arch/arm/src/armv7-a/arm_releasepending.c +++ b/arch/arm/src/armv7-a/arm_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_releasepending.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 @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -86,10 +74,15 @@ void up_release_pending(void) if (sched_mergepending()) { /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + * switch contexts. */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -103,7 +96,10 @@ void up_release_pending(void) */ 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. @@ -125,7 +121,6 @@ void up_release_pending(void) */ 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 @@ -136,7 +131,11 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); } diff --git a/arch/arm/src/armv7-m/up_releasepending.c b/arch/arm/src/armv7-m/up_releasepending.c index f29bca9110f..c7954d0b296 100644 --- a/arch/arm/src/armv7-m/up_releasepending.c +++ b/arch/arm/src/armv7-m/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_releasepending.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,18 +46,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,9 +73,15 @@ void up_release_pending(void) if (sched_mergepending()) { /* The currently active task has changed! We will need to switch - * contexts. First check if we are operating in interrupt context. + * contexts. */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. Just copy the @@ -101,7 +95,10 @@ void up_release_pending(void) */ 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 */ @@ -112,11 +109,16 @@ void up_release_pending(void) 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_releasepending.c b/arch/avr/src/avr/up_releasepending.c index c2f651de833..5f75d1e6619 100644 --- a/arch/avr/src/avr/up_releasepending.c +++ b/arch/avr/src/avr/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_releasepending.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,18 +46,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,11 +72,14 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. */ + /* Update scheduler parameters */ + + sched_suspend_scheduler(rtcb); + if (current_regs) { /* Yes, then we have to do things differently. @@ -102,7 +93,10 @@ void up_release_pending(void) */ 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 */ @@ -113,11 +107,16 @@ void up_release_pending(void) 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_releasepending.c b/arch/avr/src/avr32/up_releasepending.c index 52edd7e94da..f26ce1e1c56 100644 --- a/arch/avr/src/avr32/up_releasepending.c +++ b/arch/avr/src/avr32/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_releasepending.c * - * Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,11 +73,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -103,7 +96,10 @@ void up_release_pending(void) */ 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. @@ -131,6 +127,10 @@ void up_release_pending(void) (void)group_addrenv(nexttcb); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(nexttcb); + /* Then switch contexs */ up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); diff --git a/arch/hc/src/common/up_releasepending.c b/arch/hc/src/common/up_releasepending.c index b71694af109..8e7f0ca72a3 100644 --- a/arch/hc/src/common/up_releasepending.c +++ b/arch/hc/src/common/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/hc/src/common/up_releasepending.c * - * Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,11 +72,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -102,7 +95,10 @@ void up_release_pending(void) */ 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. @@ -124,7 +120,6 @@ void up_release_pending(void) */ 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 @@ -135,7 +130,11 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); } diff --git a/arch/mips/src/mips32/up_releasepending.c b/arch/mips/src/mips32/up_releasepending.c index cbfe9dba389..81d25e6580b 100644 --- a/arch/mips/src/mips32/up_releasepending.c +++ b/arch/mips/src/mips32/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/mips32/up_releasepending.c * - * Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2014-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 ****************************************************************************/ @@ -87,11 +75,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -105,7 +98,10 @@ void up_release_pending(void) */ 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. @@ -133,6 +129,10 @@ void up_release_pending(void) (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 30dba34d11f..1de7e603718 100644 --- a/arch/rgmp/src/nuttx.c +++ b/arch/rgmp/src/nuttx.c @@ -404,24 +404,38 @@ void up_unblock_task(struct tcb_s *tcb) void up_release_pending(void) { - struct tcb_s *rtcb = current_task; + struct tcb_s *rtcb = current_task; - /* Merge the g_pendingtasks list into the g_readytorun task list */ + /* Merge the g_pendingtasks list into the g_readytorun task list */ + + if (sched_mergepending()) + { + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. + */ + + sched_suspend_scheduler(rtcb); - if (sched_mergepending()) { - /* The currently active task has changed! */ - 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 - 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_releasepending.c b/arch/sh/src/common/up_releasepending.c index 0f1279bb8cd..5ad3e208331 100644 --- a/arch/sh/src/common/up_releasepending.c +++ b/arch/sh/src/common/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sh/src/common/up_releasepending.c * - * Copyright (C) 2008-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,11 +73,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -103,7 +96,10 @@ void up_release_pending(void) */ 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. @@ -125,7 +121,6 @@ void up_release_pending(void) */ 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 @@ -136,7 +131,11 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); } diff --git a/arch/sim/src/up_releasepending.c b/arch/sim/src/up_releasepending.c index 21c1a1f8551..27373b639d4 100644 --- a/arch/sim/src/up_releasepending.c +++ b/arch/sim/src/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sim/src/up_releasepending.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,18 +46,6 @@ #include "sched/sched.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,10 +72,17 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! Copy the exception context - * into the TCB of the task that was currently active. if up_setjmp - * returns a non-zero value, then this is really the previously - * running task restarting! + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. + */ + + sched_suspend_scheduler(rtcb); + + /* Copy the exception context into the TCB of the task that was + * currently active. if up_setjmp returns a non-zero value, then + * this is really the previously running task restarting! */ if (!up_setjmp(rtcb->xcp.regs)) @@ -111,7 +106,11 @@ void up_release_pending(void) rtcb->xcp.sigdeliver = NULL; } - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_longjmp(rtcb->xcp.regs, 1); } diff --git a/arch/x86/src/common/up_releasepending.c b/arch/x86/src/common/up_releasepending.c index 0137243dbf7..8c36db5b580 100644 --- a/arch/x86/src/common/up_releasepending.c +++ b/arch/x86/src/common/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_releasepending.c * - * Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,18 +47,6 @@ #include "group/group.h" #include "up_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -85,11 +73,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (current_regs) { /* Yes, then we have to do things differently. @@ -103,7 +96,10 @@ void up_release_pending(void) */ 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. @@ -125,7 +121,6 @@ void up_release_pending(void) */ 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 @@ -136,7 +131,11 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif - /* Then switch contexts */ + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + + /* Then switch contexts */ up_fullcontextrestore(rtcb->xcp.regs); } diff --git a/arch/z16/src/common/up_releasepending.c b/arch/z16/src/common/up_releasepending.c index d0429e12e96..d787e66e11a 100644 --- a/arch/z16/src/common/up_releasepending.c +++ b/arch/z16/src/common/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_releasepending.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 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 ****************************************************************************/ @@ -86,11 +74,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (IN_INTERRUPT) { /* Yes, then we have to do things differently. @@ -104,7 +97,10 @@ void up_release_pending(void) */ 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. @@ -126,7 +122,10 @@ void up_release_pending(void) */ 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_releasepending.c b/arch/z80/src/common/up_releasepending.c index f960e6adf53..c0690b92036 100644 --- a/arch/z80/src/common/up_releasepending.c +++ b/arch/z80/src/common/up_releasepending.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/common/up_releasepending.c * - * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014-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 ****************************************************************************/ @@ -88,11 +76,16 @@ void up_release_pending(void) /* sched_lock(); */ if (sched_mergepending()) { - /* The currently active task has changed! We will need to - * switch contexts. First check if we are operating in - * interrupt context: + /* The currently active task has changed! We will need to switch + * contexts. + * + * Update scheduler parameters. */ + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. @@ -106,7 +99,10 @@ void up_release_pending(void) */ 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 @@ -129,7 +125,6 @@ void up_release_pending(void) */ 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 @@ -140,6 +135,10 @@ void up_release_pending(void) (void)group_addrenv(rtcb); #endif + /* Update scheduler parameters */ + + sched_resume_scheduler(rtcb); + /* Then switch contexts */ RESTORE_USERCONTEXT(rtcb);