From d785c8a7e5e58dc2ef41afdfee47e605ef1216f5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 7 Mar 2009 11:47:38 +0000 Subject: [PATCH] Documentation fixes about timeouts, improved checks in chVTSetI(). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@812 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chcond.c | 10 ++++++++-- src/chevents.c | 15 ++++++++++++--- src/chschd.c | 12 +++++++----- src/chsem.c | 5 ++++- src/chvt.c | 6 ++++-- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/chcond.c b/src/chcond.c index bc19b978f..b531cffa4 100644 --- a/src/chcond.c +++ b/src/chcond.c @@ -162,7 +162,10 @@ msg_t chCondWaitS(CondVar *cp) { * acquires the mutex again. This is done atomically. * * @param cp pointer to the @p CondVar structure - * @param time the number of ticks before the operation fails + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The wakep mode. * @retval RDY_OK if the condvar was signaled using chCondSignal(). * @retval RDY_RESET if the condvar was signaled using chCondBroadcast(). @@ -186,7 +189,10 @@ msg_t chCondWaitTimeout(CondVar *cp, systime_t time) { * acquires the mutex again. This is done atomically. * * @param cp pointer to the @p CondVar structure - * @param time the number of ticks before the operation fails + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The wakep mode. * @retval RDY_OK if the condvar was signaled using chCondSignal(). * @retval RDY_RESET if the condvar was signaled using chCondBroadcast(). diff --git a/src/chevents.c b/src/chevents.c index 4fd8286ad..83c487dcd 100644 --- a/src/chevents.c +++ b/src/chevents.c @@ -288,7 +288,10 @@ eventmask_t chEvtWaitAll(eventmask_t ewmask) { * * @param ewmask mask of the events that the function should wait for, * @p ALL_EVENTS enables all the events - * @param time the number of ticks before the operation timouts + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The mask of the lowest id served and cleared event. * @retval 0 if the specified timeout expired. * @note One and only one event is served in the function, the one with the @@ -322,7 +325,10 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time) { * * @param ewmask mask of the events that the function should wait for, * @p ALL_EVENTS enables all the events - * @param time the number of ticks before the operation timouts + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The mask of the served and cleared events. * @retval 0 if the specified timeout expired. */ @@ -349,7 +355,10 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time) { * become pending then the events are cleared and returned. * * @param ewmask mask of the event ids that the function should wait for - * @param time the number of ticks before the operation timouts + * @param time the number of ticks before the operation timeouts + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The mask of the served and cleared events. * @retval 0 if the specified timeout expired. */ diff --git a/src/chschd.c b/src/chschd.c index 3c17c3831..6742bf5f8 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -122,10 +122,10 @@ static void wakeup(void *p) { * to sleep is awakened after the specified time has elapsed. * * @param newstate the new thread state - * @param time the number of ticks before the operation timeouts. The - * following special values are allowed: - * - @p TIME_ZERO immediate timeout. - * - @p TIME_INFINITE no timeout. + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @return The wakeup message. * @retval RDY_TIMEOUT if a timeout occurs. * @note The function must be called in the system mutex zone. @@ -133,8 +133,10 @@ static void wakeup(void *p) { */ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { - if (TIME_ZERO == time) + if (TIME_ZERO == time) { + chSchRescheduleS(); return RDY_OK; + } if (TIME_INFINITE != time) { VirtualTimer vt; diff --git a/src/chsem.c b/src/chsem.c index 774611ea6..b682db108 100644 --- a/src/chsem.c +++ b/src/chsem.c @@ -132,7 +132,10 @@ msg_t chSemWaitS(Semaphore *sp) { * @brief Performs a wait operation on a semaphore with timeout specification. * * @param sp pointer to a @p Semaphore structure - * @param time the number of ticks before the operation fails + * @param time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_ZERO immediate timeout. + * - @a TIME_INFINITE no timeout. * @retval RDY_OK if the semaphore was signaled or not taken. * @retval RDY_RESET if the semaphore was reset using @p chSemReset(). * @retval RDY_TIMEOUT if the semaphore was not signaled or reset within the diff --git a/src/chvt.c b/src/chvt.c index 1fdd198f0..0e2eae794 100644 --- a/src/chvt.c +++ b/src/chvt.c @@ -44,7 +44,8 @@ void vt_init(void) { * @brief Enables a virtual timer. * * @param vtp the @p VirtualTimer structure pointer - * @param time the number of time ticks, the value zero is not allowed + * @param time the number of time ticks, the values @p TIME_ZERO and + * @p TIME_INFINITE are not allowed * @param vtfunc the timer callback function. After invoking the callback * the timer is disabled and the structure can be disposed or * reused. @@ -55,7 +56,8 @@ void vt_init(void) { void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) { VirtualTimer *p; - chDbgCheck((vtp != NULL) && (time != 0) && (vtfunc != NULL), "chVTSetI"); + chDbgCheck((vtp != NULL) && (time != TIME_ZERO) && + (time != TIME_INFINITE) && (vtfunc != NULL), "chVTSetI"); vtp->vt_par = par; vtp->vt_func = vtfunc;