From 902470d1c542735b989a727355744a974af43de4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 25 Oct 2008 09:34:25 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@481 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chdebug.c | 4 ---- src/chdelta.c | 3 +-- src/chinit.c | 9 +-------- src/chqueues.c | 16 ++++++++-------- src/chschd.c | 5 ----- src/chsleep.c | 2 -- src/include/delta.h | 40 +++++++++++++++++++--------------------- src/include/scheduler.h | 3 --- src/include/sleep.h | 12 ++---------- src/templates/chconf.h | 17 +++-------------- 10 files changed, 34 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/chdebug.c b/src/chdebug.c index a826776fe..56edd2a0d 100644 --- a/src/chdebug.c +++ b/src/chdebug.c @@ -60,11 +60,7 @@ TraceBuffer dbgtb; void chDbgTrace(Thread *otp, Thread *ntp) { dbgtb.tb_ptr->cse_wtobjp = otp->p_wtobjp; -#ifdef CH_USE_SYSTEMTIME dbgtb.tb_ptr->cse_time = chSysGetTime(); -#else - dbgtb.tb_ptr->cse_time = 0; -#endif dbgtb.tb_ptr->cse_state = otp->p_state; dbgtb.tb_ptr->cse_tid = ntp->p_tid; if (++dbgtb.tb_ptr >= &dbgtb.tb_buffer[TRACE_BUFFER_SIZE]) diff --git a/src/chdelta.c b/src/chdelta.c index 62f3b35cc..ec654907c 100644 --- a/src/chdelta.c +++ b/src/chdelta.c @@ -24,7 +24,6 @@ #include -#ifdef CH_USE_VIRTUAL_TIMERS DeltaList dlist; /** @@ -35,6 +34,7 @@ void chVTInit(void) { dlist.dl_next = dlist.dl_prev = (void *)&dlist; dlist.dl_dtime = (systime_t)-1; + dlist.dl_stime = 0; } /** @@ -86,6 +86,5 @@ void chVTResetI(VirtualTimer *vtp) { vtp->vt_next->vt_prev = vtp->vt_prev; vtp->vt_func = 0; } -#endif /* CH_USE_VIRTUAL_TIMER */ /** @} */ diff --git a/src/chinit.c b/src/chinit.c index 5d46808d8..d93ac1581 100644 --- a/src/chinit.c +++ b/src/chinit.c @@ -37,9 +37,7 @@ void chSysInit(void) { chSchInit(); chDbgInit(); -#ifdef CH_USE_VIRTUAL_TIMERS chVTInit(); -#endif #ifdef CH_USE_HEAP chHeapInit(); #endif @@ -69,19 +67,14 @@ void chSysInit(void) { * together with the \p CH_TIME_QUANTUM macro, the round robin interval. */ void chSysTimerHandlerI(void) { + #ifdef CH_USE_ROUNDROBIN /* running thread has not used up quantum yet? */ if (rlist.r_preempt > 0) /* decrement remaining quantum */ rlist.r_preempt--; #endif -#ifdef CH_USE_SYSTEMTIME - rlist.r_stime++; -#endif - -#ifdef CH_USE_VIRTUAL_TIMERS chVTDoTickI(); -#endif } /** @} */ diff --git a/src/chqueues.c b/src/chqueues.c index ed9eb840c..30e71a055 100644 --- a/src/chqueues.c +++ b/src/chqueues.c @@ -108,7 +108,7 @@ msg_t chIQGet(Queue *qp) { return b; } -#ifdef CH_USE_QUEUES_TIMEOUT +#if defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) /** * Gets a byte from the input queue, if the queue is empty then the * calling thread is suspended until a byte arrives in the queue or the @@ -118,8 +118,8 @@ msg_t chIQGet(Queue *qp) { * @return A byte value from the queue. * @retval Q_TIMEOUT if the specified time expired. * @retval Q_RESET if the queue was reset. - * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT - * option is enabled in \p chconf.h. + * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT and + * \p CH_USE_SEMAPHORES_TIMEOUT options are enabled in \p chconf.h. */ msg_t chIQGetTimeout(Queue *qp, systime_t time) { uint8_t b; @@ -142,7 +142,7 @@ msg_t chIQGetTimeout(Queue *qp, systime_t time) { chSysUnlock(); return b; } -#endif /* CH_USE_QUEUES_TIMEOUTS */ +#endif /* defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) */ /** * Reads some data from the input queue into the specified buffer. The function @@ -358,7 +358,7 @@ msg_t chHDQGetReceive(HalfDuplexQueue *qp) { return b; } -#ifdef CH_USE_QUEUES_TIMEOUT +#if defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) /** * Reads a byte from the receive queue, if the queue is empty or is in * transmission mode then the invoking thread is suspended. @@ -366,8 +366,8 @@ msg_t chHDQGetReceive(HalfDuplexQueue *qp) { * @param time the number of ticks before the operation timouts * @return The byte value. * @retval Q_TIMEOUT if a timeout occurs. - * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT - * option is enabled in \p chconf.h. + * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT and + * \p CH_USE_SEMAPHORES_TIMEOUT options are enabled in \p chconf.h. */ msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time) { uint8_t b; @@ -394,7 +394,7 @@ msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time) { chSysUnlock(); return b; } -#endif +#endif /* defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) */ /** * Writes a byte into the transmit queue. If the buffer contains unread diff --git a/src/chschd.c b/src/chschd.c index 2ac2a9e1d..b6fd624e0 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -39,9 +39,6 @@ void chSchInit(void) { #ifdef CH_USE_ROUNDROBIN rlist.r_preempt = CH_TIME_QUANTUM; #endif -#ifdef CH_USE_SYSTEMTIME - rlist.r_stime = 0; -#endif } /** @@ -94,7 +91,6 @@ void chSchGoSleepS(tstate_t newstate) { chSysSwitchI(otp, currp); } -#ifdef CH_USE_VIRTUAL_TIMERS /* * Timeout wakeup callback. */ @@ -130,7 +126,6 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { chVTResetI(&vt); return currp->p_rdymsg; } -#endif /* CH_USE_VIRTUAL_TIMERS */ /** * Wakes up a thread. diff --git a/src/chsleep.c b/src/chsleep.c index 1fc686120..7bf805471 100644 --- a/src/chsleep.c +++ b/src/chsleep.c @@ -35,7 +35,6 @@ void chThdSleep(systime_t time) { chSysUnlock(); } -#ifdef CH_USE_SYSTEMTIME /** * Checks if the current system time is within the specified time window. * @param start the start of the time window (inclusive) @@ -47,6 +46,5 @@ bool_t chSysInTimeWindow(systime_t start, systime_t end) { return end >= start ? (time >= start) && (time < end) : (time >= start) || (time < end); } -#endif /* CH_USE_SYSTEMTIME */ /** @} */ diff --git a/src/include/delta.h b/src/include/delta.h index 4d59c1a73..4d1c9ac23 100644 --- a/src/include/delta.h +++ b/src/include/delta.h @@ -25,8 +25,6 @@ #ifndef _DELTA_H_ #define _DELTA_H_ -#ifdef CH_USE_VIRTUAL_TIMERS - /** Virtual Timer callback function.*/ typedef void (*vtfunc_t)(void *); @@ -37,17 +35,17 @@ typedef struct VirtualTimer VirtualTimer; * @extends DeltaList */ struct VirtualTimer { - /** Next timer in the delta list.*/ - VirtualTimer *vt_next; - /** Previous timer in the delta list.*/ - VirtualTimer *vt_prev; - /** Time delta before timeout.*/ - systime_t vt_dtime; - /** Timer callback function pointer. The pointer is reset to zero after - the callback is invoked.*/ - vtfunc_t vt_func; - /** Timer callback function parameter.*/ - void *vt_par; + /** Next timer in the delta list.*/ + VirtualTimer *vt_next; + /** Previous timer in the delta list.*/ + VirtualTimer *vt_prev; + /** Time delta before timeout.*/ + systime_t vt_dtime; + /** Timer callback function pointer. The pointer is reset to zero after + the callback is invoked.*/ + vtfunc_t vt_func; + /** Timer callback function parameter.*/ + void *vt_par; }; /** @@ -57,17 +55,19 @@ struct VirtualTimer { * is often used in the code. */ typedef struct { - /** Next timer in the list (the one that will be triggered next).*/ - VirtualTimer *dl_next; - /** Last timer in the list.*/ - VirtualTimer *dl_prev; - /** Not used but it must be set to -1.*/ - systime_t dl_dtime; + /** Next timer in the list (the one that will be triggered next).*/ + VirtualTimer *dl_next; + /** Last timer in the list.*/ + VirtualTimer *dl_prev; + /** Not used but it must be set to -1.*/ + systime_t dl_dtime; + volatile systime_t dl_stime; } DeltaList; extern DeltaList dlist; #define chVTDoTickI() { \ + dlist.dl_stime++; \ if (&dlist != (DeltaList *)dlist.dl_next) { \ VirtualTimer *vtp; \ \ @@ -100,8 +100,6 @@ extern "C" { /** Returns TRUE if the speciified timer is armed.*/ #define chVTIsArmedI(vtp) ((vtp)->vt_func != NULL) -#endif /* CH_USE_VIRTUAL_TIMER */ - #endif /* _DELTA_H_ */ /** @} */ diff --git a/src/include/scheduler.h b/src/include/scheduler.h index 362dd9d31..3f9eb7a39 100644 --- a/src/include/scheduler.h +++ b/src/include/scheduler.h @@ -48,9 +48,6 @@ typedef struct { /** the currently running thread */ Thread *r_current; #endif -#ifdef CH_USE_SYSTEMTIME - volatile systime_t r_stime; -#endif } ReadyList; extern ReadyList rlist; diff --git a/src/include/sleep.h b/src/include/sleep.h index 109d9d072..faed26109 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -46,29 +46,22 @@ extern "C" { #endif void chThdSleep(systime_t time); -#ifdef CH_USE_SYSTEMTIME -bool_t chSysInTimeWindow(systime_t start, systime_t end); -#endif /* CH_USE_SYSTEMTIME */ + bool_t chSysInTimeWindow(systime_t start, systime_t end); #ifdef __cplusplus } #endif -#ifdef CH_USE_SYSTEMTIME /** * Returns the number of system ticks since the \p chSysInit() invocation. * @return the system ticks number * @note The counter can reach its maximum and then returns to zero. * @note This function is designed to work with the \p chThdSleepUntil(). - * @note The function is available only if the \p CH_USE_SYSTEMTIME - * option is enabled in \p chconf.h. */ -#define chSysGetTime() rlist.r_stime +#define chSysGetTime() dlist.dl_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(); \ @@ -76,7 +69,6 @@ bool_t chSysInTimeWindow(systime_t start, systime_t end); (systime_t)((t) - chSysGetTime())); \ chSysUnlock(); \ } -#endif /* CH_USE_SYSTEMTIME */ #endif /* _SLEEP_H_ */ diff --git a/src/templates/chconf.h b/src/templates/chconf.h index 37569772e..5a16800bc 100644 --- a/src/templates/chconf.h +++ b/src/templates/chconf.h @@ -35,18 +35,10 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED -/** Configuration option: if specified then the Virtual Timers subsystem is - * included in the kernel.*/ -#define CH_USE_VIRTUAL_TIMERS - /** Configuration option: if specified then the kernel performs the round * robin scheduling algorithm on threads of equal priority.*/ #define CH_USE_ROUNDROBIN -/** Configuration option: if specified then the System Timer subsystem is - * included in the kernel.*/ -#define CH_USE_SYSTEMTIME - /** Configuration option: if specified then the \p chThdWait() function * is included in the kernel.*/ #define CH_USE_WAITEXIT @@ -61,8 +53,7 @@ /** Configuration option: if specified then the Semaphores with timeout APIs * are included in the kernel. - * @note requires \p CH_USE_SEMAPHORES. - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/ + * @note requires \p CH_USE_SEMAPHORES.*/ #define CH_USE_SEMAPHORES_TIMEOUT /** Configuration option: if specified then the Mutexes APIs are included in @@ -75,8 +66,7 @@ /** Configuration option: if specified then the \p chEvtWaitTimeout() * function is included in the kernel. - * @note requires \p CH_USE_EVENTS. - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/ + * @note requires \p CH_USE_EVENTS.*/ #define CH_USE_EVENTS_TIMEOUT /** Configuration option: if specified then the Synchronous Messages APIs are @@ -85,8 +75,7 @@ /** Configuration option: if specified then the \p chMsgSendWithEvent() * function is included in the kernel. - * @note requires \p CH_USE_MESSAGES. - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/ + * @note requires \p CH_USE_MESSAGES.*/ #define CH_USE_MESSAGES_EVENT /** Configuration option: If enabled then the threads have an option to serve -- cgit v1.2.3