From dd32a2316e1df07158537972262752a8e888a744 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 17 May 2009 09:17:17 +0000 Subject: Fixed bug 2792919, minor documentation improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@979 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chlists.c | 2 +- src/chthreads.c | 54 +++++++++++++++++++++++++-------------------------- src/include/lists.h | 2 +- src/include/threads.h | 6 +++--- 4 files changed, 31 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/chlists.c b/src/chlists.c index 8d191fc12..a2177ca63 100644 --- a/src/chlists.c +++ b/src/chlists.c @@ -19,7 +19,7 @@ /** * @file chlists.c - * @brief Lists and queues code. + * @brief Thread queues/lists code. * @addtogroup ThreadLists * @{ */ diff --git a/src/chthreads.c b/src/chthreads.c index ae63c2b86..f8bb3b869 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -71,9 +71,8 @@ static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) { * @details The new thread is initialized but not inserted in the ready list, * the initial state is @p PRSUSPENDED. * - * @param[out] workspace pointer to a working area dedicated to the thread - * stack - * @param[in] wsize size of the working area + * @param[out] wsp pointer to a working area dedicated to the thread stack + * @param[in] size size of the working area * @param[in] prio the priority level for the new thread * @param[in] pf the thread function * @param[in] arg an argument passed to the thread function. It can be @p NULL. @@ -85,32 +84,28 @@ static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) { * it is not an I-Class API because it does not touch any critical kernel * data structure. */ -Thread *chThdInit(void *workspace, size_t wsize, - tprio_t prio, tfunc_t pf, void *arg) { - /* thread structure is layed out in the lower part of the thread workspace */ - Thread *tp = workspace; +Thread *chThdInit(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((workspace != NULL) && (wsize >= THD_WA_SIZE(0)) && + chDbgCheck((wsp != NULL) && (size >= THD_WA_SIZE(0)) && (prio <= HIGHPRIO) && (pf != NULL), "chThdInit"); #if CH_DBG_FILL_THREADS - memfill((uint8_t *)workspace, - (uint8_t *)workspace + sizeof(Thread), - THREAD_FILL_VALUE); - memfill((uint8_t *)workspace + sizeof(Thread), - (uint8_t *)workspace + wsize, - STACK_FILL_VALUE); + 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 - SETUP_CONTEXT(workspace, wsize, pf, arg); + SETUP_CONTEXT(wsp, size, pf, arg); return init_thread(tp, prio); } /** * @brief Creates a new thread into a static memory area. * - * @param[out] workspace pointer to a working area dedicated to the thread + * @param[out] wsp pointer to a working area dedicated to the thread * stack - * @param[in] wsize size of the working area + * @param[in] size size of the working area * @param[in] prio the priority level for the new thread * @param[in] pf the thread function * @param[in] arg an argument passed to the thread function. It can be @p NULL. @@ -119,17 +114,17 @@ Thread *chThdInit(void *workspace, size_t wsize, * @note A thread can terminate by calling @p chThdExit() or by simply * returning from its main function. */ -Thread *chThdCreateStatic(void *workspace, size_t wsize, +Thread *chThdCreateStatic(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg) { - return chThdResume(chThdInit(workspace, wsize, prio, pf, arg)); + return chThdResume(chThdInit(wsp, size, prio, pf, arg)); } #if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP /** * @brief Creates a new thread allocating the memory from the heap. * - * @param[in] wsize size of the working area to be allocated + * @param[in] size size of the working area to be allocated * @param[in] prio the priority level for the new thread * @param[in] pf the thread function * @param[in] arg an argument passed to the thread function. It can be @p NULL. @@ -144,13 +139,14 @@ Thread *chThdCreateStatic(void *workspace, size_t wsize, * @p CH_USE_HEAP and @p CH_USE_WAITEXIT options are enabled * in @p chconf.h. */ -Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio, - tfunc_t pf, void *arg) { +Thread *chThdCreateFromHeap(size_t size, tprio_t prio, tfunc_t pf, void *arg) { + void *wsp; + Thread *tp; - void *workspace = chHeapAlloc(wsize); - if (workspace == NULL) + wsp = chHeapAlloc(size); + if (wsp == NULL) return NULL; - Thread *tp = chThdInit(workspace, wsize, prio, pf, arg); + tp = chThdInit(wsp, size, prio, pf, arg); tp->p_flags = P_MEM_MODE_HEAP; return chThdResume(tp); } @@ -179,13 +175,15 @@ Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio, */ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, tfunc_t pf, void *arg) { + void *wsp; + Thread *tp; chDbgCheck(mp != NULL, "chThdCreateFromMemoryPool"); - void *workspace = chPoolAlloc(mp); - if (workspace == NULL) + wsp = chPoolAlloc(mp); + if (wsp == NULL) return NULL; - Thread *tp = chThdInit(workspace, mp->mp_object_size, prio, pf, arg); + tp = chThdInit(wsp, mp->mp_object_size, prio, pf, arg); tp->p_flags = P_MEM_MODE_MEMPOOL; tp->p_mpool = mp; return chThdResume(tp); diff --git a/src/include/lists.h b/src/include/lists.h index 3783f8749..bc3fd7272 100644 --- a/src/include/lists.h +++ b/src/include/lists.h @@ -19,7 +19,7 @@ /** * @file lists.h - * @brief Lists and queues macros and structures. + * @brief Thread queues/lists macros and structures. * @addtogroup ThreadLists * @{ */ diff --git a/src/include/threads.h b/src/include/threads.h index 8e3f7a782..07e068854 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -162,12 +162,12 @@ typedef msg_t (*tfunc_t)(void *); #ifdef __cplusplus extern "C" { #endif - Thread *chThdInit(void *workspace, size_t wsize, + Thread *chThdInit(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg); - Thread *chThdCreateStatic(void *workspace, size_t wsize, + 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(size_t wsize, tprio_t prio, + Thread *chThdCreateFromHeap(size_t size, tprio_t prio, tfunc_t pf, void *arg); #endif #if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS -- cgit v1.2.3