From 9754b801b539e2d251b911e12756f47e3414ba16 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 19 May 2011 17:58:18 +0000 Subject: [PATCH] Fixed bug 3303841. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.2.x@2975 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chthreads.h | 4 +++- os/kernel/src/chheap.c | 2 ++ os/kernel/src/chmtx.c | 8 +++++--- os/kernel/src/chschd.c | 6 +++++- readme.txt | 1 + test/testdyn.c | 24 +++++++++++++----------- test/testheap.c | 4 ++-- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 8549da463..633ceb6a6 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -187,8 +187,10 @@ struct Thread { #define THD_STATE_SNDMSG 10 /** @brief Thread state: Waiting in @p chMsgWait().*/ #define THD_STATE_WTMSG 11 +/** @brief Thread state: Waiting on an I/O queue.*/ +#define THD_STATE_WTQUEUE 12 /** @brief Thread state: After termination.*/ -#define THD_STATE_FINAL 12 +#define THD_STATE_FINAL 13 /* * Various flags into the thread p_flags field. diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c index bcc1bf894..91d811160 100644 --- a/os/kernel/src/chheap.c +++ b/os/kernel/src/chheap.c @@ -86,6 +86,8 @@ void heap_init(void) { * @brief Initializes a memory heap from a static memory area. * @pre Both the heap buffer base and the heap size must be aligned to * the @p stkalign_t type size. + * @pre In order to use this function the option @p CH_USE_MALLOC_HEAP + * must be disabled. * * @param[out] heapp pointer to the memory heap descriptor to be initialized * @param[in] buf heap buffer base diff --git a/os/kernel/src/chmtx.c b/os/kernel/src/chmtx.c index 3b7e59a99..eb6326326 100644 --- a/os/kernel/src/chmtx.c +++ b/os/kernel/src/chmtx.c @@ -140,14 +140,16 @@ void chMtxLockS(Mutex *mp) { prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp); tp = ((Mutex *)tp->p_u.wtobjp)->m_owner; continue; -#if CH_USE_CONDVARS | CH_USE_SEMAPHORES_PRIORITY | CH_USE_MESSAGES_PRIORITY +#if CH_USE_CONDVARS | \ + (CH_USE_SEMAPHORES && CH_USE_SEMAPHORES_PRIORITY) | \ + (CH_USE_MESSAGES && CH_USE_MESSAGES_PRIORITY) #if CH_USE_CONDVARS case THD_STATE_WTCOND: #endif -#if CH_USE_SEMAPHORES_PRIORITY +#if CH_USE_SEMAPHORES && CH_USE_SEMAPHORES_PRIORITY case THD_STATE_WTSEM: #endif -#if CH_USE_MESSAGES_PRIORITY +#if CH_USE_MESSAGES && CH_USE_MESSAGES_PRIORITY case THD_STATE_SNDMSG: #endif /* Re-enqueues tp with its new priority on the queue.*/ diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c index 36a00a102..6d3c55989 100644 --- a/os/kernel/src/chschd.c +++ b/os/kernel/src/chschd.c @@ -136,12 +136,16 @@ static void wakeup(void *p) { /* Handling the special case where the thread has been made ready by another thread with higher priority.*/ return; -#if CH_USE_SEMAPHORES || (CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT) +#if CH_USE_SEMAPHORES || CH_USE_QUEUES || \ + (CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT) #if CH_USE_SEMAPHORES case THD_STATE_WTSEM: chSemFastSignalI((Semaphore *)tp->p_u.wtobjp); /* Falls into, intentional. */ #endif +#if CH_USE_QUEUES + case THD_STATE_WTQUEUE: +#endif #if CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT case THD_STATE_WTCOND: #endif diff --git a/readme.txt b/readme.txt index b139a8b11..05f836eb2 100644 --- a/readme.txt +++ b/readme.txt @@ -69,6 +69,7 @@ ***************************************************************************** *** 2.2.4 *** +- FIX: Fixed CH_USE_HEAP and CH_USE_MALLOC_HEAP conflict (bug 3303841). - FIX: Fixed timeout problem in the lwIP interface layer (bug 3302420). - FIX: Fixed invalid BRR() macro in AVR serial driver (bug 3299306). - FIX: Fixed missing IRQ vectors amicable names for STM32 XL devices (bug diff --git a/test/testdyn.c b/test/testdyn.c index 3153db48c..458984d3b 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -59,11 +59,11 @@ * @brief Dynamic thread APIs test header file */ -#if CH_USE_DYNAMIC -#if CH_USE_HEAP +#if CH_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) static MemoryHeap heap1; #endif -#if CH_USE_MEMPOOLS +#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) static MemoryPool mp1; #endif @@ -84,7 +84,7 @@ static msg_t thread(void *p) { return 0; } -#if CH_USE_HEAP +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) static void dyn1_setup(void) { chHeapInit(&heap1, test.buffer, sizeof(union test_buffers)); @@ -130,9 +130,9 @@ ROMCONST struct testcase testdyn1 = { NULL, dyn1_execute }; -#endif /* CH_USE_HEAP */ +#endif /* (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) */ -#if CH_USE_MEMPOOLS +#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) /** * @page test_dynamic_002 Threads creation from Memory Pool * @@ -188,7 +188,8 @@ ROMCONST struct testcase testdyn2 = { }; #endif /* CH_USE_MEMPOOLS */ -#if CH_USE_HEAP && CH_USE_REGISTRY +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \ + defined(__DOXYGEN__) /** * @page test_dynamic_003 Registry and References test * @@ -257,14 +258,15 @@ ROMCONST struct testcase testdyn3 = { * @brief Test sequence for dynamic APIs. */ ROMCONST struct testcase * ROMCONST patterndyn[] = { -#if CH_USE_DYNAMIC -#if CH_USE_HEAP +#if CH_USE_DYNAMIC || defined(__DOXYGEN__) +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) &testdyn1, #endif -#if CH_USE_MEMPOOLS +#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) &testdyn2, #endif -#if CH_USE_HEAP && CH_USE_REGISTRY +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP && CH_USE_REGISTRY) || \ + defined(__DOXYGEN__) &testdyn3, #endif #endif diff --git a/test/testheap.c b/test/testheap.c index a1771f0cb..c6188eb25 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -54,7 +54,7 @@ * @brief Heap header file */ -#if CH_USE_HEAP +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) #define SIZE 16 @@ -162,7 +162,7 @@ ROMCONST struct testcase testheap1 = { * @brief Test sequence for heap. */ ROMCONST struct testcase * ROMCONST patternheap[] = { -#if CH_USE_HEAP +#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) &testheap1, #endif NULL