From 8feba91865981a1cb8b1ba12c4bce09997141f2f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 26 Sep 2008 10:46:10 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@444 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chthreads.c | 13 ++++++------- src/include/threads.h | 2 ++ src/templates/chconf.h | 34 +++++++++++++++------------------- 3 files changed, 23 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/chthreads.c b/src/chthreads.c index 676df3d68..755cda99e 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -51,9 +51,7 @@ Thread *init_thread(Thread *tp, tprio_t prio) { #ifdef CH_USE_EXIT_EVENT chEvtInit(&tp->p_exitesource); #endif -#ifdef CH_USE_THREAD_EXT THREAD_EXT_INIT(tp); -#endif return tp; } @@ -295,16 +293,17 @@ void chThdTerminate(Thread *tp) { * \p chThdWait(). */ void chThdExit(msg_t msg) { + Thread *tp = currp; chSysLock(); - - currp->p_exitcode = msg; + tp->p_exitcode = msg; + THREAD_EXT_EXIT(tp); #ifdef CH_USE_WAITEXIT - while (notempty(&currp->p_waiting)) - chSchReadyI(list_remove(&currp->p_waiting)); + while (notempty(&tp->p_waiting)) + chSchReadyI(list_remove(&tp->p_waiting)); #endif #ifdef CH_USE_EXIT_EVENT - chEvtBroadcastI(&currp->p_exitesource); + chEvtBroadcastI(&tp->p_exitesource); #endif chSchGoSleepS(PREXIT); } diff --git a/src/include/threads.h b/src/include/threads.h index 5248c807e..099b8466f 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -235,6 +235,8 @@ extern "C" { * 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. + * @deprecated \p THREAD_EXT_EXIT should be used, this functionality will be + * removed in version 1.0.0. */ #define chThdGetExitEventSource(tp) (&(tp)->p_exitesource) diff --git a/src/templates/chconf.h b/src/templates/chconf.h index 1f5ca1446..37569772e 100644 --- a/src/templates/chconf.h +++ b/src/templates/chconf.h @@ -35,13 +35,6 @@ * that this is not related to the compiler optimization options.*/ #define CH_OPTIMIZE_SPEED -/** Configuration option: it specified this option enables the \p Thread - * extension fields and initiazation code. - * @see THREAD_EXT_FIELDS - * @see THREAD_EXT_INIT - */ -#define CH_USE_THREAD_EXT - /** Configuration option: if specified then the Virtual Timers subsystem is * included in the kernel.*/ #define CH_USE_VIRTUAL_TIMERS @@ -103,8 +96,10 @@ /** Configuration option: if specified then the * \p chThdGetExitEventSource() function is included in the kernel. - * @note requires \p CH_USE_MESSAGES. - * @note requires \p CH_USE_EVENTS.*/ + * @note requires \p CH_USE_EVENTS. + * @deprecated \p THREAD_EXT_EXIT should be used, this functionality will be + * removed in version 1.0.0. + */ #define CH_USE_EXIT_EVENT /** Configuration option: if specified then the I/O queues APIs are included @@ -186,21 +181,22 @@ */ #define CH_USE_TRACE -/** User fields added to the end of the \p Thread structure if the - * \p CH_USE_THREAD_EXT option is enabled. - * @see CH_USE_THREAD_EXT - */ +/** User fields added to the end of the \p Thread structure. */ #define THREAD_EXT_FIELDS \ struct { \ - /* Add fields here.*/ \ + /* Add thread custom fields here.*/ \ }; -/** User initialization code added to the \p chThdCreate() API if the - * \p CH_USE_THREAD_EXT option is enabled. - * @see CH_USE_THREAD_EXT - */ +/** User initialization code added to the \p chThdCreate() API. + * @note It is invoked from within \p chThdInit(). */ #define THREAD_EXT_INIT(tp) { \ - /* Add initialization code here.*/ \ + /* Add thread initialization code here.*/ \ +} + +/** User finalization code added to the \p chThdExit() API. + * @note It is inserted into lock zone. */ +#define THREAD_EXT_EXIT(tp) { \ + /* Add thread finalization code here.*/ \ } #endif /* _CHCONF_H_ */ -- cgit v1.2.3