From bef9d20d8eb9186a4f03c397ae880be7cad7efe1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 4 Dec 2007 14:48:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@126 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chinit.c | 18 ++++++++++++++++++ src/chqueues.c | 5 ++++- src/chschd.c | 18 ------------------ src/chsleep.c | 6 +----- src/include/ch.h | 1 + src/include/scheduler.h | 1 - 6 files changed, 24 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/chinit.c b/src/chinit.c index 9fa079e2c..c7c0c7735 100644 --- a/src/chinit.c +++ b/src/chinit.c @@ -58,4 +58,22 @@ void chSysInit(void) { chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), (t_tfunc)_IdleThread, NULL); } +/** + * Preemption routine, this function must be called into an interrupt + * handler invoked by a system timer. + * The frequency of the timer determines the system tick granularity and, + * together with the \p CH_TIME_QUANTUM macro, the round robin interval. + */ +void chSysTimerHandlerI(void) { + + rlist.r_preempt--; +#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 d0412598b..ddc2cfdff 100644 --- a/src/chqueues.c +++ b/src/chqueues.c @@ -125,8 +125,11 @@ t_msg chIQGetTimeout(Queue *qp, t_time time) { chSysLock(); - if ((msg = chSemWaitTimeoutS(&qp->q_sem, time)) < RDY_OK) + if ((msg = chSemWaitTimeoutS(&qp->q_sem, time)) < RDY_OK) { + + chSysUnlock(); return msg; + } b = *qp->q_rdptr++; if (qp->q_rdptr >= qp->q_top) qp->q_rdptr = qp->q_buffer; diff --git a/src/chschd.c b/src/chschd.c index c4b5df5a9..e091bb0a0 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -166,22 +166,4 @@ BOOL chSchRescRequiredI(void) { return TRUE; } -/** - * Preemption routine, this function must be called into an interrupt - * handler invoked by a system timer. - * The frequency of the timer determines the system tick granularity and, - * together with the \p CH_TIME_QUANTUM macro, the round robin interval. - */ -void chSchTimerHandlerI(void) { - - rlist.r_preempt--; -#ifdef CH_USE_SYSTEMTIME - rlist.r_stime++; -#endif - -#ifdef CH_USE_VIRTUAL_TIMERS - chVTDoTickI(); -#endif -} - /** @} */ diff --git a/src/chsleep.c b/src/chsleep.c index 3abf22cd2..b6c31e1a4 100644 --- a/src/chsleep.c +++ b/src/chsleep.c @@ -27,10 +27,7 @@ #ifdef CH_USE_SLEEP static void wakeup(void *p) { -#ifdef CH_USE_DEBUG - if (((Thread *)p)->p_state != PRSLEEP) - chDbgPanic("chsleep.c, wakeup()"); -#endif + chDbgAssert(((Thread *)p)->p_state == PRSLEEP, "chsleep.c, wakeup()"); chSchReadyI(p, RDY_OK); } @@ -72,4 +69,3 @@ void chThdSleepUntil(t_time time) { #endif /* CH_USE_SLEEP */ /** @} */ - diff --git a/src/include/ch.h b/src/include/ch.h index 0ef78fbf4..be251415f 100644 --- a/src/include/ch.h +++ b/src/include/ch.h @@ -106,6 +106,7 @@ extern "C" { #endif void chSysInit(void); + void chSysTimerHandlerI(void); #ifdef __cplusplus } #endif diff --git a/src/include/scheduler.h b/src/include/scheduler.h index 4aed76e28..183e3af79 100644 --- a/src/include/scheduler.h +++ b/src/include/scheduler.h @@ -64,7 +64,6 @@ extern "C" { void chSchRescheduleS(void); void chSchDoRescheduleI(void); BOOL chSchRescRequiredI(void); - void chSchTimerHandlerI(void); #ifdef __cplusplus } #endif -- cgit v1.2.3