diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-05-17 09:17:17 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-05-17 09:17:17 +0000 |
commit | dd32a2316e1df07158537972262752a8e888a744 (patch) | |
tree | b5eeb0b0e6df0e269509ff23b3085eaf6f9349aa /src/chthreads.c | |
parent | 53f1b747726d85020beca994f6fe67a5e9af7b8e (diff) | |
download | ChibiOS-dd32a2316e1df07158537972262752a8e888a744.tar.gz ChibiOS-dd32a2316e1df07158537972262752a8e888a744.tar.bz2 ChibiOS-dd32a2316e1df07158537972262752a8e888a744.zip |
Fixed bug 2792919, minor documentation improvements.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@979 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chthreads.c')
-rw-r--r-- | src/chthreads.c | 54 |
1 files changed, 26 insertions, 28 deletions
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); |