From ae805916748f4a559d33f3d3a63b6d6ef4628d93 Mon Sep 17 00:00:00 2001 From: rtel Date: Fri, 20 Nov 2015 14:11:11 +0000 Subject: [PATCH] Kernel changes: + Support tickless idle when configUSE_PREEMPTION is 0 (previously tickless idle was only supported when the pre-emptive scheduler was being used). + If a stack was statically allocated, then don't try freeing it if the TCB cannot be allocated. + Remove use of INCLUDE_xEventGroupsSetBitsFromISR() pre-processor macro, as it was not tested anyway. Demo app changes: + Updated SAM4L Atmel Studio project to use Atmel Studio 7. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2393 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../Include/trcKernelPort.h | 2 +- .../FreeRTOSConfig.h | 2 +- .../FreeRTOSConfig.h | 2 +- .../FreeRTOS_Demo.cproj | 237 +++++++++--------- .../src/asf/sam/utils/compiler.h | 1 + .../src/config/FreeRTOSConfig.h | 51 ++-- .../CORTEX_M4_ATSAM4L_Atmel_Studio/src/main.c | 2 +- .../src/FreeRTOSConfig.h | 2 +- .../FreeRTOSConfig.h | 2 +- .../data/freertos822_xilinx.tcl | 2 +- FreeRTOS/Source/event_groups.c | 8 - FreeRTOS/Source/include/FreeRTOS.h | 10 +- FreeRTOS/Source/include/event_groups.h | 4 +- FreeRTOS/Source/include/projdefs.h | 1 + .../Source/portable/MSVC-MingW/portmacro.h | 1 + .../Source/portable/RVDS/ARM_CM3/portmacro.h | 2 + .../Source/portable/RVDS/ARM_CM4F/portmacro.h | 2 + .../portable/RVDS/ARM_CM7/r0p1/portmacro.h | 2 + FreeRTOS/Source/portable/readme.txt | 14 +- FreeRTOS/Source/tasks.c | 49 +++- 20 files changed, 215 insertions(+), 181 deletions(-) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h index c5d25d921..7c8244137 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h @@ -165,7 +165,7 @@ extern int uiInEventGroupSetBitsFromISR; #include "trcUser.h" #if (INCLUDE_NEW_TIME_EVENTS == 1 && configUSE_TICKLESS_IDLE != 0) -#error "NewTime events can not be used in combination with tickless idle!" + #error "NewTime events can not be used in combination with tickless idle!" #endif /* Initialization of the object property table */ diff --git a/FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/FreeRTOSConfig.h index 514cc4743..a043cdf3e 100644 --- a/FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A5_SAMA5D3x_Xplained_IAR/FreeRTOSConfig.h @@ -124,7 +124,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 -#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xEventGroupSetBitsFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 /* This demo makes use of one or more example stats formatting functions. These diff --git a/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/FreeRTOSConfig.h index c05ac6aed..6d9f6e8a0 100644 --- a/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/FreeRTOSConfig.h @@ -124,7 +124,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 -#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xEventGroupSetBitsFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 /* This demo makes use of one or more example stats formatting functions. These diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj index ee91e87e1..b35d94066 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj @@ -2,7 +2,7 @@ 2.0 - 6.2 + 7.0 com.Atmel.ARMGCC.C {dfc77570-bc67-4ee7-8143-c34e75167169} ATSAM4LC4C @@ -23,116 +23,116 @@ 3.5.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SWD com.atmel.avrdbg.tool.samice @@ -166,6 +166,8 @@ 0x20000000 2 + true + @@ -228,11 +230,6 @@ True -T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ - - - ../src/ASF/sam/drivers/eic - - -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ @@ -315,7 +312,7 @@ True Maximum (-g3) True - -std=gnu99 -Wmissing-field-initializers -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -std=gnu99 -Wmissing-field-initializers -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -Wno-attributes libm @@ -328,13 +325,9 @@ True + -T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ - - - ../src/ASF/sam/drivers/eic - - Default (-g) -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/utils/compiler.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/utils/compiler.h index 5f1e1d239..22d88dada 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/utils/compiler.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/utils/compiler.h @@ -156,6 +156,7 @@ #if defined(__CC_ARM) # define __always_inline __forceinline #elif (defined __GNUC__) +# undef __always_inline /* remove warning of the macro being redefined. */ # define __always_inline inline __attribute__((__always_inline__)) #elif (defined __ICCARM__) # define __always_inline _Pragma("inline=forced") diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/config/FreeRTOSConfig.h index f37cae445..fb2639c1c 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/config/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/config/FreeRTOSConfig.h @@ -86,36 +86,37 @@ /* Set configCREATE_LOW_POWER_DEMO to one to run the simple blinky demo, or 0 to run the more comprehensive test and demo application. */ -#define configCREATE_LOW_POWER_DEMO 1 +#define configCREATE_LOW_POWER_DEMO 1 #if configCREATE_LOW_POWER_DEMO == 1 - #define configCPU_CLOCK_HZ 16384 - #define configSYSTICK_CLOCK_HZ 16384 - #define configUSE_TICKLESS_IDLE 1 - #define configTICK_RATE_HZ ( ( TickType_t ) 128 ) + #define configCPU_CLOCK_HZ 16384 + #define configSYSTICK_CLOCK_HZ 16384 + #define configUSE_TICKLESS_IDLE 1 + #define configTICK_RATE_HZ ( ( TickType_t ) 128 ) #else - #define configCPU_CLOCK_HZ sysclk_get_cpu_hz() - #define configUSE_TICKLESS_IDLE 0 - #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) + #define configCPU_CLOCK_HZ sysclk_get_cpu_hz() + #define configUSE_TICKLESS_IDLE 0 + #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #endif /* configCREATE_LOW_POWER_DEMO */ -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 26000 ) ) -#define configMAX_TASK_NAME_LEN ( 10 ) -#define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 -#define configCHECK_FOR_STACK_OVERFLOW 0 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configUSE_APPLICATION_TASK_TAG 0 -#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configMAX_PRIORITIES ( 5 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 26000 ) ) +#define configMAX_TASK_NAME_LEN ( 10 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/main.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/main.c index 2116fbe18..fdf1c3e43 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/main.c @@ -131,7 +131,7 @@ int main( void ) /* The configCREATE_LOW_POWER_DEMO setting is described at the top of this file. */ - #if configCREATE_LOW_POWER_DEMO == 1 + #if( configCREATE_LOW_POWER_DEMO == 1 ) { main_low_power(); } diff --git a/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/src/FreeRTOSConfig.h index 8c7d07d95..8e63501a0 100644 --- a/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/src/FreeRTOSConfig.h @@ -125,7 +125,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 -#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xEventGroupSetBitsFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 /* This demo makes use of one or more example stats formatting functions. These diff --git a/FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS/FreeRTOSConfig.h b/FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS/FreeRTOSConfig.h index fa65262c4..28f4e6aaa 100644 --- a/FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/MSP430X_MSP430FR5969_LaunchPad_IAR_CCS/FreeRTOSConfig.h @@ -144,7 +144,7 @@ left at 1 with no impact on the code size. */ #define INCLUDE_xTaskGetIdleTaskHandle 1 #define INCLUDE_xQueueGetMutexHolder 1 #define INCLUDE_eTaskGetState 1 -#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xEventGroupSetBitsFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_pcTaskGetTaskName 1 diff --git a/FreeRTOS/Demo/Xilinx_FreeRTOS_BSP/repo/bsp/freertos822_xilinx_v1_0/data/freertos822_xilinx.tcl b/FreeRTOS/Demo/Xilinx_FreeRTOS_BSP/repo/bsp/freertos822_xilinx_v1_0/data/freertos822_xilinx.tcl index b6242e529..27451fced 100644 --- a/FreeRTOS/Demo/Xilinx_FreeRTOS_BSP/repo/bsp/freertos822_xilinx_v1_0/data/freertos822_xilinx.tcl +++ b/FreeRTOS/Demo/Xilinx_FreeRTOS_BSP/repo/bsp/freertos822_xilinx_v1_0/data/freertos822_xilinx.tcl @@ -402,7 +402,7 @@ proc generate {os_handle} { puts $config_file "#define INCLUDE_xTaskGetIdleTaskHandle 1" puts $config_file "#define INCLUDE_xQueueGetMutexHolder 1" puts $config_file "#define INCLUDE_eTaskGetState 1" - puts $config_file "#define INCLUDE_xEventGroupSetBitFromISR 1" + puts $config_file "#define INCLUDE_xEventGroupSetBitsFromISR 1" puts $config_file "#define INCLUDE_xTimerPendFunctionCall 1" puts $config_file "#define INCLUDE_pcTaskGetTaskName 1" puts $config_file "#define INCLUDE_xTaskResumeFromISR 1" diff --git a/FreeRTOS/Source/event_groups.c b/FreeRTOS/Source/event_groups.c index 625548c56..e8fe1a7fb 100644 --- a/FreeRTOS/Source/event_groups.c +++ b/FreeRTOS/Source/event_groups.c @@ -87,14 +87,6 @@ header files above, but not in this file, in order to generate the correct privileged Vs unprivileged linkage and placement. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */ -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 ) - #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available. -#endif - -#if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 0 ) - #error INCLUDE_xTimerPendFunctionCall must also be set to one to make the xEventGroupSetBitFromISR() function available. -#endif - /* The following bit fields convey control information in a task's event list item value. It is important they don't clash with the taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */ diff --git a/FreeRTOS/Source/include/FreeRTOS.h b/FreeRTOS/Source/include/FreeRTOS.h index 7d34ec63b..83ab38c85 100644 --- a/FreeRTOS/Source/include/FreeRTOS.h +++ b/FreeRTOS/Source/include/FreeRTOS.h @@ -247,10 +247,6 @@ extern "C" { #define INCLUDE_xTaskResumeFromISR 1 #endif -#ifndef INCLUDE_xEventGroupSetBitFromISR - #define INCLUDE_xEventGroupSetBitFromISR 0 -#endif - #ifndef INCLUDE_xTimerPendFunctionCall #define INCLUDE_xTimerPendFunctionCall 0 #endif @@ -405,6 +401,10 @@ extern "C" { #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) #endif +#ifndef tracePOST_MOVED_TASK_TO_READY_STATE + #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) +#endif + #ifndef traceQUEUE_CREATE #define traceQUEUE_CREATE( pxNewQueue ) #endif @@ -821,7 +821,7 @@ V8 if desired. */ /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even if floating point hardware is otherwise supported by the FreeRTOS port in use. -This constant is not supported by all FreeRTOS ports that include floating +This constant is not supported by all FreeRTOS ports that include floating point support. */ #ifndef configUSE_TASK_FPU_SUPPORT #define configUSE_TASK_FPU_SUPPORT 1 diff --git a/FreeRTOS/Source/include/event_groups.h b/FreeRTOS/Source/include/event_groups.h index a381ed072..b2642b644 100644 --- a/FreeRTOS/Source/include/event_groups.h +++ b/FreeRTOS/Source/include/event_groups.h @@ -376,7 +376,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit } } - * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR + * \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR * \ingroup EventGroup */ #if( configUSE_TRACE_FACILITY == 1 ) @@ -470,7 +470,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_ * Setting bits in an event group is not a deterministic operation because there * are an unknown number of tasks that may be waiting for the bit or bits being * set. FreeRTOS does not allow nondeterministic operations to be performed in - * interrupts or from critical sections. Therefore xEventGroupSetBitFromISR() + * interrupts or from critical sections. Therefore xEventGroupSetBitsFromISR() * sends a message to the timer task to have the set operation performed in the * context of the timer task - where a scheduler lock is used in place of a * critical section. diff --git a/FreeRTOS/Source/include/projdefs.h b/FreeRTOS/Source/include/projdefs.h index 956264b95..92f5dafe9 100644 --- a/FreeRTOS/Source/include/projdefs.h +++ b/FreeRTOS/Source/include/projdefs.h @@ -107,6 +107,7 @@ typedef void (*TaskFunction_t)( void * ); itself. */ #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ +#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ diff --git a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h index e8ed3c980..f4ba0921a 100644 --- a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h +++ b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h @@ -118,6 +118,7 @@ typedef unsigned long UBaseType_t; /* Simulated interrupts return pdFALSE if no context switch should be performed, or a non-zero number if a context switch should be performed. */ #define portYIELD_FROM_ISR( x ) return x +#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) ) void vPortCloseRunningThread( void *pvTaskToDelete, volatile BaseType_t *pxPendYield ); void vPortDeleteThread( void *pvThreadToDelete ); diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h index 808663ff2..4f4da9a37 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM3/portmacro.h @@ -185,6 +185,8 @@ not necessary for to use this port. They are defined so the common demo files /* portNOP() is not required by this port. */ #define portNOP() +#define portINLINE __inline + #ifdef __cplusplus } #endif diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h index d65d2607d..9b85f30dd 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/portmacro.h @@ -198,6 +198,8 @@ not necessary for to use this port. They are defined so the common demo files /* portNOP() is not required by this port. */ #define portNOP() +#define portINLINE __inline + #ifndef portFORCE_INLINE #define portFORCE_INLINE __forceinline #endif diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h index f98fb037e..0c5ccb97c 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/portmacro.h @@ -202,6 +202,8 @@ not necessary for to use this port. They are defined so the common demo files #define portFORCE_INLINE __forceinline #endif +#define portINLINE __inline + /*-----------------------------------------------------------*/ static portFORCE_INLINE void vPortSetBASEPRI( uint32_t ulBASEPRI ) diff --git a/FreeRTOS/Source/portable/readme.txt b/FreeRTOS/Source/portable/readme.txt index a20d687e0..a259d267b 100644 --- a/FreeRTOS/Source/portable/readme.txt +++ b/FreeRTOS/Source/portable/readme.txt @@ -1,19 +1,19 @@ Each real time kernel port consists of three files that contain the core kernel -components and are common to every port, and one or more files that are +components and are common to every port, and one or more files that are specific to a particular microcontroller and/or compiler. -+ The FreeRTOS/Source/Portable/MemMang directory contains the three sample ++ The FreeRTOS/Source/Portable/MemMang directory contains the three sample memory allocators as described on the http://www.FreeRTOS.org WEB site. -+ The other directories each contain files specific to a particular ++ The other directories each contain files specific to a particular microcontroller or compiler. -For example, if you are interested in the GCC port for the ATMega323 -microcontroller then the port specific files are contained in -FreeRTOS/Source/Portable/GCC/ATMega323 directory. If this is the only -port you are interested in then all the other directories can be +For example, if you are interested in the [compiler] port for the [architecture] +microcontroller, then the port specific files are contained in +FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If this is the +only port you are interested in then all the other directories can be ignored. diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 11ca0e976..d4e5ad050 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -341,7 +341,7 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t { \ UBaseType_t uxTopPriority; \ \ - /* Find the highest priority queue that contains ready tasks. */ \ + /* Find the highest priority list that contains ready tasks. */ \ portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority ); \ configASSERT( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ uxTopPriority ] ) ) > 0 ); \ listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) ); \ @@ -389,7 +389,8 @@ count overflows. */ #define prvAddTaskToReadyList( pxTCB ) \ traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ - vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ) + vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ); \ + tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) /*-----------------------------------------------------------*/ /* @@ -1645,6 +1646,34 @@ void vTaskSuspendAll( void ) static TickType_t prvGetExpectedIdleTime( void ) { TickType_t xReturn; + UBaseType_t uxHigherPriorityReadyTasks = pdFALSE; + + /* uxHigherPriorityReadyTasks takes care of the case where + configUSE_PREEMPTION is 0, so there may be tasks above the idle priority + task that are in the Ready state, even though the idle task is + running. */ + #if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) + { + if( uxTopReadyPriority > tskIDLE_PRIORITY ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #else + { + const UBaseType_t uxLeastSignificantBit = ( UBaseType_t ) 0x01; + + /* When port optimised task selection is used the uxTopReadyPriority + variable is used as a bit map. If bits other than the least + significant bit are set then there are tasks that have a priority + above the idle priority that are in the Ready state. This takes + care of the case where the co-operative scheduler is in use. */ + if( uxTopReadyPriority > uxLeastSignificantBit ) + { + uxHigherPriorityReadyTasks = pdTRUE; + } + } + #endif if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) { @@ -1657,6 +1686,13 @@ void vTaskSuspendAll( void ) processed. */ xReturn = 0; } + else if( uxHigherPriorityReadyTasks != pdFALSE ) + { + /* There are tasks in the Ready state that have a priority above the + idle priority. This path can only be reached if + configUSE_PREEMPTION is 0. */ + xReturn = 0; + } else { xReturn = xNextTaskUnblockTime - xTickCount; @@ -2222,9 +2258,9 @@ void vTaskSwitchContext( void ) #endif /* Add the amount of time the task has been running to the - accumulated time so far. The time the task started running was + accumulated time so far. The time the task started running was stored in ulTaskSwitchedInTime. Note that there is no overflow - protection here so count values are only valid until the timer + protection here so count values are only valid until the timer overflows. The guard against negative values is to protect against suspect run time stat counter implementations - which are provided by the application, not the kernel. */ @@ -3148,7 +3184,10 @@ TCB_t *pxNewTCB; { /* The stack cannot be used as the TCB was not created. Free it again. */ - vPortFree( pxStack ); + if( puxStackBuffer == NULL ) + { + vPortFree( pxStack ); + } } } else -- 2.39.2