From 9a0ef300bce50901d5de3d6d722e29b79a2f9a36 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 28 Sep 2007 18:42:04 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@25 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chsleep.c | 4 ++-- src/chthreads.c | 49 ------------------------------------------------- src/include/threads.h | 46 +++++++++++++++++++++++++++++++++++++++++----- src/templates/chcore.c | 2 +- src/templates/chcore.h | 4 ++-- 5 files changed, 46 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/chsleep.c b/src/chsleep.c index 9fedd0244..5814410f3 100644 --- a/src/chsleep.c +++ b/src/chsleep.c @@ -62,11 +62,11 @@ t_time chSysGetTime(void) { * option is enabled in \p chconf.h. */ void chThdSleepUntil(t_time time) { - VirtualTimer t; + VirtualTimer vt; chSysLock(); - chVTSetI(&t, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp); + chVTSetI(&vt, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp); chSchGoSleepI(PRSLEEP); chSysUnlock(); diff --git a/src/chthreads.c b/src/chthreads.c index 59c361116..a439eb5b4 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -129,17 +129,6 @@ Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace, return tp; } -/** - * Verifies if the specified thread is in the \p PREXIT state. - * @param tp the pointer to the thread - * @return \p TRUE if the thread is ended else \p FALSE. \p TRUE ensures that - * a subsequent call to \p chThdWait() would not block. - */ -BOOL chThdTerminated(Thread *tp) { - - return tp->p_state == PREXIT; -} - #ifdef CH_USE_RESUME /** * Resumes a thread created with the \p P_SUSPENDED option. @@ -176,17 +165,6 @@ void chThdTerminate(Thread *tp) { chSysUnlock(); } - -/** - * Verifies if the current thread has a termination request pending. - * @return \p TRUE if the termination was requested. The thread should terminate - * as soon it is ready to do so. - */ -BOOL chThdShouldTerminate(void) { - - return currp->p_flags & P_TERMINATE ? TRUE : FALSE; -} - #endif /** @@ -234,31 +212,4 @@ t_msg chThdWait(Thread *tp) { } #endif /* CH_USE_WAITEXIT */ -#ifdef CH_USE_EXIT_EVENT -/** - * Returns the exit event source for the specified thread. The source is - * signaled when the thread terminates. - * @param tp the pointer to the thread - * @note When registering on a thread termination make sure the thread - * is still alive, if you do that after the thread termination - * then you would miss the event. There are two ways to ensure - * this:
- * - * @note You dont need to unregister from a terminated thread because - * the event source becomes inactive. - * @note The function is available only if the \p CH_USE_EXIT_EVENT - * option is enabled in \p chconf.h. - */ -EventSource *chThdGetExitEventSource(Thread *tp) { - - return &tp->p_exitesource; -} -#endif /* CH_USE_EXIT_EVENT */ - /** @} */ diff --git a/src/include/threads.h b/src/include/threads.h index f170ce368..688ce579a 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -182,19 +182,55 @@ static INLINE void enqueue(Thread *tp, ThreadsQueue *tqp) { /* * Threads APIs. */ -#define chThdSelf() currp Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace, t_size wsize, t_tfunc pf, void *arg); void chThdResume(Thread *tp); -void chThdTerminate(Thread *tp); -BOOL chThdShouldTerminate(void); -BOOL chThdTerminated(Thread *tp); void chThdExit(t_msg msg); + +/** Returns the pointer to the \p Thread currently in execution.*/ +#define chThdSelf() currp + +/** Returns the pointer to the \p Thread local storage area, if any.*/ +#define chThdLS() (void *)(currp + 1) + +/** Verifies if the specified thread is in the \p PREXIT state.*/ +#define chThdTerminated(tp) ((tp)->p_state == PREXIT) + +#ifdef CH_USE_TERMINATE +/** + * Verifies if the current thread has a termination request pending. + */ +#define chThdShouldTerminate() (currp->p_flags & P_TERMINATE) + +void chThdTerminate(Thread *tp); +#endif + #ifdef CH_USE_WAITEXIT t_msg chThdWait(Thread *tp); #endif + #ifdef CH_USE_EXIT_EVENT -EventSource *chThdGetExitEventSource(Thread *tp); +/** + * Returns the exit event source for the specified thread. The source is + * signaled when the thread terminates. + * @param tp the pointer to the thread + * @note When registering on a thread termination make sure the thread + * is still alive, if you do that after the thread termination + * then you would miss the event. There are two ways to ensure + * this:
+ * + * @note You dont need to unregister from a terminated thread because + * the event source becomes inactive. + * @note The function is available only if the \p CH_USE_EXIT_EVENT + * option is enabled in \p chconf.h. + */ +#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource) #endif #endif /* _THREADS_H_ */ diff --git a/src/templates/chcore.c b/src/templates/chcore.c index 29a809378..e23cf1bfe 100644 --- a/src/templates/chcore.c +++ b/src/templates/chcore.c @@ -37,7 +37,7 @@ void chSysPause(void) {} /** - * Abonormal system termination handler. Invoked by the ChobiOS/RT when an + * Abonormal system termination handler. Invoked by the ChibiOS/RT when an * abnormal unrecoverable condition is met. */ void chSysHalt(void) {} diff --git a/src/templates/chcore.h b/src/templates/chcore.h index 895e2b685..bb901b1ec 100644 --- a/src/templates/chcore.h +++ b/src/templates/chcore.h @@ -39,7 +39,7 @@ struct stackregs { } /** - * Enters the ChobiOS/RT system mutual exclusion zone, the implementation is + * Enters the ChibiOS/RT system mutual exclusion zone, the implementation is * architecture dependent, on single core systems usually this function * just disables the interrupts. * @note The code in the system mutual exclusion zone must be as light and @@ -50,7 +50,7 @@ struct stackregs { #define chSysLock() /** - * Leaves the ChobiOS/RT system mutual exclusion zone, the implementation is + * Leaves the ChibiOS/RT system mutual exclusion zone, the implementation is * architecture dependent, on single core systems usually this function * just enables the interrupts. * @note The code in the system mutual exclusion zone must be as light and -- cgit v1.2.3