mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
sched: remove sched_continue, merge code
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -64,7 +64,7 @@ static int group_continue_handler(pid_t pid, FAR void *arg)
|
|||||||
rtcb = nxsched_get_tcb(pid);
|
rtcb = nxsched_get_tcb(pid);
|
||||||
if (rtcb != NULL)
|
if (rtcb != NULL)
|
||||||
{
|
{
|
||||||
nxsched_continue(rtcb);
|
up_unblock_task(rtcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always return zero. We need to visit each member of the group */
|
/* Always return zero. We need to visit each member of the group */
|
||||||
@@ -82,6 +82,7 @@ static int group_continue_handler(pid_t pid, FAR void *arg)
|
|||||||
* Description:
|
* Description:
|
||||||
* Resume all members of the task group. This is SIGCONT default signal
|
* Resume all members of the task group. This is SIGCONT default signal
|
||||||
* action logic.
|
* action logic.
|
||||||
|
* Note: this function should used within critical_section
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* tcb - TCB of the task to be retained.
|
* tcb - TCB of the task to be retained.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
* task that is waiting on a message queue -- either for a queue to
|
* task that is waiting on a message queue -- either for a queue to
|
||||||
* becoming not full (on mq_send and friends) or not empty (on mq_receive
|
* becoming not full (on mq_send and friends) or not empty (on mq_receive
|
||||||
* and friends).
|
* and friends).
|
||||||
|
* Note: this function should used within critical_section
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* wtcb - A pointer to the TCB of the task that is waiting on a message
|
* wtcb - A pointer to the TCB of the task that is waiting on a message
|
||||||
@@ -61,13 +62,6 @@
|
|||||||
void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
||||||
{
|
{
|
||||||
FAR struct mqueue_inode_s *msgq;
|
FAR struct mqueue_inode_s *msgq;
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
|
||||||
* attempt to send a message while we are doing this.
|
|
||||||
*/
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
|
|
||||||
/* It is possible that an interrupt/context switch beat us to the punch and
|
/* It is possible that an interrupt/context switch beat us to the punch and
|
||||||
* already changed the task's state. NOTE: The operations within the if
|
* already changed the task's state. NOTE: The operations within the if
|
||||||
@@ -75,9 +69,6 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
|||||||
* nwaitnotempty, and nwaitnotfull fields are modified.
|
* nwaitnotempty, and nwaitnotfull fields are modified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY ||
|
|
||||||
wtcb->task_state == TSTATE_WAIT_MQNOTFULL)
|
|
||||||
{
|
|
||||||
/* Get the message queue associated with the waiter from the TCB */
|
/* Get the message queue associated with the waiter from the TCB */
|
||||||
|
|
||||||
msgq = wtcb->waitobj;
|
msgq = wtcb->waitobj;
|
||||||
@@ -103,9 +94,4 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
|||||||
/* Restart the task. */
|
/* Restart the task. */
|
||||||
|
|
||||||
up_unblock_task(wtcb);
|
up_unblock_task(wtcb);
|
||||||
}
|
|
||||||
|
|
||||||
/* Interrupts may now be enabled. */
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ CSRCS += sched_getaffinity.c sched_setaffinity.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SIG_SIGSTOP_ACTION),y)
|
ifeq ($(CONFIG_SIG_SIGSTOP_ACTION),y)
|
||||||
CSRCS += sched_suspend.c sched_continue.c
|
CSRCS += sched_suspend.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCHED_WAITPID),y)
|
ifeq ($(CONFIG_SCHED_WAITPID),y)
|
||||||
|
|||||||
@@ -357,7 +357,6 @@ void nxsched_sporadic_lowpriority(FAR struct tcb_s *tcb);
|
|||||||
|
|
||||||
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
||||||
void nxsched_suspend(FAR struct tcb_s *tcb);
|
void nxsched_suspend(FAR struct tcb_s *tcb);
|
||||||
void nxsched_continue(FAR struct tcb_s *tcb);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* sched/sched/sched_continue.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: nxsched_continue
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Resume the specified thread. This is normally calling indirectly
|
|
||||||
* via group_continue();
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void nxsched_continue(FAR struct tcb_s *tcb)
|
|
||||||
{
|
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
DEBUGASSERT(tcb != NULL && tcb->task_state == TSTATE_TASK_STOPPED);
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
|
|
||||||
/* Simply restart the thread. If is was blocked before, it will awaken
|
|
||||||
* with errcode = EINTR and will appears as if it were awakened by a
|
|
||||||
* signal. If pre-emption is not disabled this action could block this
|
|
||||||
* task here!
|
|
||||||
*/
|
|
||||||
|
|
||||||
up_unblock_task(tcb);
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
|
||||||
@@ -50,6 +50,8 @@
|
|||||||
* 2. From logic associated with sem_timedwait(). This function is called
|
* 2. From logic associated with sem_timedwait(). This function is called
|
||||||
* when the timeout elapses without receiving the semaphore.
|
* when the timeout elapses without receiving the semaphore.
|
||||||
*
|
*
|
||||||
|
* Note: this function should used within critical_section
|
||||||
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* wtcb - A pointer to the TCB of the task that is waiting on a
|
* wtcb - A pointer to the TCB of the task that is waiting on a
|
||||||
* semphaphore, but has received a signal or timeout instead.
|
* semphaphore, but has received a signal or timeout instead.
|
||||||
@@ -65,22 +67,12 @@
|
|||||||
|
|
||||||
void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
FAR sem_t *sem = wtcb->waitobj;
|
||||||
|
|
||||||
/* Disable interrupts. This is necessary (unfortunately) because an
|
|
||||||
* interrupt handler may attempt to post the semaphore while we are
|
|
||||||
* doing this.
|
|
||||||
*/
|
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
|
|
||||||
/* It is possible that an interrupt/context switch beat us to the punch
|
/* It is possible that an interrupt/context switch beat us to the punch
|
||||||
* and already changed the task's state.
|
* and already changed the task's state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (wtcb->task_state == TSTATE_WAIT_SEM)
|
|
||||||
{
|
|
||||||
FAR sem_t *sem = wtcb->waitobj;
|
|
||||||
DEBUGASSERT(sem != NULL && sem->semcount < 0);
|
DEBUGASSERT(sem != NULL && sem->semcount < 0);
|
||||||
|
|
||||||
/* Restore the correct priority of all threads that hold references
|
/* Restore the correct priority of all threads that hold references
|
||||||
@@ -104,9 +96,4 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode)
|
|||||||
/* Restart the task. */
|
/* Restart the task. */
|
||||||
|
|
||||||
up_unblock_task(wtcb);
|
up_unblock_task(wtcb);
|
||||||
}
|
|
||||||
|
|
||||||
/* Interrupts may now be enabled. */
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,6 +430,8 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||||||
|
|
||||||
if (masked == 0)
|
if (masked == 0)
|
||||||
{
|
{
|
||||||
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* If the task is blocked waiting for a semaphore, then that task must
|
/* If the task is blocked waiting for a semaphore, then that task must
|
||||||
* be unblocked when a signal is received.
|
* be unblocked when a signal is received.
|
||||||
*/
|
*/
|
||||||
@@ -462,10 +464,12 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||||||
#ifdef HAVE_GROUP_MEMBERS
|
#ifdef HAVE_GROUP_MEMBERS
|
||||||
group_continue(stcb);
|
group_continue(stcb);
|
||||||
#else
|
#else
|
||||||
nxsched_continue(stcb);
|
up_unblock_task(stcb);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In case nxsig_ismember failed due to an invalid signal number */
|
/* In case nxsig_ismember failed due to an invalid signal number */
|
||||||
|
|||||||
Reference in New Issue
Block a user