From 411e6a635117a17986c22d98176e80c6921f70a6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:40:21 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1678 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 330 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 330 insertions(+) create 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 new file mode 100644 index 000000000..9f519fea0 --- /dev/null +++ b/os/kernel/include/chthreads.h @@ -0,0 +1,330 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 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 threads.h + * @brief Threads macros and structures. + * + * @addtogroup threads + * @{ + */ + +#ifndef _THREADS_H_ +#define _THREADS_H_ + +/* + * Module dependencies check. + */ +#if CH_USE_DYNAMIC && !CH_USE_WAITEXIT +#error "CH_USE_DYNAMIC requires CH_USE_WAITEXIT" +#endif +#if CH_USE_DYNAMIC && !CH_USE_HEAP && !CH_USE_MEMPOOLS +#error "CH_USE_DYNAMIC requires CH_USE_HEAP and/or CH_USE_MEMPOOLS" +#endif + +/** + * @extends ThreadsQueue + * + * @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. + */ +struct Thread { + Thread *p_next; /**< @brief Next in the list/queue. */ + /* End of the fields shared with the ThreadsList structure. */ + Thread *p_prev; /**< @brief Previous in the queue. */ + /* End of the fields shared with the ThreadsQueue structure. */ + tprio_t p_prio; /**< @brief Thread priority. */ + struct context p_ctx; /**< @brief Processor context. */ +#if CH_USE_REGISTRY + Thread *p_newer; /**< @brief Newer registry element. */ + Thread *p_older; /**< @brief Older registry element. */ +#endif + /* End of the fields shared with the ReadyList structure. */ + /** + * @brief Current thread state. + */ + tstate_t p_state; + /** + * @brief Various thread flags. + */ + tmode_t p_flags; +#if CH_USE_DYNAMIC + /** + * @brief References to this thread. + */ + trefs_t p_refs; +#endif +#if CH_USE_NESTED_LOCKS + /** + * @brief Number of nested locks. + */ + cnt_t p_locks; +#endif +#if CH_DBG_THREADS_PROFILING + /** + * @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_USE_EVENTS + /** + * @brief Enabled events mask. + * @note This field is only valied while the thread is in the + * @p THD_STATE_WTOREVT or @p THD_STATE_WTANDEVT states. + */ + eventmask_t ewmask; +#endif + } p_u; +#if CH_USE_WAITEXIT + /** + * @brief Termination waiting list. + */ + ThreadsList p_waiting; +#endif +#if CH_USE_MESSAGES + /** + * @brief Messages queue. + */ + ThreadsQueue p_msgqueue; + /** + * @brief Thread message. + */ + msg_t p_msg; +#endif +#if CH_USE_EVENTS + /** + * @brief Pending events mask. + */ + eventmask_t p_epending; +#endif +#if CH_USE_MUTEXES + /** + * @brief List of the mutexes owned by this thread. + * @note The list is terminated by a @p NULL in this field. + */ + Mutex *p_mtxlist; + /** + * @brief Thread's own, non-inherited, priority. + */ + tprio_t p_realprio; +#endif +#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS + /** + * @brief Memory Pool where the thread workspace is returned. + */ + void *p_mpool; +#endif + /* Extra fields defined in chconf.h.*/ + THREAD_EXT_FIELDS +}; + +/** @brief Thread state: Ready to run, waiting on the ready list.*/ +#define THD_STATE_READY 0 +/** @brief Thread state: Currently running.*/ +#define THD_STATE_CURRENT 1 +/** @brief Thread state: Thread created in suspended state.*/ +#define THD_STATE_SUSPENDED 2 +/** @brief Thread state: Waiting on a semaphore.*/ +#define THD_STATE_WTSEM 3 +/** @brief Thread state: Waiting on a mutex.*/ +#define THD_STATE_WTMTX 4 +/** @brief Thread state: Waiting in @p chCondWait().*/ +#define THD_STATE_WTCOND 5 +/** @brief Thread state: Waiting in @p chThdSleep() or @p chThdSleepUntil().*/ +#define THD_STATE_SLEEPING 6 +/** @brief Thread state: Waiting in @p chThdWait().*/ +#define THD_STATE_WTEXIT 7 +/** @brief Thread state: Waiting in @p chEvtWaitXXX().*/ +#define THD_STATE_WTOREVT 8 +/** @brief Thread state: Waiting in @p chEvtWaitAllTimeout().*/ +#define THD_STATE_WTANDEVT 9 +/** @brief Thread state: Waiting in @p chMsgSend().*/ +#define THD_STATE_SNDMSG 10 +/** @brief Thread state: Waiting in @p chMsgWait().*/ +#define THD_STATE_WTMSG 11 +/** @brief Thread state: After termination.*/ +#define THD_STATE_FINAL 12 + +/* + * Various flags into the thread p_flags field. + */ +#define THD_MEM_MODE_MASK 3 /**< @brief Thread memory mode mask. */ +#define THD_MEM_MODE_STATIC 0 /**< @brief Thread memory mode: static. */ +#define THD_MEM_MODE_HEAP 1 /**< @brief Thread memory mode: heap. */ +#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread memory mode: pool. */ +#define THD_TERMINATE 4 /**< @brief Termination requested. */ + +/** @brief Thread function.*/ +typedef msg_t (*tfunc_t)(void *); + +/* + * Threads APIs. + */ +#ifdef __cplusplus +extern "C" { +#endif + Thread *init_thread(Thread *tp, tprio_t prio); + Thread *chThdInit(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); +#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP + Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, + tprio_t prio, tfunc_t pf, void *arg); +#endif +#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS + Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, + tfunc_t pf, void *arg); +#endif + tprio_t chThdSetPriority(tprio_t newprio); + Thread *chThdResume(Thread *tp); + void chThdTerminate(Thread *tp); + void chThdSleep(systime_t time); + void chThdSleepUntil(systime_t time); + void chThdYield(void); + void chThdExit(msg_t msg); +#if CH_USE_DYNAMIC + Thread *chThdAddRef(Thread *tp); + void chThdRelease(Thread *tp); +#endif +#if CH_USE_WAITEXIT + msg_t chThdWait(Thread *tp); +#endif +#ifdef __cplusplus +} +#endif + +/** + * @brief Returns a pointer to the current @p Thread. + */ +#define chThdSelf() currp + +/** + * @brief Returns the current thread priority. + */ +#define chThdGetPriority() (currp->p_prio) + +/** + * @brief Returns the pointer to the @p Thread local storage area, if any. + */ +#define chThdLS() (void *)(currp + 1) + +/** + * @brief Verifies if the specified thread is in the @p THD_STATE_FINAL state. + * + * @param[in] tp the pointer to the thread + * @retval TRUE thread terminated. + * @retval FALSE thread not terminated. + */ +#define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL) + +/** + * @brief Verifies if the current thread has a termination request pending. + * + * @retval TRUE termination request pended. + * @retval FALSE termination request not pended. + */ +#define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) + +/** + * @brief Resumes a thread created with @p chThdInit(). + * + * @param[in] tp the pointer to the thread + */ +#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 accepted but + * interpreted as a normal time specification not as + * an immediate timeout specification. + * . + */ +#define chThdSleepS(time) chSchGoSleepTimeoutS(THD_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 clock. + * @note The maximum specified value is implementation dependent. + * + * @param[in] sec the time in seconds + */ +#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 clock. + * @note The maximum specified value is implementation dependent. + * + * @param[in] msec the time in milliseconds + */ +#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 clock. + * @note The maximum specified value is implementation dependent. + * + * @param[in] usec the time in microseconds + */ +#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) + +#endif /* _THREADS_H_ */ + +/** @} */ -- cgit v1.2.3 From 5fb790997fec3b9d965c57e57b4edd156c8b8954 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 27 Feb 2010 08:54:22 +0000 Subject: Renamed the kernel header to match their source files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1679 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 9f519fea0..9eeff8666 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -18,15 +18,15 @@ */ /** - * @file threads.h + * @file chthreads.h * @brief Threads macros and structures. * * @addtogroup threads * @{ */ -#ifndef _THREADS_H_ -#define _THREADS_H_ +#ifndef _CHTHREADS_H_ +#define _CHTHREADS_H_ /* * Module dependencies check. @@ -325,6 +325,6 @@ extern "C" { */ #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) -#endif /* _THREADS_H_ */ +#endif /* _CHTHREADS_H_ */ /** @} */ -- cgit v1.2.3 From fef1911a8f6329ad97e4112965e004d21bffef73 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 20 Aug 2010 07:15:55 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2134 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 9eeff8666..1e659b768 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -250,6 +250,15 @@ extern "C" { */ #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. + * + * @param[in] tp the pointer to the thread + */ +#define chThdGetTicks(tp) ((tp)->p_time) + /** * @brief Returns the pointer to the @p Thread local storage area, if any. */ -- cgit v1.2.3 From 138c0f900d823b2c953038048bc40b14610f958a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Aug 2010 08:38:14 +0000 Subject: Added new kernel hooks (on halt and on systick). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2136 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 1e659b768..9748166b9 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -160,8 +160,10 @@ struct Thread { */ void *p_mpool; #endif +#if defined(THREAD_EXT_FIELDS_HOOK) /* Extra fields defined in chconf.h.*/ - THREAD_EXT_FIELDS + THREAD_EXT_FIELDS_HOOK +#endif }; /** @brief Thread state: Ready to run, waiting on the ready list.*/ -- cgit v1.2.3 From 07351222e6d0b6b3dcd4f50ecb18bc09e7402d1c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Sep 2010 10:22:06 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2184 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 9748166b9..97e03840b 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -244,11 +244,15 @@ extern "C" { /** * @brief Returns a pointer to the current @p Thread. + * + * @api */ #define chThdSelf() currp /** * @brief Returns the current thread priority. + * + * @api */ #define chThdGetPriority() (currp->p_prio) @@ -258,11 +262,15 @@ extern "C" { * @p CH_DBG_THREADS_PROFILING configuration option is enabled. * * @param[in] tp the pointer to the thread + * + * @api */ #define chThdGetTicks(tp) ((tp)->p_time) /** * @brief Returns the pointer to the @p Thread local storage area, if any. + * + * @api */ #define chThdLS() (void *)(currp + 1) @@ -272,6 +280,8 @@ extern "C" { * @param[in] tp the pointer to the thread * @retval TRUE thread terminated. * @retval FALSE thread not terminated. + * + * @api */ #define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL) @@ -280,6 +290,8 @@ extern "C" { * * @retval TRUE termination request pended. * @retval FALSE termination request not pended. + * + * @api */ #define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) @@ -287,6 +299,8 @@ extern "C" { * @brief Resumes a thread created with @p chThdInit(). * * @param[in] tp the pointer to the thread + * + * @iclass */ #define chThdResumeI(tp) chSchReadyI(tp) @@ -301,6 +315,8 @@ extern "C" { * interpreted as a normal time specification not as * an immediate timeout specification. * . + * + * @sclass */ #define chThdSleepS(time) chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time) @@ -311,6 +327,8 @@ extern "C" { * @note The maximum specified value is implementation dependent. * * @param[in] sec the time in seconds + * + * @api */ #define chThdSleepSeconds(sec) chThdSleep(S2ST(sec)) @@ -322,6 +340,8 @@ extern "C" { * @note The maximum specified value is implementation dependent. * * @param[in] msec the time in milliseconds + * + * @api */ #define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec)) @@ -333,6 +353,8 @@ extern "C" { * @note The maximum specified value is implementation dependent. * * @param[in] usec the time in microseconds + * + * @api */ #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) -- cgit v1.2.3 From d97be800597f99b9a02c265a01c7902a07c45570 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 25 Sep 2010 15:46:22 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2199 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 97e03840b..f07afa9a0 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -212,8 +212,8 @@ typedef msg_t (*tfunc_t)(void *); extern "C" { #endif Thread *init_thread(Thread *tp, tprio_t prio); - Thread *chThdInit(void *wsp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); + 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); #if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP -- cgit v1.2.3 From efdf9a658b9bffb0a42dc792f2852f88873f4240 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 27 Sep 2010 18:43:55 +0000 Subject: Reverted name change for macro THREAD_EXT_FIELDS. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2210 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index f07afa9a0..12d853eb1 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -162,7 +162,7 @@ struct Thread { #endif #if defined(THREAD_EXT_FIELDS_HOOK) /* Extra fields defined in chconf.h.*/ - THREAD_EXT_FIELDS_HOOK + THREAD_EXT_FIELDS #endif }; -- cgit v1.2.3 From 44b87c4e1d8048217cfdc6428db70aa01c95e2d4 Mon Sep 17 00:00:00 2001 From: liamstask Date: Mon, 27 Sep 2010 22:10:19 +0000 Subject: missed one spot :) git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2212 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 12d853eb1..e862c8c1a 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -160,7 +160,7 @@ struct Thread { */ void *p_mpool; #endif -#if defined(THREAD_EXT_FIELDS_HOOK) +#if defined(THREAD_EXT_FIELDS) /* Extra fields defined in chconf.h.*/ THREAD_EXT_FIELDS #endif -- cgit v1.2.3 From e889040710fe8e5ee4454b01803d0c8522f489f0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 12 Nov 2010 18:47:41 +0000 Subject: Separated the dynamic threads code from the static threads code. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2349 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 27 ++++----------------------- 1 file changed, 4 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 e862c8c1a..677f0be58 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -28,16 +28,6 @@ #ifndef _CHTHREADS_H_ #define _CHTHREADS_H_ -/* - * Module dependencies check. - */ -#if CH_USE_DYNAMIC && !CH_USE_WAITEXIT -#error "CH_USE_DYNAMIC requires CH_USE_WAITEXIT" -#endif -#if CH_USE_DYNAMIC && !CH_USE_HEAP && !CH_USE_MEMPOOLS -#error "CH_USE_DYNAMIC requires CH_USE_HEAP and/or CH_USE_MEMPOOLS" -#endif - /** * @extends ThreadsQueue * @@ -211,19 +201,14 @@ typedef msg_t (*tfunc_t)(void *); #ifdef __cplusplus extern "C" { #endif - Thread *init_thread(Thread *tp, tprio_t prio); + Thread *_thread_init(Thread *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); -#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP - Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, - tprio_t prio, tfunc_t pf, void *arg); -#endif -#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS - Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, - tfunc_t pf, void *arg); -#endif tprio_t chThdSetPriority(tprio_t newprio); Thread *chThdResume(Thread *tp); void chThdTerminate(Thread *tp); @@ -231,10 +216,6 @@ extern "C" { void chThdSleepUntil(systime_t time); void chThdYield(void); void chThdExit(msg_t msg); -#if CH_USE_DYNAMIC - Thread *chThdAddRef(Thread *tp); - void chThdRelease(Thread *tp); -#endif #if CH_USE_WAITEXIT msg_t chThdWait(Thread *tp); #endif -- cgit v1.2.3 From b3b1028036a2f18327fb97f2126192a2ace62bb2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 21 Feb 2011 19:06:46 +0000 Subject: TIME_IMMEDIATE and TIME_INFINITE values swapped. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2757 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 677f0be58..c22255ad0 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -292,9 +292,7 @@ extern "C" { * handled as follow: * - @a TIME_INFINITE the thread enters an infinite sleep * state. - * - @a TIME_IMMEDIATE this value is accepted but - * interpreted as a normal time specification not as - * an immediate timeout specification. + * - @a TIME_IMMEDIATE this value is not allowed. * . * * @sclass -- cgit v1.2.3 From 6f6e1a6401eda000dce198150937c7919b4c9855 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 23 Feb 2011 18:59:39 +0000 Subject: Improved messages subsystem. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2759 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index c22255ad0..f6ed23d1d 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -176,12 +176,14 @@ struct Thread { #define THD_STATE_WTOREVT 8 /** @brief Thread state: Waiting in @p chEvtWaitAllTimeout().*/ #define THD_STATE_WTANDEVT 9 -/** @brief Thread state: Waiting in @p chMsgSend().*/ -#define THD_STATE_SNDMSG 10 +/** @brief Thread state: Waiting in @p chMsgSend() (queued).*/ +#define THD_STATE_SNDMSGQ 10 +/** @brief Thread state: Waiting in @p chMsgSend() (not queued).*/ +#define THD_STATE_SNDMSG 11 /** @brief Thread state: Waiting in @p chMsgWait().*/ -#define THD_STATE_WTMSG 11 +#define THD_STATE_WTMSG 12 /** @brief Thread state: After termination.*/ -#define THD_STATE_FINAL 12 +#define THD_STATE_FINAL 13 /* * Various flags into the thread p_flags field. @@ -242,7 +244,7 @@ extern "C" { * @note This function is only available when the * @p CH_DBG_THREADS_PROFILING configuration option is enabled. * - * @param[in] tp the pointer to the thread + * @param[in] tp pointer to the thread * * @api */ @@ -258,7 +260,7 @@ extern "C" { /** * @brief Verifies if the specified thread is in the @p THD_STATE_FINAL state. * - * @param[in] tp the pointer to the thread + * @param[in] tp pointer to the thread * @retval TRUE thread terminated. * @retval FALSE thread not terminated. * @@ -279,7 +281,7 @@ extern "C" { /** * @brief Resumes a thread created with @p chThdInit(). * - * @param[in] tp the pointer to the thread + * @param[in] tp pointer to the thread * * @iclass */ @@ -305,7 +307,7 @@ extern "C" { * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] sec the time in seconds + * @param[in] sec time in seconds * * @api */ @@ -318,7 +320,7 @@ extern "C" { * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] msec the time in milliseconds + * @param[in] msec time in milliseconds * * @api */ @@ -331,7 +333,7 @@ extern "C" { * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] usec the time in microseconds + * @param[in] usec time in microseconds * * @api */ -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index f6ed23d1d..df6fc329f 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 807c5f1882224c2afd471a44889b83c2adf80589 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 18 May 2011 17:54:55 +0000 Subject: Fixed bug 3303908. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2972 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index df6fc329f..215bb9920 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -183,8 +183,10 @@ struct Thread { #define THD_STATE_SNDMSG 11 /** @brief Thread state: Waiting in @p chMsgWait().*/ #define THD_STATE_WTMSG 12 +/** @brief Thread state: Waiting on an I/O queue.*/ +#define THD_STATE_WTQUEUE 13 /** @brief Thread state: After termination.*/ -#define THD_STATE_FINAL 13 +#define THD_STATE_FINAL 14 /* * Various flags into the thread p_flags field. -- cgit v1.2.3 From d79eea31a268ce14b60b30d929b2d2c905048d98 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 8 Jul 2011 19:29:00 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3135 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 66 ++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 215bb9920..e0f1b3e95 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -49,6 +49,12 @@ struct Thread { Thread *p_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the ReadyList structure. */ +#if CH_USE_REGISTRY + /** + * @brief Thread name or @p NULL. + */ + const char *p_name; +#endif /** * @brief Current thread state. */ @@ -197,36 +203,10 @@ struct Thread { #define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread memory mode: pool. */ #define THD_TERMINATE 4 /**< @brief Termination requested. */ -/** @brief Thread function.*/ -typedef msg_t (*tfunc_t)(void *); - -/* - * Threads APIs. +/** + * @brief Thread function. */ -#ifdef __cplusplus -extern "C" { -#endif - Thread *_thread_init(Thread *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); - tprio_t chThdSetPriority(tprio_t newprio); - Thread *chThdResume(Thread *tp); - void chThdTerminate(Thread *tp); - void chThdSleep(systime_t time); - void chThdSleepUntil(systime_t time); - void chThdYield(void); - void chThdExit(msg_t msg); -#if CH_USE_WAITEXIT - msg_t chThdWait(Thread *tp); -#endif -#ifdef __cplusplus -} -#endif +typedef msg_t (*tfunc_t)(void *); /** * @brief Returns a pointer to the current @p Thread. @@ -342,6 +322,34 @@ extern "C" { */ #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) +/* + * Threads APIs. + */ +#ifdef __cplusplus +extern "C" { +#endif + Thread *_thread_init(Thread *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); + tprio_t chThdSetPriority(tprio_t newprio); + Thread *chThdResume(Thread *tp); + void chThdTerminate(Thread *tp); + void chThdSleep(systime_t time); + void chThdSleepUntil(systime_t time); + void chThdYield(void); + void chThdExit(msg_t msg); +#if CH_USE_WAITEXIT + msg_t chThdWait(Thread *tp); +#endif +#ifdef __cplusplus +} +#endif + #endif /* _CHTHREADS_H_ */ /** @} */ -- cgit v1.2.3 From 075ff711f1c9cf031fa4708c6b704f120d9a509d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Aug 2011 09:00:12 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3192 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index e0f1b3e95..b02960bd4 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -44,16 +44,22 @@ struct Thread { /* End of the fields shared with the ThreadsQueue structure. */ tprio_t p_prio; /**< @brief Thread priority. */ struct context p_ctx; /**< @brief Processor context. */ -#if CH_USE_REGISTRY +#if CH_USE_REGISTRY || defined(__DOXYGEN__) Thread *p_newer; /**< @brief Newer registry element. */ Thread *p_older; /**< @brief Older registry element. */ #endif /* End of the fields shared with the ReadyList structure. */ -#if CH_USE_REGISTRY +#if CH_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. @@ -63,19 +69,19 @@ struct Thread { * @brief Various thread flags. */ tmode_t p_flags; -#if CH_USE_DYNAMIC +#if CH_USE_DYNAMIC || defined(__DOXYGEN__) /** * @brief References to this thread. */ trefs_t p_refs; #endif -#if CH_USE_NESTED_LOCKS +#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__) /** * @brief Number of nested locks. */ cnt_t p_locks; #endif -#if CH_DBG_THREADS_PROFILING +#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) /** * @brief Thread consumed time in ticks. * @note This field can overflow. @@ -109,22 +115,22 @@ struct Thread { * states. */ void *wtobjp; -#if CH_USE_EVENTS +#if CH_USE_EVENTS || defined(__DOXYGEN__) /** * @brief Enabled events mask. - * @note This field is only valied while the thread is in the + * @note This field is only valid while the thread is in the * @p THD_STATE_WTOREVT or @p THD_STATE_WTANDEVT states. */ eventmask_t ewmask; #endif } p_u; -#if CH_USE_WAITEXIT +#if CH_USE_WAITEXIT || defined(__DOXYGEN__) /** * @brief Termination waiting list. */ ThreadsList p_waiting; #endif -#if CH_USE_MESSAGES +#if CH_USE_MESSAGES || defined(__DOXYGEN__) /** * @brief Messages queue. */ @@ -134,13 +140,13 @@ struct Thread { */ msg_t p_msg; #endif -#if CH_USE_EVENTS +#if CH_USE_EVENTS || defined(__DOXYGEN__) /** * @brief Pending events mask. */ eventmask_t p_epending; #endif -#if CH_USE_MUTEXES +#if CH_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. @@ -151,7 +157,7 @@ struct Thread { */ tprio_t p_realprio; #endif -#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS +#if (CH_USE_DYNAMIC && CH_USE_MEMPOOLS) || defined(__DOXYGEN__) /** * @brief Memory Pool where the thread workspace is returned. */ -- cgit v1.2.3 From b9933c2089f5f0cd93738ae9081c45fcf3df54b7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 11 Aug 2011 17:51:37 +0000 Subject: Implemented system state checker debug option, remove the option CH_USE_NESTED_LOCKS. Documentation improvements and fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3221 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index b02960bd4..a0a668df4 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -75,12 +75,6 @@ struct Thread { */ trefs_t p_refs; #endif -#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__) - /** - * @brief Number of nested locks. - */ - cnt_t p_locks; -#endif #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) /** * @brief Thread consumed time in ticks. -- cgit v1.2.3 From 2d55ac3059fcca69cc9736db310b4521064c2b23 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 22 Aug 2011 17:18:52 +0000 Subject: Documentation improvements and code comments reformatting. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3248 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 76 ++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 40 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index a0a668df4..eb3d8bb14 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -29,6 +29,42 @@ #ifndef _CHTHREADS_H_ #define _CHTHREADS_H_ +/** + * @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 + variable. */ +#define THD_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 + 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. */ +/** @} */ + +/** + * @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 Heap. */ +#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread allocated from Memory + Pool. */ +#define THD_TERMINATE 4 /**< @brief Termination requested flag. */ +/** @} */ + /** * @extends ThreadsQueue * @@ -163,46 +199,6 @@ struct Thread { #endif }; -/** @brief Thread state: Ready to run, waiting on the ready list.*/ -#define THD_STATE_READY 0 -/** @brief Thread state: Currently running.*/ -#define THD_STATE_CURRENT 1 -/** @brief Thread state: Thread created in suspended state.*/ -#define THD_STATE_SUSPENDED 2 -/** @brief Thread state: Waiting on a semaphore.*/ -#define THD_STATE_WTSEM 3 -/** @brief Thread state: Waiting on a mutex.*/ -#define THD_STATE_WTMTX 4 -/** @brief Thread state: Waiting in @p chCondWait().*/ -#define THD_STATE_WTCOND 5 -/** @brief Thread state: Waiting in @p chThdSleep() or @p chThdSleepUntil().*/ -#define THD_STATE_SLEEPING 6 -/** @brief Thread state: Waiting in @p chThdWait().*/ -#define THD_STATE_WTEXIT 7 -/** @brief Thread state: Waiting in @p chEvtWaitXXX().*/ -#define THD_STATE_WTOREVT 8 -/** @brief Thread state: Waiting in @p chEvtWaitAllTimeout().*/ -#define THD_STATE_WTANDEVT 9 -/** @brief Thread state: Waiting in @p chMsgSend() (queued).*/ -#define THD_STATE_SNDMSGQ 10 -/** @brief Thread state: Waiting in @p chMsgSend() (not queued).*/ -#define THD_STATE_SNDMSG 11 -/** @brief Thread state: Waiting in @p chMsgWait().*/ -#define THD_STATE_WTMSG 12 -/** @brief Thread state: Waiting on an I/O queue.*/ -#define THD_STATE_WTQUEUE 13 -/** @brief Thread state: After termination.*/ -#define THD_STATE_FINAL 14 - -/* - * Various flags into the thread p_flags field. - */ -#define THD_MEM_MODE_MASK 3 /**< @brief Thread memory mode mask. */ -#define THD_MEM_MODE_STATIC 0 /**< @brief Thread memory mode: static. */ -#define THD_MEM_MODE_HEAP 1 /**< @brief Thread memory mode: heap. */ -#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread memory mode: pool. */ -#define THD_TERMINATE 4 /**< @brief Termination requested. */ - /** * @brief Thread function. */ -- cgit v1.2.3 From c9be79def630f153b0b2d28e905939c15743f989 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 10:09:08 +0000 Subject: Kernel documentation fixes and improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 14 ++++++++++---- 1 file changed, 10 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 eb3d8bb14..bd3f21296 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -59,9 +59,10 @@ */ #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 Heap. */ -#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread allocated from Memory - Pool. */ +#define THD_MEM_MODE_HEAP 1 /**< @brief Thread allocated from a + Memory Heap. */ +#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread allocated from a + Memory Pool. */ #define THD_TERMINATE 4 /**< @brief Termination requested flag. */ /** @} */ @@ -204,6 +205,10 @@ struct Thread { */ typedef msg_t (*tfunc_t)(void *); +/** + * @name Macro Functions + * @{ + */ /** * @brief Returns a pointer to the current @p Thread. * @@ -258,7 +263,7 @@ typedef msg_t (*tfunc_t)(void *); #define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) /** - * @brief Resumes a thread created with @p chThdInit(). + * @brief Resumes a thread created with @p chThdCreateI(). * * @param[in] tp pointer to the thread * @@ -317,6 +322,7 @@ typedef msg_t (*tfunc_t)(void *); * @api */ #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) +/** @} */ /* * Threads APIs. -- cgit v1.2.3 From 5463b41d3a7a81da20c88631535c088decd61999 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 20 Sep 2011 17:08:22 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3362 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 1 + 1 file changed, 1 insertion(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index bd3f21296..d99b2ee3b 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -345,6 +345,7 @@ extern "C" { 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); #endif -- cgit v1.2.3 From 42e2ea515d9c24187d57cffcd2889c4641384165 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 20 Sep 2011 20:31:20 +0000 Subject: Improved documentation of sleep functions. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3375 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index d99b2ee3b..582b4e1e1 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -291,7 +291,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] sec time in seconds + * @param[in] sec time in seconds, must be different from zero * * @api */ @@ -304,7 +304,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] msec time in milliseconds + * @param[in] msec time in milliseconds, must be different from zero * * @api */ @@ -317,7 +317,7 @@ typedef msg_t (*tfunc_t)(void *); * system clock. * @note The maximum specified value is implementation dependent. * - * @param[in] usec time in microseconds + * @param[in] usec time in microseconds, must be different from zero * * @api */ -- cgit v1.2.3 From 309b1e411426e8d36d9a552ef2870da3db912a80 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 23 Oct 2011 11:39:45 +0000 Subject: Improvements to the USB driver, first phase. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3449 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 582b4e1e1..5848d5643 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -51,6 +51,16 @@ #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. */ + +/** + * @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 \ + "READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \ + "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \ + "FINAL" /** @} */ /** -- cgit v1.2.3 From 8824a54e5efd1cc239bd7af2f8cbe12481d7a247 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 10 Jan 2012 18:14:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3783 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 5848d5643..bcb15d456 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -125,7 +125,7 @@ struct Thread { #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) /** * @brief Thread consumed time in ticks. - * @note This field can overflow. + * @note This field can overflow. */ volatile systime_t p_time; #endif -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index bcb15d456..66b593818 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 4401d0e7b2874074e37c90e0178667a854d0da1f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 6 Feb 2012 19:45:47 +0000 Subject: Round robin scheduling improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3930 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 66b593818..421a3e23f 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -121,6 +121,12 @@ struct Thread { * @brief References to this thread. */ trefs_t p_refs; +#endif + /** + * @brief Number of ticks remaining to this thread. + */ +#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__) + tslices_t p_preempt; #endif #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) /** -- cgit v1.2.3 From eccd5b4b5ec4eed2cfe50493bcdd138876c6e0c5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 15 Aug 2012 14:10:01 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4573 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 421a3e23f..91b8b2fdf 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -270,11 +270,12 @@ typedef msg_t (*tfunc_t)(void *); /** * @brief Verifies if the current thread has a termination request pending. + * @note This function can be called in any context. * - * @retval TRUE termination request pended. - * @retval FALSE termination request not pended. + * @retval TRUE termination request pending. + * @retval FALSE termination request not pending. * - * @api + * @special */ #define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) -- cgit v1.2.3 From 840eb5253736c02b9b894b519be90586f915f8ce Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 13 Dec 2012 08:04:25 +0000 Subject: Various documentation fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4911 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 91b8b2fdf..eb55dae94 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -227,15 +227,17 @@ typedef msg_t (*tfunc_t)(void *); */ /** * @brief Returns a pointer to the current @p Thread. + * @note Can be invoked in any context. * - * @api + * @special */ #define chThdSelf() currp /** * @brief Returns the current thread priority. + * @note Can be invoked in any context. * - * @api + * @special */ #define chThdGetPriority() (currp->p_prio) @@ -243,34 +245,37 @@ typedef msg_t (*tfunc_t)(void *); * @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 * - * @api + * @special */ #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. * - * @api + * @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. * * @param[in] tp pointer to the thread * @retval TRUE thread terminated. * @retval FALSE thread not terminated. * - * @api + * @special */ #define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL) /** * @brief Verifies if the current thread has a termination request pending. - * @note This function can be called in any context. + * @note Can be invoked in any context. * * @retval TRUE termination request pending. * @retval FALSE termination request not pending. -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index eb55dae94..ca8a843da 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From df7afc9b41c598a9ff924dd971989e72708094ad Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 11 Apr 2013 08:25:03 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5586 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chthreads.h') diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index ca8a843da..77f72caca 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -310,8 +310,8 @@ typedef msg_t (*tfunc_t)(void *); /** * @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 clock. - * @note The maximum specified value is implementation dependent. + * system tick clock. + * @note The maximum specifiable value is implementation dependent. * * @param[in] sec time in seconds, must be different from zero * @@ -323,8 +323,8 @@ typedef msg_t (*tfunc_t)(void *); * @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 clock. - * @note The maximum specified value is implementation dependent. + * system tick clock. + * @note The maximum specifiable value is implementation dependent. * * @param[in] msec time in milliseconds, must be different from zero * @@ -336,8 +336,8 @@ typedef msg_t (*tfunc_t)(void *); * @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 clock. - * @note The maximum specified value is implementation dependent. + * system tick clock. + * @note The maximum specifiable value is implementation dependent. * * @param[in] usec time in microseconds, must be different from zero * -- cgit v1.2.3