From 2fed1a20f04e0fed69d918251acf18da79f591ac Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 26 Sep 2010 10:03:10 +0000 Subject: [PATCH] Fixed bug 3075544, changed version numbers to 2.0.6. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.0.x@2203 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- docs/Doxyfile | 2 +- os/kernel/include/ch.h | 4 +-- os/kernel/include/chthreads.h | 4 +-- os/kernel/src/chthreads.c | 60 +++++++++++++++++++++++++---------- readme.txt | 4 +++ 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 1e9a3e009..e2be5c466 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = ChibiOS/RT # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 2.0.5 +PROJECT_NUMBER = 2.0.6 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h index 50e21343d..fb5956f1a 100644 --- a/os/kernel/include/ch.h +++ b/os/kernel/include/ch.h @@ -46,7 +46,7 @@ /** * @brief Kernel version string. */ -#define CH_KERNEL_VERSION "2.0.5" +#define CH_KERNEL_VERSION "2.0.6" /** * @brief Kernel version major number. @@ -61,7 +61,7 @@ /** * @brief Kernel version patch number. */ -#define CH_KERNEL_PATCH 5 +#define CH_KERNEL_PATCH 6 /* * Common values. diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 40e756318..07b15be54 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -217,8 +217,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 diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index e7e78f03f..4db883081 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -99,9 +99,7 @@ Thread *init_thread(Thread *tp, tprio_t prio) { queue_init(&tp->p_msgqueue); #endif #if CH_USE_REGISTRY - chSysLock(); REG_INSERT(tp); - chSysUnlock(); #endif #if defined(THREAD_EXT_EXIT_HOOK) THREAD_EXT_INIT_HOOK(tp); @@ -118,11 +116,14 @@ static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) { #endif /** - * @brief Initializes a new thread. + * @brief Creates a new thread into a static memory area. * @details The new thread is initialized but not inserted in the ready list, * the initial state is @p THD_STATE_SUSPENDED. * @note A thread can terminate by calling @p chThdExit() or by simply * returning from its main function. + * @note Threads created using this function do not obey to the + * @p CH_DBG_FILL_THREADS debug option because it would keep + * the kernel locked for too much time. * * @param[out] wsp pointer to a working area dedicated to the thread stack * @param[in] size size of the working area @@ -133,18 +134,14 @@ static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) { * @return The pointer to the @p Thread structure allocated for * the thread into the working space area. */ -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 structure is layed out in the lower part of the thread workspace */ Thread *tp = wsp; chDbgCheck((wsp != NULL) && (size >= THD_WA_SIZE(0)) && (prio <= HIGHPRIO) && (pf != NULL), - "chThdInit"); -#if CH_DBG_FILL_THREADS - memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(Thread), THREAD_FILL_VALUE); - memfill((uint8_t *)wsp + sizeof(Thread), - (uint8_t *)wsp + size, STACK_FILL_VALUE); -#endif + "chThdCreateI"); SETUP_CONTEXT(wsp, size, pf, arg); return init_thread(tp, prio); } @@ -165,8 +162,17 @@ 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) { - - return chThdResume(chThdInit(wsp, size, prio, pf, arg)); + Thread *tp; + +#if CH_DBG_FILL_THREADS + memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(Thread), THREAD_FILL_VALUE); + memfill((uint8_t *)wsp + sizeof(Thread), + (uint8_t *)wsp + size, STACK_FILL_VALUE); +#endif + chSysLock(); + chSchWakeupS(tp = chThdCreateI(wsp, size, prio, pf, arg), RDY_OK); + chSysUnlock(); + return tp; } #if CH_USE_DYNAMIC && CH_USE_HEAP @@ -199,16 +205,26 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, wsp = chHeapAlloc(heapp, size); if (wsp == NULL) return NULL; - tp = chThdInit(wsp, size, prio, pf, arg); + +#if CH_DBG_FILL_THREADS + memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(Thread), THREAD_FILL_VALUE); + memfill((uint8_t *)wsp + sizeof(Thread), + (uint8_t *)wsp + size, STACK_FILL_VALUE); +#endif + + chSysLock(); + tp = chThdCreateI(wsp, size, prio, pf, arg); tp->p_flags = THD_MEM_MODE_HEAP; - return chThdResume(tp); + chSchWakeupS(tp, RDY_OK); + chSysUnlock(); + return tp; } #endif /* CH_USE_DYNAMIC && CH_USE_HEAP */ #if CH_USE_DYNAMIC && CH_USE_MEMPOOLS /** * @brief Creates a new thread allocating the memory from the specified - * Memory Pool. + * memory pool. * @note A thread can terminate by calling @p chThdExit() or by simply * returning from its main function. * @note The memory allocated for the thread is not released when the thread @@ -236,10 +252,20 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, wsp = chPoolAlloc(mp); if (wsp == NULL) return NULL; - tp = chThdInit(wsp, mp->mp_object_size, prio, pf, arg); + +#if CH_DBG_FILL_THREADS + memfill((uint8_t *)wsp, (uint8_t *)wsp + sizeof(Thread), THREAD_FILL_VALUE); + memfill((uint8_t *)wsp + sizeof(Thread), + (uint8_t *)wsp + mp->mp_object_size, STACK_FILL_VALUE); +#endif + + chSysLock(); + tp = chThdCreateI(wsp, mp->mp_object_size, prio, pf, arg); tp->p_flags = THD_MEM_MODE_MEMPOOL; tp->p_mpool = mp; - return chThdResume(tp); + chSchWakeupS(tp, RDY_OK); + chSysUnlock(); + return tp; } #endif /* CH_USE_DYNAMIC && CH_USE_MEMPOOLS */ diff --git a/readme.txt b/readme.txt index cf057a15b..65b2de2d8 100644 --- a/readme.txt +++ b/readme.txt @@ -58,6 +58,10 @@ *** Releases *** ***************************************************************************** +*** 2.0.6 *** +- FIX: Fixed non functioning option CH_USE_NESTED_LOCKS (bug 3075544). +- CHANGE: The API chThdInit() has been renamed to chThdCreateI(). + *** 2.0.5 *** - FIX: Incorrect AT91SAM7X initialization, thanks Leszek (bug 3075354). - FIX: Fixed race condition in function chSchGoSleepTimeoutS, thanks Balázs