From: richardbarry Date: Tue, 12 Feb 2013 14:30:12 +0000 (+0000) Subject: Adjusted the wrap checks in the QueueSet test task. X-Git-Tag: V7.4.0~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=81256f37c8b390c72eb26221370ee3a871ddfc6e;p=freertos Adjusted the wrap checks in the QueueSet test task. Added the QueueSet test to the Rowlay Stellaris and SAM4S-EK Studio demos. Updated the MSVC demo to use heap_4.c. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1824 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/FreeRTOSConfig.h index a3776d4a1..dd1e20178 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/FreeRTOSConfig.h @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -99,6 +99,7 @@ #define configQUEUE_REGISTRY_SIZE 10 #define configGENERATE_RUN_TIME_STATS 1 #define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_QUEUE_SETS 1 #define configMAX_PRIORITIES ( 5UL ) #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) @@ -132,4 +133,7 @@ to zero. */ version. */ #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* Disable interrupts and sit in a null loop if assert is called. */ +#define configASSERT( x ) if( ( x == 0 ) ) { taskDISABLE_INTERRUPTS(); for( ;; ); } + #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzp b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzp index 3d683eb4f..67ac5394d 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzp +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzp @@ -58,7 +58,9 @@ + + diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzs b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzs index c67c36900..a7a437463 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzs +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/RTOSDemo.hzs @@ -24,9 +24,7 @@ - - @@ -57,7 +55,7 @@ - + - + diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/main.c b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/main.c index ad38a3dc0..db2873b44 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/main.c +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Rowley/main.c @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -146,6 +146,7 @@ #include "QPeek.h" #include "recmutex.h" #include "IntQueue.h" +#include "QueueSet.h" /*-----------------------------------------------------------*/ @@ -262,6 +263,7 @@ int main( void ) vStartQueuePeekTasks(); vStartRecursiveMutexTasks(); vStartInterruptQueueTasks(); + vStartQueueSetTasks(); /* Start the tasks defined within this file/specific to this demo. */ xTaskCreate( vOLEDTask, ( signed char * ) "OLED", mainOLED_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); @@ -366,12 +368,18 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; { xMessage.pcMessage = "ERROR IN INT QUEUE"; } - + else if( xAreQueueSetTasksStillRunning() != pdTRUE ) + { + xMessage.pcMessage = "ERROR IN QUEUE SET"; + } /* Send the message to the OLED gatekeeper for display. */ xHigherPriorityTaskWoken = pdFALSE; xQueueSendFromISR( xOLEDQueue, &xMessage, &xHigherPriorityTaskWoken ); } + + /* Exercise the queue sets from an ISR. */ + vQueueSetAccessQueueSetFromISR(); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo index 5e8db2c57..9e0627d80 100644 Binary files a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo and b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo differ diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h index 1cfa33cb1..94dcbd37b 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h @@ -92,27 +92,28 @@ #include extern uint32_t SystemCoreClock; -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 1 -#define configCPU_CLOCK_HZ ( SystemCoreClock ) -#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) -#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 40960 ) ) -#define configMAX_TASK_NAME_LEN ( 10 ) -#define configUSE_TRACE_FACILITY 0 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 0 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configUSE_APPLICATION_TASK_TAG 0 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_QUEUE_SETS 1 -#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 1 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMAX_PRIORITIES ( 5 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 40960 ) ) +#define configMAX_TASK_NAME_LEN ( 10 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_QUEUE_SETS 1 +#define configGENERATE_RUN_TIME_STATS 0 /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c index f1c8cfec3..a4a5691c4 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c @@ -211,7 +211,7 @@ void vApplicationTickHook( void ) #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) { /* In this case the tick hook is used as part of the queue set test. */ - vQueueSetWriteToQueueFromISR(); + vQueueSetAccessQueueSetFromISR(); } #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */ } diff --git a/FreeRTOS/Demo/Common/Minimal/QueueSet.c b/FreeRTOS/Demo/Common/Minimal/QueueSet.c index 59dbcd3d2..b7e37c008 100644 --- a/FreeRTOS/Demo/Common/Minimal/QueueSet.c +++ b/FreeRTOS/Demo/Common/Minimal/QueueSet.c @@ -116,13 +116,18 @@ queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */ #define queuesetPRIORITY_CHANGE_LOOPS 100UL /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */ -#define queuesetISR_TX_PERIOD 2//( 100UL ) +#define queuesetISR_TX_PERIOD ( 100UL ) /* The allowable maximum deviation between a received value and the expected received value. A deviation will occur when data is received from a queue inside an ISR in between a task receiving from a queue and the task checking the received value. */ -#define queuesetALLOWABLE_RX_DEVIATION 5 +#define queuesetALLOWABLE_RX_DEVIATION 3 + +/* Ignore values that are at the boundaries of allowable values to make the +testing of limits easier (don't have to deal with wrapping values). */ +#define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 ) + /* * The task that periodically sends to the queue set. */ @@ -414,17 +419,21 @@ static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE ) { /* The value was sent from the ISR. */ - if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetALLOWABLE_RX_DEVIATION ) + if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY ) { /* The value received is at the lower limit of the expected range. Don't test it and expect to receive one higher next time. */ ulExpectedReceivedFromISR++; } - else if( ( ULONG_MAX - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION ) + else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY ) { /* The value received is at the higher limit of the expected range. Don't test it and expect to wrap soon. */ - ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE; + ulExpectedReceivedFromISR++; + if( ulExpectedReceivedFromISR == 0 ) + { + ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE; + } } else { @@ -443,17 +452,21 @@ static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = else { /* The value was sent from the Tx task. */ - if( ulReceived < queuesetALLOWABLE_RX_DEVIATION ) + if( ulReceived < queuesetIGNORED_BOUNDARY ) { /* The value received is at the lower limit of the expected range. Don't test it, and expect to receive one higher next time. */ ulExpectedReceivedFromTask++; } - else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION ) + else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY ) { /* The value received is at the higher limit of the expected range. Don't test it and expect to wrap soon. */ - ulExpectedReceivedFromTask = 0; + ulExpectedReceivedFromTask++; + if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE ) + { + ulExpectedReceivedFromTask = 0; + } } else { diff --git a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h index 31bb3115e..d0c1f9368 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h @@ -85,7 +85,7 @@ #define configUSE_TICK_HOOK 1 #define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ -#define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 20 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 12 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo b/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo index 4e80022d3..3a7a73946 100644 Binary files a/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo and b/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo differ diff --git a/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj b/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj index 5429533dc..6ea0af09d 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj +++ b/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj @@ -129,7 +129,7 @@ - + diff --git a/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters b/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters index bbd24de02..1c628ea6a 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters +++ b/FreeRTOS/Demo/WIN32-MSVC/WIN32.vcxproj.filters @@ -49,9 +49,6 @@ FreeRTOS Source\Source - - FreeRTOS Source\Source - FreeRTOS Source\Source\Portable @@ -115,6 +112,9 @@ Demo App Source + + FreeRTOS Source\Source\Portable + diff --git a/FreeRTOS/Demo/WIN32-MSVC/main.c b/FreeRTOS/Demo/WIN32-MSVC/main.c index 2cc0a9b04..9b0164233 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/main.c +++ b/FreeRTOS/Demo/WIN32-MSVC/main.c @@ -96,6 +96,7 @@ /* Standard includes. */ #include +#include /* Kernel includes. */ #include @@ -292,6 +293,7 @@ const unsigned long ulMSToSleep = 15; xTaskHandle xIdleTaskHandle, xTimerTaskHandle, xTestTask; signed char *pcTaskName; const unsigned char ucConstQueueNumber = 0xaaU, ucConstTaskNumber = 0x55U; +void *pvAllocated; /* These three functions are only meant for use by trace code, and not for direct use from application code, hence their prototypes are not in queue.h. */ @@ -386,13 +388,17 @@ extern unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask ); } } } + + /* Exercise heap_4 a bit. The malloc failed hook will trap failed + allocations so there is no need to test here. */ + pvAllocated = pvPortMalloc( ( rand() % 100 ) + 1 ); + vPortFree( pvAllocated ); } /*-----------------------------------------------------------*/ void vApplicationMallocFailedHook( void ) { - /* Can be implemented if required, but probably not required in this - environment and running this demo. */ + vAssertCalled(); } /*-----------------------------------------------------------*/