aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-10 16:45:47 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-10 16:45:47 +0000
commit80284bf64ae30d7c28adc1ff550c7423db53d418 (patch)
treee62bf4578fac6e4b54d831f1104e463b32711d7b /os/rt/src
parent49d05cf79505a4eee8a45fc2a58151bad6fac6ad (diff)
downloadChibiOS-80284bf64ae30d7c28adc1ff550c7423db53d418.tar.gz
ChibiOS-80284bf64ae30d7c28adc1ff550c7423db53d418.tar.bz2
ChibiOS-80284bf64ae30d7c28adc1ff550c7423db53d418.zip
Added systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next) API.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7165 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/src')
-rw-r--r--os/rt/src/chthreads.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
index f7694f593..d7e9bc13d 100644
--- a/os/rt/src/chthreads.c
+++ b/os/rt/src/chthreads.c
@@ -311,6 +311,11 @@ void chThdSleep(systime_t time) {
/**
* @brief Suspends the invoking thread until the system time arrives to the
* specified value.
+ * @note The function has no concept of "past", all specifiable times
+ * are in the future, this means that if you call this function
+ * exceeding your calculated intervals then the function will
+ * return in a far future time, not immediately.
+ * @see chThdSleepUntilWindowed()
*
* @param[in] time absolute system time
*
@@ -325,6 +330,31 @@ void chThdSleepUntil(systime_t time) {
}
/**
+ * @brief Suspends the invoking thread until the system time arrives to the
+ * specified value.
+ * @note The system time is assumed to be between @p prev and @p time
+ * else the call is assumed to have been called outside the
+ * allowed time interval, in this case no sleep is performed.
+ * @see chThdSleepUntilWindowed()
+ *
+ * @param[in] prev absolute system time of the previous deadline
+ * @param[in] next absolute system time of the next deadline
+ * @return the @p next parameter
+ *
+ * @api
+ */
+systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next) {
+ systime_t time;
+
+ chSysLock();
+ time = chVTGetSystemTimeX();
+ if (chVTIsTimeWithinX(time, prev, next))
+ chThdSleepS(next - time);
+ chSysUnlock();
+ return next;
+}
+
+/**
* @brief Yields the time slot.
* @details Yields the CPU control to the next thread in the ready list with
* equal priority, if any.