This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 23d48da4bd9883af42bb5c62a3d10abe35065caf
Author: wangchengdong <[email protected]>
AuthorDate: Thu Feb 26 10:27:03 2026 +0800

    sched/sched: add nxsched_abstick_sleep()
    
    Add nxsched_abstick_sleep() and make nxsched_ticksleep()
    a wrapper around it.
    
    Signed-off-by: Chengdong Wang <[email protected]>
---
 include/nuttx/sched.h     | 19 +++++++++++++++++++
 sched/sched/sched_sleep.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index c362cb1011e..05f792a92d1 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -1676,6 +1676,25 @@ int nxsched_smp_call_async(cpu_set_t cpuset,
                            FAR struct smp_call_data_s *data);
 #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
  *
diff --git a/sched/sched/sched_sleep.c b/sched/sched/sched_sleep.c
index 16f898b7c83..2bf60ca86b0 100644
--- a/sched/sched/sched_sleep.c
+++ b/sched/sched/sched_sleep.c
@@ -74,20 +74,42 @@ static void nxsched_timeout(wdparm_t arg)
 
 void nxsched_ticksleep(unsigned int ticks)
 {
-  FAR struct tcb_s *rtcb;
-  irqstate_t flags;
-
   if (ticks == 0)
     {
       sched_yield();
       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();
 
   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. */
 

Reply via email to