mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
sched/sched: add nxsched_abstick_sleep()
Add nxsched_abstick_sleep() and make nxsched_ticksleep() a wrapper around it. Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
This commit is contained in:
@@ -1676,6 +1676,25 @@ int nxsched_smp_call_async(cpu_set_t cpuset,
|
|||||||
FAR struct smp_call_data_s *data);
|
FAR struct smp_call_data_s *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxsched_abstick_sleep
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The nxsched_abstick_sleep() function will cause the calling thread to be
|
||||||
|
* suspended from execution to the specified ticks.
|
||||||
|
*
|
||||||
|
* It can only be resumed through scheduler operations.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* ticks - Absolute time in clock ticks.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxsched_abstick_sleep(clock_t ticks);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxsched_ticksleep
|
* Name: nxsched_ticksleep
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -74,20 +74,42 @@ static void nxsched_timeout(wdparm_t arg)
|
|||||||
|
|
||||||
void nxsched_ticksleep(unsigned int ticks)
|
void nxsched_ticksleep(unsigned int ticks)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *rtcb;
|
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
if (ticks == 0)
|
if (ticks == 0)
|
||||||
{
|
{
|
||||||
sched_yield();
|
sched_yield();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nxsched_abstick_sleep(clock_delay2abstick(ticks));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxsched_abstick_sleep
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The nxsched_abstick_sleep() function will cause the calling thread to be
|
||||||
|
* suspended from execution to the specified ticks.
|
||||||
|
*
|
||||||
|
* It can only be resumed through scheduler operations.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* ticks - Absolute time in clock ticks.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxsched_abstick_sleep(clock_t ticks)
|
||||||
|
{
|
||||||
|
FAR struct tcb_s *rtcb;
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
rtcb = this_task();
|
rtcb = this_task();
|
||||||
|
|
||||||
wd_start(&rtcb->waitdog, ticks, nxsched_timeout, (uintptr_t)rtcb);
|
wd_start_abstick(&rtcb->waitdog, ticks, nxsched_timeout, (uintptr_t)rtcb);
|
||||||
|
|
||||||
/* Remove the tcb task from the ready-to-run list. */
|
/* Remove the tcb task from the ready-to-run list. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user