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
master
gdisirio 2014-08-10 16:45:47 +00:00
parent 49d05cf795
commit 80284bf64a
2 changed files with 31 additions and 0 deletions

View File

@ -252,6 +252,7 @@ extern "C" {
void chThdTerminate(thread_t *tp);
void chThdSleep(systime_t time);
void chThdSleepUntil(systime_t time);
systime_t chThdSleepUntilWindowed(systime_t prev, systime_t next);
void chThdYield(void);
void chThdExit(msg_t msg);
void chThdExitS(msg_t msg);

View File

@ -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
*
@ -324,6 +329,31 @@ void chThdSleepUntil(systime_t time) {
chSysUnlock();
}
/**
* @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