From 2e4ba09bb54f415e7f8fd66f4ccddbf421612820 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 16:12:33 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5860 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 140 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 131 insertions(+), 9 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 77f72caca..1341cb1ea 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -20,7 +20,7 @@ /** * @file chthreads.h - * @brief Threads macros and structures. + * @brief Threads module macros and structures. * * @addtogroup threads * @{ @@ -29,6 +29,10 @@ #ifndef _CHTHREADS_H_ #define _CHTHREADS_H_ +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + /** * @name Thread states * @{ @@ -76,6 +80,42 @@ #define THD_TERMINATE 4 /**< @brief Termination requested flag. */ /** @} */ +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/* Forward declaration required by the mutexes stack structure present + in every thread.*/ +#if CH_USE_MUTEXES +typedef struct Mutex Mutex; +#endif + +/** + * @brief Generic threads single link list, it works like a stack. + */ +typedef struct { + + Thread *p_next; /**< @brief Next in the list/queue. */ +} ThreadsList; + +/** + * @extends ThreadsList + * + * @brief Generic threads bidirectional linked list header and element. + */ +typedef struct { + Thread *p_next; /**< @brief Next in the list/queue. */ + Thread *p_prev; /**< @brief Previous in the queue. */ +} ThreadsQueue; + /** * @extends ThreadsQueue * @@ -221,6 +261,32 @@ struct Thread { */ typedef msg_t (*tfunc_t)(void *); +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/** + * @brief Data part of a static threads queue initializer. + * @details This macro should be used when statically initializing a threads + * queue that is part of a bigger structure. + * + * @param[in] name the name of the threads queue variable + */ +#define _THREADSQUEUE_DATA(name) {(Thread *)&name, (Thread *)&name} + +/** + * @brief Static threads queue initializer. + * @details Statically initialized threads queues require no explicit + * initialization using @p queue_init(). + * + * @param[in] name the name of the threads queue variable + */ +#define THREADSQUEUE_DECL(name) ThreadsQueue name = _THREADSQUEUE_DATA(name) + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + /** * @name Macro Functions * @{ @@ -253,14 +319,6 @@ typedef msg_t (*tfunc_t)(void *); */ #define chThdGetTicks(tp) ((tp)->p_time) -/** - * @brief Returns the pointer to the @p Thread local storage area, if any. - * @note Can be invoked in any context. - * - * @special - */ -#define chThdLS() (void *)(currp + 1) - /** * @brief Verifies if the specified thread is in the @p THD_STATE_FINAL state. * @note Can be invoked in any context. @@ -375,6 +433,70 @@ extern "C" { } #endif +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +/** + * @brief Threads list initialization. + * + * @notapi + */ +static inline void list_init(ThreadsList *tlp) { + + tlp->p_next = (Thread *)tlp; +} + +/** + * @brief Evaluates to @p TRUE if the specified threads list is empty. + * + * @notapi + */ +static inline bool_t list_isempty(ThreadsList *tlp) { + + return (bool_t)(tlp->p_next == (Thread *)tlp); +} + +/** + * @brief Evaluates to @p TRUE if the specified threads list is not empty. + * + * @notapi + */ +static inline bool_t list_notempty(ThreadsList *tlp) { + + return (bool_t)(tlp->p_next != (Thread *)tlp); +} + +/** + * @brief Threads queue initialization. + * + * @notapi + */ +static inline void queue_init(ThreadsQueue *tqp) { + + tqp->p_next = tqp->p_prev = (Thread *)tqp; +} + +/** + * @brief Evaluates to @p TRUE if the specified threads queue is empty. + * + * @notapi + */ +static inline bool_t queue_isempty(ThreadsQueue *tqp) { + + return (bool_t)(tqp->p_next == (Thread *)tqp); +} + +/** + * @brief Evaluates to @p TRUE if the specified threads queue is not empty. + * + * @notapi + */ +static inline bool_t queue_notempty(ThreadsQueue *tqp) { + + return (bool_t)(tqp->p_next != (Thread *)tqp); +} + #endif /* _CHTHREADS_H_ */ /** @} */ -- cgit v1.2.3 From 745d8c15044781f1215f2188edcc402fafadd059 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 16:30:00 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5861 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 78 ------------------------------------------- 1 file changed, 78 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 1341cb1ea..854a72dde 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -265,24 +265,6 @@ typedef msg_t (*tfunc_t)(void *); /* Module macros. */ /*===========================================================================*/ -/** - * @brief Data part of a static threads queue initializer. - * @details This macro should be used when statically initializing a threads - * queue that is part of a bigger structure. - * - * @param[in] name the name of the threads queue variable - */ -#define _THREADSQUEUE_DATA(name) {(Thread *)&name, (Thread *)&name} - -/** - * @brief Static threads queue initializer. - * @details Statically initialized threads queues require no explicit - * initialization using @p queue_init(). - * - * @param[in] name the name of the threads queue variable - */ -#define THREADSQUEUE_DECL(name) ThreadsQueue name = _THREADSQUEUE_DATA(name) - /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -437,66 +419,6 @@ extern "C" { /* Module inline functions. */ /*===========================================================================*/ -/** - * @brief Threads list initialization. - * - * @notapi - */ -static inline void list_init(ThreadsList *tlp) { - - tlp->p_next = (Thread *)tlp; -} - -/** - * @brief Evaluates to @p TRUE if the specified threads list is empty. - * - * @notapi - */ -static inline bool_t list_isempty(ThreadsList *tlp) { - - return (bool_t)(tlp->p_next == (Thread *)tlp); -} - -/** - * @brief Evaluates to @p TRUE if the specified threads list is not empty. - * - * @notapi - */ -static inline bool_t list_notempty(ThreadsList *tlp) { - - return (bool_t)(tlp->p_next != (Thread *)tlp); -} - -/** - * @brief Threads queue initialization. - * - * @notapi - */ -static inline void queue_init(ThreadsQueue *tqp) { - - tqp->p_next = tqp->p_prev = (Thread *)tqp; -} - -/** - * @brief Evaluates to @p TRUE if the specified threads queue is empty. - * - * @notapi - */ -static inline bool_t queue_isempty(ThreadsQueue *tqp) { - - return (bool_t)(tqp->p_next == (Thread *)tqp); -} - -/** - * @brief Evaluates to @p TRUE if the specified threads queue is not empty. - * - * @notapi - */ -static inline bool_t queue_notempty(ThreadsQueue *tqp) { - - return (bool_t)(tqp->p_next != (Thread *)tqp); -} - #endif /* _CHTHREADS_H_ */ /** @} */ -- cgit v1.2.3 From 43a7a0820fa1873dba8e77d7890b614fb5dd93dd Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 16 Jun 2013 16:48:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5862 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 854a72dde..800263092 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -265,10 +265,6 @@ typedef msg_t (*tfunc_t)(void *); /* Module macros. */ /*===========================================================================*/ -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - /** * @name Macro Functions * @{ @@ -386,6 +382,10 @@ typedef msg_t (*tfunc_t)(void *); #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) /** @} */ +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + /* * Threads APIs. */ -- cgit v1.2.3 From 3b6423187e643f8d1005d5fca2617a5485bc16b8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 09:43:11 +0000 Subject: Started renaming the types to follow the _t convention. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5988 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 800263092..b8ff5693e 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -104,20 +104,20 @@ typedef struct Mutex Mutex; typedef struct { Thread *p_next; /**< @brief Next in the list/queue. */ -} ThreadsList; +} threads_list_t; /** - * @extends ThreadsList + * @extends threads_list_t * * @brief Generic threads bidirectional linked list header and element. */ typedef struct { Thread *p_next; /**< @brief Next in the list/queue. */ Thread *p_prev; /**< @brief Previous in the queue. */ -} ThreadsQueue; +} threads_queue_t; /** - * @extends ThreadsQueue + * @extends threads_queue_t * * @brief Structure representing a thread. * @note Not all the listed fields are always needed, by switching off some @@ -126,9 +126,9 @@ typedef struct { */ struct Thread { Thread *p_next; /**< @brief Next in the list/queue. */ - /* End of the fields shared with the ThreadsList structure. */ + /* End of the fields shared with the threads_list_t structure.*/ Thread *p_prev; /**< @brief Previous in the queue. */ - /* End of the fields shared with the ThreadsQueue structure. */ + /* End of the fields shared with the threads_queue_t structure.*/ tprio_t p_prio; /**< @brief Thread priority. */ struct context p_ctx; /**< @brief Processor context. */ #if CH_USE_REGISTRY || defined(__DOXYGEN__) @@ -215,13 +215,13 @@ struct Thread { /** * @brief Termination waiting list. */ - ThreadsList p_waiting; + threads_list_t p_waiting; #endif #if CH_USE_MESSAGES || defined(__DOXYGEN__) /** * @brief Messages queue. */ - ThreadsQueue p_msgqueue; + threads_queue_t p_msgqueue; /** * @brief Thread message. */ -- cgit v1.2.3 From 3a504e26ce59c61235bb18930225b8104fafbaad Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 09:56:22 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5989 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index b8ff5693e..95fd5c4d8 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -124,7 +124,7 @@ typedef struct { * not needed ChibiOS/RT subsystems it is possible to save RAM space * by shrinking the @p Thread structure. */ -struct Thread { +typedef struct Thread { Thread *p_next; /**< @brief Next in the list/queue. */ /* End of the fields shared with the threads_list_t structure.*/ Thread *p_prev; /**< @brief Previous in the queue. */ @@ -254,7 +254,7 @@ struct Thread { /* Extra fields defined in chconf.h.*/ THREAD_EXT_FIELDS #endif -}; +} Thread; /** * @brief Thread function. -- cgit v1.2.3 From 84e044f176cee7c6946b24c36c90f63534b5b369 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 12:22:31 +0000 Subject: Renamed Thread to thread_t. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5995 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 95fd5c4d8..452ffd37d 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -103,7 +103,7 @@ typedef struct Mutex Mutex; */ typedef struct { - Thread *p_next; /**< @brief Next in the list/queue. */ + thread_t *p_next; /**< @brief Next in the list/queue. */ } threads_list_t; /** @@ -112,8 +112,8 @@ typedef struct { * @brief Generic threads bidirectional linked list header and element. */ typedef struct { - Thread *p_next; /**< @brief Next in the list/queue. */ - Thread *p_prev; /**< @brief Previous in the queue. */ + thread_t *p_next; /**< @brief Next in the list/queue. */ + thread_t *p_prev; /**< @brief Previous in the queue. */ } threads_queue_t; /** @@ -122,18 +122,18 @@ typedef struct { * @brief Structure representing a thread. * @note Not all the listed fields are always needed, by switching off some * not needed ChibiOS/RT subsystems it is possible to save RAM space - * by shrinking the @p Thread structure. + * by shrinking the @p thread_t structure. */ -typedef struct Thread { - Thread *p_next; /**< @brief Next in the list/queue. */ +typedef struct thread { + thread_t *p_next; /**< @brief Next in the list/queue. */ /* End of the fields shared with the threads_list_t structure.*/ - Thread *p_prev; /**< @brief Previous in the queue. */ + thread_t *p_prev; /**< @brief Previous in the queue. */ /* End of the fields shared with the threads_queue_t structure.*/ tprio_t p_prio; /**< @brief Thread priority. */ struct context p_ctx; /**< @brief Processor context. */ #if CH_USE_REGISTRY || defined(__DOXYGEN__) - Thread *p_newer; /**< @brief Newer registry element. */ - Thread *p_older; /**< @brief Older registry element. */ + thread_t *p_newer; /**< @brief Newer registry element. */ + thread_t *p_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the ReadyList structure. */ #if CH_USE_REGISTRY || defined(__DOXYGEN__) @@ -254,10 +254,10 @@ typedef struct Thread { /* Extra fields defined in chconf.h.*/ THREAD_EXT_FIELDS #endif -} Thread; +} thread_t; /** - * @brief Thread function. + * @brief Thread function. */ typedef msg_t (*tfunc_t)(void *); @@ -270,7 +270,7 @@ typedef msg_t (*tfunc_t)(void *); * @{ */ /** - * @brief Returns a pointer to the current @p Thread. + * @brief Returns a pointer to the current @p thread_t. * @note Can be invoked in any context. * * @special @@ -386,30 +386,27 @@ typedef msg_t (*tfunc_t)(void *); /* External declarations. */ /*===========================================================================*/ -/* - * Threads APIs. - */ #ifdef __cplusplus extern "C" { #endif - Thread *_thread_init(Thread *tp, tprio_t prio); + thread_t *_thread_init(thread_t *tp, tprio_t prio); #if CH_DBG_FILL_THREADS void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v); #endif - Thread *chThdCreateI(void *wsp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); - Thread *chThdCreateStatic(void *wsp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); + thread_t *chThdCreateI(void *wsp, size_t size, + tprio_t prio, tfunc_t pf, void *arg); + thread_t *chThdCreateStatic(void *wsp, size_t size, + tprio_t prio, tfunc_t pf, void *arg); tprio_t chThdSetPriority(tprio_t newprio); - Thread *chThdResume(Thread *tp); - void chThdTerminate(Thread *tp); + thread_t *chThdResume(thread_t *tp); + void chThdTerminate(thread_t *tp); void chThdSleep(systime_t time); void chThdSleepUntil(systime_t time); void chThdYield(void); void chThdExit(msg_t msg); void chThdExitS(msg_t msg); #if CH_USE_WAITEXIT - msg_t chThdWait(Thread *tp); + msg_t chThdWait(thread_t *tp); #endif #ifdef __cplusplus } -- cgit v1.2.3 From 25ddb1c801f06a3be7171e20dcfd46d11a75f112 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 14:51:35 +0000 Subject: First cleanup pass finished, queues and streams not yet removed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5999 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 452ffd37d..c46103faf 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -95,7 +95,7 @@ /* Forward declaration required by the mutexes stack structure present in every thread.*/ #if CH_USE_MUTEXES -typedef struct Mutex Mutex; +typedef struct mutex mutex_t; #endif /** @@ -238,7 +238,7 @@ typedef struct thread { * @brief List of the mutexes owned by this thread. * @note The list is terminated by a @p NULL in this field. */ - Mutex *p_mtxlist; + mutex_t *p_mtxlist; /** * @brief Thread's own, non-inherited, priority. */ -- cgit v1.2.3 From 390ed322cb8f40cb9250021cde5f48acb928d291 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 07:24:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6001 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index c46103faf..ef5a0dbe9 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -302,8 +302,8 @@ typedef msg_t (*tfunc_t)(void *); * @note Can be invoked in any context. * * @param[in] tp pointer to the thread - * @retval TRUE thread terminated. - * @retval FALSE thread not terminated. + * @retval true thread terminated. + * @retval false thread not terminated. * * @special */ @@ -313,8 +313,8 @@ typedef msg_t (*tfunc_t)(void *); * @brief Verifies if the current thread has a termination request pending. * @note Can be invoked in any context. * - * @retval TRUE termination request pending. - * @retval FALSE termination request not pending. + * @retval true termination request pending. + * @retval false termination request not pending. * * @special */ -- cgit v1.2.3 From 49d71a01abeefa000a4cd7a556052d826b096d49 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 10:12:44 +0000 Subject: Renamed or added prefix to all hernel configuration options. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6010 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index ef5a0dbe9..f4785a268 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -94,7 +94,7 @@ /* Forward declaration required by the mutexes stack structure present in every thread.*/ -#if CH_USE_MUTEXES +#if CH_CFG_USE_MUTEXES typedef struct mutex mutex_t; #endif @@ -131,12 +131,12 @@ typedef struct thread { /* End of the fields shared with the threads_queue_t structure.*/ tprio_t p_prio; /**< @brief Thread priority. */ struct context p_ctx; /**< @brief Processor context. */ -#if CH_USE_REGISTRY || defined(__DOXYGEN__) +#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__) thread_t *p_newer; /**< @brief Newer registry element. */ thread_t *p_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the ReadyList structure. */ -#if CH_USE_REGISTRY || defined(__DOXYGEN__) +#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__) /** * @brief Thread name or @p NULL. */ @@ -156,7 +156,7 @@ typedef struct thread { * @brief Various thread flags. */ tmode_t p_flags; -#if CH_USE_DYNAMIC || defined(__DOXYGEN__) +#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) /** * @brief References to this thread. */ @@ -165,7 +165,7 @@ typedef struct thread { /** * @brief Number of ticks remaining to this thread. */ -#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) +#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__) tslices_t p_preempt; #endif #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) @@ -202,7 +202,7 @@ typedef struct thread { * states. */ void *wtobjp; -#if CH_USE_EVENTS || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) /** * @brief Enabled events mask. * @note This field is only valid while the thread is in the @@ -211,13 +211,13 @@ typedef struct thread { eventmask_t ewmask; #endif } p_u; -#if CH_USE_WAITEXIT || defined(__DOXYGEN__) +#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__) /** * @brief Termination waiting list. */ threads_list_t p_waiting; #endif -#if CH_USE_MESSAGES || defined(__DOXYGEN__) +#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) /** * @brief Messages queue. */ @@ -227,13 +227,13 @@ typedef struct thread { */ msg_t p_msg; #endif -#if CH_USE_EVENTS || defined(__DOXYGEN__) +#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) /** * @brief Pending events mask. */ eventmask_t p_epending; #endif -#if CH_USE_MUTEXES || defined(__DOXYGEN__) +#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) /** * @brief List of the mutexes owned by this thread. * @note The list is terminated by a @p NULL in this field. @@ -244,15 +244,15 @@ typedef struct thread { */ tprio_t p_realprio; #endif -#if (CH_USE_DYNAMIC && CH_USE_MEMPOOLS) || defined(__DOXYGEN__) +#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__) /** * @brief Memory Pool where the thread workspace is returned. */ void *p_mpool; #endif -#if defined(THREAD_EXT_FIELDS) +#if defined(CH_CFG_THREAD_EXTRA_FIELDS) /* Extra fields defined in chconf.h.*/ - THREAD_EXT_FIELDS + CH_CFG_THREAD_EXTRA_FIELDS #endif } thread_t; @@ -405,7 +405,7 @@ extern "C" { void chThdYield(void); void chThdExit(msg_t msg); void chThdExitS(msg_t msg); -#if CH_USE_WAITEXIT +#if CH_CFG_USE_WAITEXIT msg_t chThdWait(thread_t *tp); #endif #ifdef __cplusplus -- cgit v1.2.3 From 40f413d3c97a7694703938cd031ce15912b29ff7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 24 Jul 2013 14:54:26 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6025 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index f4785a268..a945f8d7d 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -37,31 +37,31 @@ * @name Thread states * @{ */ -#define THD_STATE_READY 0 /**< @brief Waiting on the ready list. */ -#define THD_STATE_CURRENT 1 /**< @brief Currently running. */ -#define THD_STATE_SUSPENDED 2 /**< @brief Created in suspended state. */ -#define THD_STATE_WTSEM 3 /**< @brief Waiting on a semaphore. */ -#define THD_STATE_WTMTX 4 /**< @brief Waiting on a mutex. */ -#define THD_STATE_WTCOND 5 /**< @brief Waiting on a condition +#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */ +#define CH_STATE_CURRENT 1 /**< @brief Currently running. */ +#define CH_STATE_SUSPENDED 2 /**< @brief Created in suspended state. */ +#define CH_STATE_WTSEM 3 /**< @brief Waiting on a semaphore. */ +#define CH_STATE_WTMTX 4 /**< @brief Waiting on a mutex. */ +#define CH_STATE_WTCOND 5 /**< @brief Waiting on a condition variable. */ -#define THD_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep() +#define CH_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep() or @p chThdSleepUntil(). */ -#define THD_STATE_WTEXIT 7 /**< @brief Waiting in @p chThdWait(). */ -#define THD_STATE_WTOREVT 8 /**< @brief Waiting for an event. */ -#define THD_STATE_WTANDEVT 9 /**< @brief Waiting for several events. */ -#define THD_STATE_SNDMSGQ 10 /**< @brief Sending a message, in queue.*/ -#define THD_STATE_SNDMSG 11 /**< @brief Sent a message, waiting +#define CH_STATE_WTEXIT 7 /**< @brief Waiting in @p chThdWait(). */ +#define CH_STATE_WTOREVT 8 /**< @brief Waiting for an event. */ +#define CH_STATE_WTANDEVT 9 /**< @brief Waiting for several events. */ +#define CH_STATE_SNDMSGQ 10 /**< @brief Sending a message, in queue.*/ +#define CH_STATE_SNDMSG 11 /**< @brief Sent a message, waiting answer. */ -#define THD_STATE_WTMSG 12 /**< @brief Waiting for a message. */ -#define THD_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */ -#define THD_STATE_FINAL 14 /**< @brief Thread terminated. */ +#define CH_STATE_WTMSG 12 /**< @brief Waiting for a message. */ +#define CH_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */ +#define CH_STATE_FINAL 14 /**< @brief Thread terminated. */ /** * @brief Thread states as array of strings. * @details Each element in an array initialized with this macro can be * indexed using the numeric thread state values. */ -#define THD_STATE_NAMES \ +#define CH_STATE_NAMES \ "READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \ "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \ "FINAL" @@ -71,13 +71,13 @@ * @name Thread flags and attributes * @{ */ -#define THD_MEM_MODE_MASK 3 /**< @brief Thread memory mode mask. */ -#define THD_MEM_MODE_STATIC 0 /**< @brief Static thread. */ -#define THD_MEM_MODE_HEAP 1 /**< @brief Thread allocated from a +#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */ +#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */ +#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a Memory Heap. */ -#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread allocated from a +#define CH_FLAG_MODE_MEMPOOL 2 /**< @brief Thread allocated from a Memory Pool. */ -#define THD_TERMINATE 4 /**< @brief Termination requested flag. */ +#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */ /** @} */ /*===========================================================================*/ @@ -206,7 +206,7 @@ typedef struct thread { /** * @brief Enabled events mask. * @note This field is only valid while the thread is in the - * @p THD_STATE_WTOREVT or @p THD_STATE_WTANDEVT states. + * @p CH_STATE_WTOREVT or @p CH_STATE_WTANDEVT states. */ eventmask_t ewmask; #endif @@ -298,7 +298,7 @@ typedef msg_t (*tfunc_t)(void *); #define chThdGetTicks(tp) ((tp)->p_time) /** - * @brief Verifies if the specified thread is in the @p THD_STATE_FINAL state. + * @brief Verifies if the specified thread is in the @p CH_STATE_FINAL state. * @note Can be invoked in any context. * * @param[in] tp pointer to the thread @@ -307,7 +307,7 @@ typedef msg_t (*tfunc_t)(void *); * * @special */ -#define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL) +#define chThdTerminated(tp) ((tp)->p_state == CH_STATE_FINAL) /** * @brief Verifies if the current thread has a termination request pending. @@ -318,7 +318,7 @@ typedef msg_t (*tfunc_t)(void *); * * @special */ -#define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) +#define chThdShouldTerminate() (currp->p_flags & CH_FLAG_TERMINATE) /** * @brief Resumes a thread created with @p chThdCreateI(). @@ -341,7 +341,7 @@ typedef msg_t (*tfunc_t)(void *); * * @sclass */ -#define chThdSleepS(time) chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time) +#define chThdSleepS(time) chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time) /** * @brief Delays the invoking thread for the specified number of seconds. -- cgit v1.2.3 From ceea042aaf3e373b598b3295c256feaef4e4236c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 31 Jul 2013 12:26:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6056 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index a945f8d7d..66d000d7e 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -250,6 +250,9 @@ typedef struct thread { */ void *p_mpool; #endif +#if CH_DBG_STATISTICS || defined(__DOXYGEN__) + time_measurement_t p_stats; +#endif #if defined(CH_CFG_THREAD_EXTRA_FIELDS) /* Extra fields defined in chconf.h.*/ CH_CFG_THREAD_EXTRA_FIELDS -- cgit v1.2.3 From c3dc5598c315f4650bfcd1e595104a2ace7aa87c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 08:07:43 +0000 Subject: Global variables consolidation. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6116 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 66d000d7e..22f499edf 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -98,24 +98,6 @@ typedef struct mutex mutex_t; #endif -/** - * @brief Generic threads single link list, it works like a stack. - */ -typedef struct { - - thread_t *p_next; /**< @brief Next in the list/queue. */ -} threads_list_t; - -/** - * @extends threads_list_t - * - * @brief Generic threads bidirectional linked list header and element. - */ -typedef struct { - thread_t *p_next; /**< @brief Next in the list/queue. */ - thread_t *p_prev; /**< @brief Previous in the queue. */ -} threads_queue_t; - /** * @extends threads_queue_t * -- cgit v1.2.3 From a1435e018bfc9919cb76b1356509ecc883767fb4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 14:51:16 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6123 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 406 ------------------------------------------ 1 file changed, 406 deletions(-) delete mode 100644 os/kernel/include/chthreads.h (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h deleted file mode 100644 index 22f499edf..000000000 --- a/os/kernel/include/chthreads.h +++ /dev/null @@ -1,406 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file chthreads.h - * @brief Threads module macros and structures. - * - * @addtogroup threads - * @{ - */ - -#ifndef _CHTHREADS_H_ -#define _CHTHREADS_H_ - -/*===========================================================================*/ -/* Module constants. */ -/*===========================================================================*/ - -/** - * @name Thread states - * @{ - */ -#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */ -#define CH_STATE_CURRENT 1 /**< @brief Currently running. */ -#define CH_STATE_SUSPENDED 2 /**< @brief Created in suspended state. */ -#define CH_STATE_WTSEM 3 /**< @brief Waiting on a semaphore. */ -#define CH_STATE_WTMTX 4 /**< @brief Waiting on a mutex. */ -#define CH_STATE_WTCOND 5 /**< @brief Waiting on a condition - variable. */ -#define CH_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep() - or @p chThdSleepUntil(). */ -#define CH_STATE_WTEXIT 7 /**< @brief Waiting in @p chThdWait(). */ -#define CH_STATE_WTOREVT 8 /**< @brief Waiting for an event. */ -#define CH_STATE_WTANDEVT 9 /**< @brief Waiting for several events. */ -#define CH_STATE_SNDMSGQ 10 /**< @brief Sending a message, in queue.*/ -#define CH_STATE_SNDMSG 11 /**< @brief Sent a message, waiting - answer. */ -#define CH_STATE_WTMSG 12 /**< @brief Waiting for a message. */ -#define CH_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */ -#define CH_STATE_FINAL 14 /**< @brief Thread terminated. */ - -/** - * @brief Thread states as array of strings. - * @details Each element in an array initialized with this macro can be - * indexed using the numeric thread state values. - */ -#define CH_STATE_NAMES \ - "READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \ - "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \ - "FINAL" -/** @} */ - -/** - * @name Thread flags and attributes - * @{ - */ -#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */ -#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */ -#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a - Memory Heap. */ -#define CH_FLAG_MODE_MEMPOOL 2 /**< @brief Thread allocated from a - Memory Pool. */ -#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */ -/** @} */ - -/*===========================================================================*/ -/* Module pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module data structures and types. */ -/*===========================================================================*/ - -/* Forward declaration required by the mutexes stack structure present - in every thread.*/ -#if CH_CFG_USE_MUTEXES -typedef struct mutex mutex_t; -#endif - -/** - * @extends threads_queue_t - * - * @brief Structure representing a thread. - * @note Not all the listed fields are always needed, by switching off some - * not needed ChibiOS/RT subsystems it is possible to save RAM space - * by shrinking the @p thread_t structure. - */ -typedef struct thread { - thread_t *p_next; /**< @brief Next in the list/queue. */ - /* End of the fields shared with the threads_list_t structure.*/ - thread_t *p_prev; /**< @brief Previous in the queue. */ - /* End of the fields shared with the threads_queue_t structure.*/ - tprio_t p_prio; /**< @brief Thread priority. */ - struct context p_ctx; /**< @brief Processor context. */ -#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__) - thread_t *p_newer; /**< @brief Newer registry element. */ - thread_t *p_older; /**< @brief Older registry element. */ -#endif - /* End of the fields shared with the ReadyList structure. */ -#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__) - /** - * @brief Thread name or @p NULL. - */ - const char *p_name; -#endif -#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__) - /** - * @brief Thread stack boundary. - */ - stkalign_t *p_stklimit; -#endif - /** - * @brief Current thread state. - */ - tstate_t p_state; - /** - * @brief Various thread flags. - */ - tmode_t p_flags; -#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__) - /** - * @brief References to this thread. - */ - trefs_t p_refs; -#endif - /** - * @brief Number of ticks remaining to this thread. - */ -#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__) - tslices_t p_preempt; -#endif -#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) - /** - * @brief Thread consumed time in ticks. - * @note This field can overflow. - */ - volatile systime_t p_time; -#endif - /** - * @brief State-specific fields. - * @note All the fields declared in this union are only valid in the - * specified state or condition and are thus volatile. - */ - union { - /** - * @brief Thread wakeup code. - * @note This field contains the low level message sent to the thread - * by the waking thread or interrupt handler. The value is valid - * after exiting the @p chSchWakeupS() function. - */ - msg_t rdymsg; - /** - * @brief Thread exit code. - * @note The thread termination code is stored in this field in order - * to be retrieved by the thread performing a @p chThdWait() on - * this thread. - */ - msg_t exitcode; - /** - * @brief Pointer to a generic "wait" object. - * @note This field is used to get a generic pointer to a synchronization - * object and is valid when the thread is in one of the wait - * states. - */ - void *wtobjp; -#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) - /** - * @brief Enabled events mask. - * @note This field is only valid while the thread is in the - * @p CH_STATE_WTOREVT or @p CH_STATE_WTANDEVT states. - */ - eventmask_t ewmask; -#endif - } p_u; -#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__) - /** - * @brief Termination waiting list. - */ - threads_list_t p_waiting; -#endif -#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__) - /** - * @brief Messages queue. - */ - threads_queue_t p_msgqueue; - /** - * @brief Thread message. - */ - msg_t p_msg; -#endif -#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__) - /** - * @brief Pending events mask. - */ - eventmask_t p_epending; -#endif -#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__) - /** - * @brief List of the mutexes owned by this thread. - * @note The list is terminated by a @p NULL in this field. - */ - mutex_t *p_mtxlist; - /** - * @brief Thread's own, non-inherited, priority. - */ - tprio_t p_realprio; -#endif -#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__) - /** - * @brief Memory Pool where the thread workspace is returned. - */ - void *p_mpool; -#endif -#if CH_DBG_STATISTICS || defined(__DOXYGEN__) - time_measurement_t p_stats; -#endif -#if defined(CH_CFG_THREAD_EXTRA_FIELDS) - /* Extra fields defined in chconf.h.*/ - CH_CFG_THREAD_EXTRA_FIELDS -#endif -} thread_t; - -/** - * @brief Thread function. - */ -typedef msg_t (*tfunc_t)(void *); - -/*===========================================================================*/ -/* Module macros. */ -/*===========================================================================*/ - -/** - * @name Macro Functions - * @{ - */ -/** - * @brief Returns a pointer to the current @p thread_t. - * @note Can be invoked in any context. - * - * @special - */ -#define chThdSelf() currp - -/** - * @brief Returns the current thread priority. - * @note Can be invoked in any context. - * - * @special - */ -#define chThdGetPriority() (currp->p_prio) - -/** - * @brief Returns the number of ticks consumed by the specified thread. - * @note This function is only available when the - * @p CH_DBG_THREADS_PROFILING configuration option is enabled. - * @note Can be invoked in any context. - * - * @param[in] tp pointer to the thread - * - * @special - */ -#define chThdGetTicks(tp) ((tp)->p_time) - -/** - * @brief Verifies if the specified thread is in the @p CH_STATE_FINAL state. - * @note Can be invoked in any context. - * - * @param[in] tp pointer to the thread - * @retval true thread terminated. - * @retval false thread not terminated. - * - * @special - */ -#define chThdTerminated(tp) ((tp)->p_state == CH_STATE_FINAL) - -/** - * @brief Verifies if the current thread has a termination request pending. - * @note Can be invoked in any context. - * - * @retval true termination request pending. - * @retval false termination request not pending. - * - * @special - */ -#define chThdShouldTerminate() (currp->p_flags & CH_FLAG_TERMINATE) - -/** - * @brief Resumes a thread created with @p chThdCreateI(). - * - * @param[in] tp pointer to the thread - * - * @iclass - */ -#define chThdResumeI(tp) chSchReadyI(tp) - -/** - * @brief Suspends the invoking thread for the specified time. - * - * @param[in] time the delay in system ticks, the special values are - * handled as follow: - * - @a TIME_INFINITE the thread enters an infinite sleep - * state. - * - @a TIME_IMMEDIATE this value is not allowed. - * . - * - * @sclass - */ -#define chThdSleepS(time) chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time) - -/** - * @brief Delays the invoking thread for the specified number of seconds. - * @note The specified time is rounded up to a value allowed by the real - * system tick clock. - * @note The maximum specifiable value is implementation dependent. - * - * @param[in] sec time in seconds, must be different from zero - * - * @api - */ -#define chThdSleepSeconds(sec) chThdSleep(S2ST(sec)) - -/** - * @brief Delays the invoking thread for the specified number of - * milliseconds. - * @note The specified time is rounded up to a value allowed by the real - * system tick clock. - * @note The maximum specifiable value is implementation dependent. - * - * @param[in] msec time in milliseconds, must be different from zero - * - * @api - */ -#define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec)) - -/** - * @brief Delays the invoking thread for the specified number of - * microseconds. - * @note The specified time is rounded up to a value allowed by the real - * system tick clock. - * @note The maximum specifiable value is implementation dependent. - * - * @param[in] usec time in microseconds, must be different from zero - * - * @api - */ -#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) -/** @} */ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - thread_t *_thread_init(thread_t *tp, tprio_t prio); -#if CH_DBG_FILL_THREADS - void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v); -#endif - thread_t *chThdCreateI(void *wsp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); - thread_t *chThdCreateStatic(void *wsp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); - tprio_t chThdSetPriority(tprio_t newprio); - thread_t *chThdResume(thread_t *tp); - void chThdTerminate(thread_t *tp); - void chThdSleep(systime_t time); - void chThdSleepUntil(systime_t time); - void chThdYield(void); - void chThdExit(msg_t msg); - void chThdExitS(msg_t msg); -#if CH_CFG_USE_WAITEXIT - msg_t chThdWait(thread_t *tp); -#endif -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Module inline functions. */ -/*===========================================================================*/ - -#endif /* _CHTHREADS_H_ */ - -/** @} */ -- cgit v1.2.3