From 5a3a608ad919591b88af842b0ce15f4e22790710 Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 20 Sep 2011 16:00:30 +0000 Subject: Fixed bug 3411207 git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3360 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chthreads.c | 1 + 1 file changed, 1 insertion(+) (limited to 'os/kernel') diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index 46039561b..73236c850 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -353,6 +353,7 @@ void chThdExit(msg_t msg) { REG_REMOVE(tp); #endif chSchGoSleepS(THD_STATE_FINAL); + chSysUnlock(); } #if CH_USE_WAITEXIT || defined(__DOXYGEN__) -- 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 + os/kernel/src/chthreads.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'os/kernel') 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 diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index 73236c850..b2231ef17 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -335,6 +335,27 @@ void chThdYield(void) { * @api */ void chThdExit(msg_t msg) { + + chSysLock(); + chThdExitS(msg); + /* The thread never returns here.*/ +} + +/** + * @brief Terminates the current thread. + * @details The thread goes in the @p THD_STATE_FINAL state holding the + * specified exit status code, other threads can retrieve the + * exit status code by invoking the function @p chThdWait(). + * @post Eventual code after this function will never be executed, + * this function never returns. The compiler has no way to + * know this so do not assume that the compiler would remove + * the dead code. + * + * @param[in] msg thread exit code + * + * @sclass + */ +void chThdExitS(msg_t msg) { Thread *tp = currp; chSysLock(); @@ -353,7 +374,8 @@ void chThdExit(msg_t msg) { REG_REMOVE(tp); #endif chSchGoSleepS(THD_STATE_FINAL); - chSysUnlock(); + /* The thread never returns here.*/ + chDbgAssert(FALSE, "chThdExitS(), #1", "zombies apocalypse"); } #if CH_USE_WAITEXIT || defined(__DOXYGEN__) -- cgit v1.2.3 From c69417e365e3f495588ad7b88e9ee8fc16b3fcdb Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 20 Sep 2011 17:10:56 +0000 Subject: Fixed bug 3411207. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3363 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chthreads.c | 1 - 1 file changed, 1 deletion(-) (limited to 'os/kernel') diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index b2231ef17..bf43c6c43 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -358,7 +358,6 @@ void chThdExit(msg_t msg) { void chThdExitS(msg_t msg) { Thread *tp = currp; - chSysLock(); tp->p_u.exitcode = msg; #if defined(THREAD_EXT_EXIT_HOOK) THREAD_EXT_EXIT_HOOK(tp); -- 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') 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 c39d08fc2ae9c43f73114e24292520306bddde19 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 23 Sep 2011 15:48:55 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3384 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chsys.c | 5 +---- os/kernel/src/chthreads.c | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'os/kernel') diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index 866ee81a8..78caa88f6 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -36,10 +36,7 @@ #include "ch.h" #if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__) -/** - * @brief Idle thread working area. - * @see PORT_IDLE_THREAD_STACK_SIZE - */ +/* Idle thread working area.*/ WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE); /** diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index bf43c6c43..7b48f2b00 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -32,8 +32,6 @@ * area. In this scenario static variables are shared among all * threads while automatic variables are local to the thread.
* Operations defined for threads: - * - Init, a thread is prepared and put in the suspended - * state. * - Create, a thread is started on the specified thread * function. This operation is available in multiple variants, * both static and dynamic. -- cgit v1.2.3 From b8aac8295e455e123ce1337b760e349d47cb2ede Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 8 Oct 2011 14:23:08 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3438 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/ch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel') diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h index 35b01af2c..e751e0fc5 100644 --- a/os/kernel/include/ch.h +++ b/os/kernel/include/ch.h @@ -40,7 +40,7 @@ /** * @brief Kernel version string. */ -#define CH_KERNEL_VERSION "2.3.3unstable" +#define CH_KERNEL_VERSION "2.3.4unstable" /** * @name Kernel version @@ -59,7 +59,7 @@ /** * @brief Kernel version patch number. */ -#define CH_KERNEL_PATCH 3 +#define CH_KERNEL_PATCH 4 /** @} */ /* -- 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 ++++++++++ os/kernel/src/chqueues.c | 23 ++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'os/kernel') 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" /** @} */ /** diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c index cf3d21732..b32ccf803 100644 --- a/os/kernel/src/chqueues.c +++ b/os/kernel/src/chqueues.c @@ -152,9 +152,8 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) { * @details This function reads a byte value from an input queue. If the queue * is empty then the calling thread is suspended until a byte arrives * in the queue or a timeout occurs. - * @note The callback is invoked if the queue is empty before entering the - * @p THD_STATE_WTQUEUE state in order to solicit the low level to - * start queue filling. + * @note The callback is invoked before reading the character from the + * buffer or before entering the state @p THD_STATE_WTQUEUE. * * @param[in] iqp pointer to an @p InputQueue structure * @param[in] time the number of ticks before the operation timeouts, @@ -172,12 +171,11 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { uint8_t b; chSysLock(); + if (iqp->q_notify) + iqp->q_notify(iqp); + while (chIQIsEmptyI(iqp)) { msg_t msg; - - if (iqp->q_notify) - iqp->q_notify(iqp); - if ((msg = qwait((GenericQueue *)iqp, time)) < Q_OK) { chSysUnlock(); return msg; @@ -201,9 +199,8 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { * been reset. * @note The function is not atomic, if you need atomicity it is suggested * to use a semaphore or a mutex for mutual exclusion. - * @note The callback is invoked if the queue is empty before entering the - * @p THD_STATE_WTQUEUE state in order to solicit the low level to - * start queue filling. + * @note The callback is invoked before reading each character from the + * buffer or before entering the state @p THD_STATE_WTQUEUE. * * @param[in] iqp pointer to an @p InputQueue structure * @param[out] bp pointer to the data buffer @@ -227,10 +224,10 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, chSysLock(); while (TRUE) { - while (chIQIsEmptyI(iqp)) { - if (nfy) - nfy(iqp); + if (nfy) + nfy(iqp); + while (chIQIsEmptyI(iqp)) { if (qwait((GenericQueue *)iqp, time) != Q_OK) { chSysUnlock(); return r; -- cgit v1.2.3 From befe9632df5540514af04a9e7a084a50778873e8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 25 Oct 2011 19:56:00 +0000 Subject: Fixed a small documentation error in port_unlock() implementations. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3452 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/templates/chcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel') diff --git a/os/kernel/templates/chcore.c b/os/kernel/templates/chcore.c index 74281f759..25a3b42a0 100644 --- a/os/kernel/templates/chcore.c +++ b/os/kernel/templates/chcore.c @@ -50,7 +50,7 @@ void port_lock(void) { /** * @brief Kernel-unlock action. - * @details Usually this function just disables interrupts but may perform more + * @details Usually this function just enables interrupts but may perform more * actions. */ void port_unlock(void) { -- cgit v1.2.3