mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
Correct resume scheduler hooks and add suspend scheduler hooks to all implementations of up_unblock_task
This commit is contained in:
@@ -81,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -93,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -111,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -142,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(rtcb->xcp.regs);
|
up_fullcontextrestore(rtcb->xcp.regs);
|
||||||
|
|||||||
@@ -47,18 +47,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -91,10 +79,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -103,10 +87,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -121,6 +109,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_restorestate(rtcb->xcp.regs);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
@@ -130,11 +122,16 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
else
|
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
|
/* Switch context to the context of the task at the head of the
|
||||||
* ready to run list.
|
* ready to run list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
|
|
||||||
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
||||||
|
|
||||||
/* up_switchcontext forces a context switch to the task at the
|
/* up_switchcontext forces a context switch to the task at the
|
||||||
|
|||||||
@@ -93,10 +93,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -105,10 +101,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -123,6 +123,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -154,6 +158,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(rtcb->xcp.regs);
|
up_fullcontextrestore(rtcb->xcp.regs);
|
||||||
|
|||||||
@@ -47,18 +47,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_restorestate(rtcb->xcp.regs);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
@@ -131,11 +123,16 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
else
|
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
|
/* Switch context to the context of the task at the head of the
|
||||||
* ready to run list.
|
* ready to run list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
|
|
||||||
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
||||||
|
|
||||||
/* up_switchcontext forces a context switch to the task at the
|
/* up_switchcontext forces a context switch to the task at the
|
||||||
|
|||||||
@@ -47,18 +47,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_restorestate(rtcb->xcp.regs);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
@@ -131,11 +123,16 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
else
|
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
|
/* Switch context to the context of the task at the head of the
|
||||||
* ready to run list.
|
* ready to run list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
|
|
||||||
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
||||||
|
|
||||||
/* up_switchcontext forces a context switch to the task at the
|
/* up_switchcontext forces a context switch to the task at the
|
||||||
|
|||||||
@@ -48,18 +48,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any new address environment needed by
|
/* Then switch contexts. Any new address environment needed by
|
||||||
* the new thread will be instantiated before the return from
|
* the new thread will be instantiated before the return from
|
||||||
* interrupt.
|
* interrupt.
|
||||||
@@ -151,6 +143,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(nexttcb);
|
(void)group_addrenv(nexttcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(nexttcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
||||||
|
|||||||
@@ -48,18 +48,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -154,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(rtcb->xcp.regs);
|
up_fullcontextrestore(rtcb->xcp.regs);
|
||||||
|
|||||||
@@ -50,18 +50,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -95,10 +83,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -107,10 +91,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -125,6 +113,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -152,6 +144,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(nexttcb);
|
(void)group_addrenv(nexttcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(nexttcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
||||||
|
|||||||
+37
-25
@@ -342,51 +342,63 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
|||||||
* ready to run taks, executed.
|
* ready to run taks, executed.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb)
|
void up_unblock_task(struct tcb_s *tcb)
|
||||||
{
|
{
|
||||||
/* Verify that the context switch can be performed */
|
/* Verify that the context switch can be performed */
|
||||||
if ((tcb->task_state < FIRST_BLOCKED_STATE) ||
|
|
||||||
(tcb->task_state > LAST_BLOCKED_STATE)) {
|
if ((tcb->task_state < FIRST_BLOCKED_STATE) ||
|
||||||
warn("%s: task sched error\n", __func__);
|
(tcb->task_state > LAST_BLOCKED_STATE))
|
||||||
return;
|
{
|
||||||
|
warn("%s: task sched error\n", __func__);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
struct tcb_s *rtcb = current_task;
|
{
|
||||||
|
struct tcb_s *rtcb = current_task;
|
||||||
|
|
||||||
/* Remove the task from the blocked task list */
|
/* Remove the task from the blocked task list */
|
||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
/* Add the task in the correct location in the prioritized
|
||||||
|
* g_readytorun task list.
|
||||||
|
*/
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
if (sched_addreadytorun(tcb) && !up_interrupt_context())
|
||||||
|
{
|
||||||
|
/* The currently active task has changed! */
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
// Add the task in the correct location in the prioritized
|
sched_suspend_scheduler(rtcb);
|
||||||
// g_readytorun task list.
|
|
||||||
if (sched_addreadytorun(tcb) && !up_interrupt_context()) {
|
|
||||||
/* The currently active task has changed! */
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
|
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
// Make sure that the address environment for the previously
|
/* Make sure that the address environment for the previously
|
||||||
// running task is closed down gracefully (data caches dump,
|
* running task is closed down gracefully (data caches dump,
|
||||||
// MMU flushed) and set up the address environment for the new
|
* MMU flushed) and set up the address environment for the new
|
||||||
// thread at the head of the ready-to-run list.
|
* thread at the head of the ready-to-run list.
|
||||||
|
|
||||||
(void)group_addrenv(nexttcb);
|
(void)group_addrenv(nexttcb);
|
||||||
#endif
|
#endif
|
||||||
// context switch
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
up_switchcontext(rtcb, nexttcb);
|
sched_resume_scheduler(nexttcb);
|
||||||
|
|
||||||
|
/* context switch */
|
||||||
|
|
||||||
|
up_switchcontext(rtcb, nexttcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* This function is called from sched_unlock() which will check not
|
||||||
* This function is called from sched_unlock() which will check not
|
|
||||||
* in interrupt context and disable interrupt.
|
* in interrupt context and disable interrupt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void up_release_pending(void)
|
void up_release_pending(void)
|
||||||
{
|
{
|
||||||
struct tcb_s *rtcb = current_task;
|
struct tcb_s *rtcb = current_task;
|
||||||
|
|||||||
@@ -48,18 +48,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -93,10 +81,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -105,10 +89,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -123,6 +111,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -154,6 +146,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(rtcb->xcp.regs);
|
up_fullcontextrestore(rtcb->xcp.regs);
|
||||||
|
|||||||
@@ -92,10 +92,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
if (sched_addreadytorun(tcb))
|
if (sched_addreadytorun(tcb))
|
||||||
{
|
{
|
||||||
/* The currently active task has changed! Copy the exception context
|
/* The currently active task has changed! */
|
||||||
* into the TCB of the task that was previously active. if
|
/* Update scheduler parameters */
|
||||||
* up_setjmp returns a non-zero value, then this is really the
|
|
||||||
* previously running task restarting!
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Copy the exception context into the TCB of the task that was
|
||||||
|
* previously active. if up_setjmp returns a non-zero value, then
|
||||||
|
* this is really the previously running task restarting!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!up_setjmp(rtcb->xcp.regs))
|
if (!up_setjmp(rtcb->xcp.regs))
|
||||||
@@ -120,6 +124,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
rtcb->xcp.sigdeliver = NULL;
|
rtcb->xcp.sigdeliver = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_longjmp(rtcb->xcp.regs, 1);
|
up_longjmp(rtcb->xcp.regs, 1);
|
||||||
|
|||||||
@@ -48,18 +48,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -92,10 +80,6 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -104,10 +88,14 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (current_regs)
|
if (current_regs)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -122,6 +110,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
/* Then switch contexts. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
*/
|
*/
|
||||||
@@ -153,6 +145,10 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(rtcb->xcp.regs);
|
up_fullcontextrestore(rtcb->xcp.regs);
|
||||||
|
|||||||
@@ -49,18 +49,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -96,10 +84,6 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -108,10 +92,14 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (IN_INTERRUPT)
|
if (IN_INTERRUPT)
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -125,7 +113,10 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
||||||
/* dbg("New Active Task TCB=%p\n", rtcb); */
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then setup so that the context will be performed on exit
|
/* Then setup so that the context will be performed on exit
|
||||||
* from the interrupt.
|
* from the interrupt.
|
||||||
@@ -148,7 +139,10 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
||||||
/* dbg("New Active Task TCB=%p\n", rtcb); */
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
|
|||||||
@@ -51,18 +51,6 @@
|
|||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -98,10 +86,6 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
sched_removeblocked(tcb);
|
sched_removeblocked(tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Add the task in the correct location in the prioritized
|
/* Add the task in the correct location in the prioritized
|
||||||
* g_readytorun task list
|
* g_readytorun task list
|
||||||
*/
|
*/
|
||||||
@@ -110,10 +94,14 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
{
|
{
|
||||||
/* The currently active task has changed! We need to do
|
/* The currently active task has changed! We need to do
|
||||||
* a context switch to the new task.
|
* a context switch to the new task.
|
||||||
*
|
|
||||||
* Are we in an interrupt handler?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
if (IN_INTERRUPT())
|
if (IN_INTERRUPT())
|
||||||
{
|
{
|
||||||
/* Yes, then we have to do things differently.
|
/* Yes, then we have to do things differently.
|
||||||
@@ -128,6 +116,10 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
rtcb = (FAR struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then setup so that the context will be performed on exit
|
/* Then setup so that the context will be performed on exit
|
||||||
* from the interrupt. Any necessary address environment
|
* from the interrupt. Any necessary address environment
|
||||||
* changes will be made when the interrupt returns.
|
* changes will be made when the interrupt returns.
|
||||||
@@ -160,6 +152,10 @@ void up_unblock_task(FAR struct tcb_s *tcb)
|
|||||||
|
|
||||||
(void)group_addrenv(rtcb);
|
(void)group_addrenv(rtcb);
|
||||||
#endif
|
#endif
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(rtcb);
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
RESTORE_USERCONTEXT(rtcb);
|
RESTORE_USERCONTEXT(rtcb);
|
||||||
|
|||||||
Reference in New Issue
Block a user