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/src') 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/src/chthreads.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'os/kernel/src') 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/src') 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 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/src') 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 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/src/chqueues.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'os/kernel/src') 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