diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/scheduler.h | 1 | ||||
-rw-r--r-- | src/include/sleep.h | 18 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/include/scheduler.h b/src/include/scheduler.h index 67fae50a4..6f4d54e56 100644 --- a/src/include/scheduler.h +++ b/src/include/scheduler.h @@ -60,6 +60,7 @@ extern "C" { void chSchInit(void);
void chSchReadyI(Thread *tp, t_msg msg);
void chSchGoSleepS(t_tstate newstate);
+ t_msg chSchGoSleepTimeoutS(t_tstate newstate, t_time time);
void chSchWakeupS(Thread *tp, t_msg msg);
void chSchDoRescheduleI(void);
void chSchRescheduleS(void);
diff --git a/src/include/sleep.h b/src/include/sleep.h index 161842a29..022b7be23 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -30,14 +30,12 @@ extern "C" { #endif
#ifdef CH_USE_SLEEP
void chThdSleep(t_time time);
-#ifdef CH_USE_SYSTEMTIME
- void chThdSleepUntil(t_time time);
-#endif /* CH_USE_SYSTEMTIME */
#endif /* CH_USE_SLEEP */
#ifdef __cplusplus
}
#endif
+#ifdef CH_USE_SYSTEMTIME
/**
* Returns the number of system ticks since the \p chSysInit() invocation.
* @return the system ticks number
@@ -48,6 +46,20 @@ extern "C" { */
#define chSysGetTime() rlist.r_stime
+/**
+ * Suspends the invoking thread until the system time arrives to the specified
+ * value.
+ * @note The function is available only if the \p CH_USE_SYSTEMTIME
+ * option is enabled in \p chconf.h.
+ */
+#define chThdSleepUntil(t) { \
+ chSysLock(); \
+ chSchGoSleepTimeoutS(PRSLEEP, \
+ (t_time)((t) - chSysGetTime())) \
+ chSysUnlock(); \
+}
+#endif /* CH_USE_SYSTEMTIME */
+
#endif /* _SLEEP_H_ */
/** @} */
|