mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
Add scheduler resume/suspend calls in all implementations of up_block_task()
This commit is contained in:
parent
9d98177daa
commit
a92c0a10ab
15 changed files with 234 additions and 226 deletions
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -48,18 +48,6 @@
|
|||
#include "clock/clock.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 */
|
||||
|
||||
|
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* 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);
|
||||
|
|
Loading…
Reference in a new issue