From 9697f8c9b0ac155093751d9654f39c39b417abff Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Mon, 20 May 2024 14:24:54 +0530 Subject: [PATCH 1/4] Update documentation of prvGetExpectedIdleTime (#1061) Signed-off-by: Gaurav Aggarwal --- tasks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 3423becd4..db158f655 100644 --- a/tasks.c +++ b/tasks.c @@ -662,7 +662,8 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, /* * Return the amount of time, in ticks, that will pass before the kernel will - * next move a task from the Blocked state to the Running state. + * next move a task from the Blocked state to the Running state or before the + * tick count overflows (whichever is earlier). * * This conditional compilation should use inequality to 0, not equality to 1. * This is to ensure portSUPPRESS_TICKS_AND_SLEEP() can be called when user From 27c4feff665a0bdcb447735d6c3d60664f2cc3f0 Mon Sep 17 00:00:00 2001 From: Florian La Roche Date: Thu, 23 May 2024 11:51:29 +0200 Subject: [PATCH 2/4] typo: add space to examples/template_configuration/FreeRTOSConfig.h (#1069) Signed-off-by: Florian La Roche --- examples/template_configuration/FreeRTOSConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/template_configuration/FreeRTOSConfig.h b/examples/template_configuration/FreeRTOSConfig.h index c35630bd1..fe21f1108 100644 --- a/examples/template_configuration/FreeRTOSConfig.h +++ b/examples/template_configuration/FreeRTOSConfig.h @@ -640,7 +640,7 @@ #define configUSE_APPLICATION_TASK_TAG 0 /* USE_POSIX_ERRNO enables the task global FreeRTOS_errno variable which will - * containthe most recent error for that task. */ + * contain the most recent error for that task. */ #define configUSE_POSIX_ERRNO 0 /* Set the following INCLUDE_* constants to 1 to incldue the named API function, From ef22228bdae4fbeedd9b6baec484053755d9bee0 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Fri, 24 May 2024 12:53:54 +0530 Subject: [PATCH 3/4] Change UBaseType_t to BaseType_t for a boolean variable (#1072) --- tasks.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks.c b/tasks.c index db158f655..a049d64fe 100644 --- a/tasks.c +++ b/tasks.c @@ -3895,9 +3895,9 @@ void vTaskSuspendAll( void ) static TickType_t prvGetExpectedIdleTime( void ) { TickType_t xReturn; - UBaseType_t uxHigherPriorityReadyTasks = pdFALSE; + BaseType_t xHigherPriorityReadyTasks = pdFALSE; - /* uxHigherPriorityReadyTasks takes care of the case where + /* xHigherPriorityReadyTasks 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. */ @@ -3905,7 +3905,7 @@ void vTaskSuspendAll( void ) { if( uxTopReadyPriority > tskIDLE_PRIORITY ) { - uxHigherPriorityReadyTasks = pdTRUE; + xHigherPriorityReadyTasks = pdTRUE; } } #else @@ -3919,7 +3919,7 @@ void vTaskSuspendAll( void ) * care of the case where the co-operative scheduler is in use. */ if( uxTopReadyPriority > uxLeastSignificantBit ) { - uxHigherPriorityReadyTasks = pdTRUE; + xHigherPriorityReadyTasks = pdTRUE; } } #endif /* if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 ) */ @@ -3935,7 +3935,7 @@ void vTaskSuspendAll( void ) * processed. */ xReturn = 0; } - else if( uxHigherPriorityReadyTasks != pdFALSE ) + else if( xHigherPriorityReadyTasks != pdFALSE ) { /* There are tasks in the Ready state that have a priority above the * idle priority. This path can only be reached if From 9f22177c02b03df2fc563482f11df4e710604287 Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Thu, 30 May 2024 02:13:07 +0800 Subject: [PATCH 4/4] Readability enhancements in heap_1.c (#1074) * Remove that Heap_1.c unnecessary judgment and code logic * Remove useless alignment calculations and increase heap usage size * Revert "Remove useless alignment calculations and increase heap usage size" This reverts commit 7832a4bc118661676c4aaa377e412c35ec0b728c. * Readability improvements Signed-off-by: Gaurav Aggarwal --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: huangly Co-authored-by: Gaurav Aggarwal --- portable/MemMang/heap_1.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c index 68f14bd37..0f7661356 100644 --- a/portable/MemMang/heap_1.c +++ b/portable/MemMang/heap_1.c @@ -51,7 +51,15 @@ #endif /* A few bytes might be lost to byte aligning the heap start address. */ -#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) +#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) + +/* Max value that fits in a size_t type. */ +#define heapSIZE_MAX ( ~( ( size_t ) 0 ) ) + +/* Check if adding a and b will result in overflow. */ +#define heapADD_WILL_OVERFLOW( a, b ) ( ( a ) > ( heapSIZE_MAX - ( b ) ) ) + +/*-----------------------------------------------------------*/ /* Allocate the memory for the heap. */ #if ( configAPPLICATION_ALLOCATED_HEAP == 1 ) @@ -76,12 +84,16 @@ void * pvPortMalloc( size_t xWantedSize ) /* Ensure that blocks are always aligned. */ #if ( portBYTE_ALIGNMENT != 1 ) { - if( xWantedSize & portBYTE_ALIGNMENT_MASK ) + size_t xAdditionalRequiredSize; + + if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { - /* Byte alignment required. Check for overflow. */ - if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) + /* Byte alignment required. */ + xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ); + + if( heapADD_WILL_OVERFLOW( xWantedSize, xAdditionalRequiredSize ) == 0 ) { - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); + xWantedSize += xAdditionalRequiredSize; } else { @@ -96,13 +108,14 @@ void * pvPortMalloc( size_t xWantedSize ) if( pucAlignedHeap == NULL ) { /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT - 1 ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &( ucHeap[ portBYTE_ALIGNMENT - 1 ] ) ) & + ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); } - /* Check there is enough room left for the allocation and. */ - if( ( xWantedSize > 0 ) && /* valid size */ - ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && - ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */ + /* Check there is enough room left for the allocation. */ + if( ( xWantedSize > 0 ) && + ( heapADD_WILL_OVERFLOW( xNextFreeByte, xWantedSize ) == 0 ) && + ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) ) { /* Return the next free byte then increment the index past this * block. */