aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/scheduler.h4
-rw-r--r--src/include/threads.h30
-rw-r--r--src/include/vt.h13
3 files changed, 31 insertions, 16 deletions
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index 3f9eb7a39..b05db16a2 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -32,6 +32,10 @@
/** Returned when the thread was made ready because of a reset. */
#define RDY_RESET -2
+/** Infinite time specification for all the syscalls with a timeout
+ specification.*/
+#define TIME_INFINITE 0
+
/** The priority of the first thread on the given ready list. */
#define firstprio(rlp) ((rlp)->p_next->p_prio)
diff --git a/src/include/threads.h b/src/include/threads.h
index e9894650d..a3d37a7db 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -193,6 +193,7 @@ extern "C" {
void chThdSuspend(Thread **tpp);
void chThdTerminate(Thread *tp);
void chThdSleep(systime_t time);
+ void chThdSleepUntil(systime_t time);
void chThdExit(msg_t msg);
#ifdef CH_USE_WAITEXIT
msg_t chThdWait(Thread *tp);
@@ -268,15 +269,28 @@ extern "C" {
chThdCreateStatic(workspace, wsize, prio, pf, NULL)
/**
- * Suspends the invoking thread until the system time arrives to the specified
- * value.
+ * Delays the invoking thread for the specified number of seconds.
+ * @note The specified time is rounded up to a value allowed by the real
+ * system clock.
+ * @note The maximum specified value is implementation dependent.
*/
-#define chThdSleepUntil(t) { \
- chSysLock(); \
- chSchGoSleepTimeoutS(PRSLEEP, \
- (systime_t)((t) - chSysGetTime())); \
- chSysUnlock(); \
-}
+#define chThdSleepSeconds(sec) chThdSleep(S2ST(sec))
+
+/**
+ * Delays the invoking thread for the specified number of milliseconds.
+ * @note The specified time is rounded up to a value allowed by the real
+ * system clock.
+ * @note The maximum specified value is implementation dependent.
+ */
+#define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec))
+
+/**
+ * Delays the invoking thread for the specified number of microseconds.
+ * @note The specified time is rounded up to a value allowed by the real
+ * system clock.
+ * @note The maximum specified value is implementation dependent.
+ */
+#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))
#endif /* _THREADS_H_ */
diff --git a/src/include/vt.h b/src/include/vt.h
index 954c87da5..72385715b 100644
--- a/src/include/vt.h
+++ b/src/include/vt.h
@@ -34,13 +34,13 @@
* Time conversion utility. Converts from milliseconds to system ticks number.
* @note The result is rounded upward to the next tick boundary.
*/
-#define MS2ST(msec) ((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / 1000) + 1))
+#define MS2ST(msec) ((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / 1000L) + 1L))
/**
* Time conversion utility. Converts from microseconds to system ticks number.
* @note The result is rounded upward to the next tick boundary.
*/
-#define US2ST(usec) ((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / 1000000) + 1))
+#define US2ST(usec) ((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / 1000000L) + 1L))
/** Virtual Timer callback function.*/
typedef void (*vtfunc_t)(void *);
@@ -85,12 +85,12 @@ typedef struct {
extern VTList vtlist;
#define chVTDoTickI() { \
- vtlist.vt_systime++; \
+ vtlist.vt_systime++; \
if (&vtlist != (VTList *)vtlist.vt_next) { \
VirtualTimer *vtp; \
\
- --vtlist.vt_next->vt_time; \
- while (!(vtp = vtlist.vt_next)->vt_time) { \
+ --vtlist.vt_next->vt_time; \
+ while (!(vtp = vtlist.vt_next)->vt_time) { \
vtfunc_t fn = vtp->vt_func; \
vtp->vt_func = NULL; \
(vtp->vt_next->vt_prev = (void *)&vtlist)->vt_next = vtp->vt_next;\
@@ -99,9 +99,6 @@ extern VTList vtlist;
} \
}
-/** Infinite time specification.*/
-#define TIME_INFINITE 0
-
/*
* Virtual Timers APIs.
*/