mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-19 11:17:43 -04:00
Added uxTaskGetStackHighWaterMark2(), which is the same as uxTaskGetStackHighWaterMark() other than the return type.
Allows the task name parameter passed into xTaskCreate() to be NULL.
This commit is contained in:
parent
e3dc5e934b
commit
c6de0001fa
14 changed files with 140 additions and 27 deletions
|
@ -100,7 +100,7 @@ changed then the definition of StaticTask_t must also be updated. */
|
|||
/* If any of the following are set then task stacks are filled with a known
|
||||
value so the high water mark can be determined. If none of the following are
|
||||
set then don't fill the stack so there is no unnecessary dependency on memset. */
|
||||
#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
|
||||
#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
|
||||
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 1
|
||||
#else
|
||||
#define tskSET_NEW_STACKS_TO_KNOWN_VALUE 0
|
||||
|
@ -521,7 +521,7 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseT
|
|||
* This function determines the 'high water mark' of the task stack by
|
||||
* determining how much of the stack remains at the original preset value.
|
||||
*/
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
|
||||
|
||||
static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;
|
||||
|
||||
|
@ -861,8 +861,6 @@ UBaseType_t x;
|
|||
uxPriority &= ~portPRIVILEGE_BIT;
|
||||
#endif /* portUSING_MPU_WRAPPERS == 1 */
|
||||
|
||||
configASSERT( pcName );
|
||||
|
||||
/* Avoid dependency on memset() if it is not required. */
|
||||
#if( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 )
|
||||
{
|
||||
|
@ -905,26 +903,35 @@ UBaseType_t x;
|
|||
#endif /* portSTACK_GROWTH */
|
||||
|
||||
/* Store the task name in the TCB. */
|
||||
for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )
|
||||
if( pcName != NULL )
|
||||
{
|
||||
pxNewTCB->pcTaskName[ x ] = pcName[ x ];
|
||||
for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )
|
||||
{
|
||||
pxNewTCB->pcTaskName[ x ] = pcName[ x ];
|
||||
|
||||
/* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
|
||||
configMAX_TASK_NAME_LEN characters just in case the memory after the
|
||||
string is not accessible (extremely unlikely). */
|
||||
if( pcName[ x ] == ( char ) 0x00 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
/* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
|
||||
configMAX_TASK_NAME_LEN characters just in case the memory after the
|
||||
string is not accessible (extremely unlikely). */
|
||||
if( pcName[ x ] == ( char ) 0x00 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure the name string is terminated in the case that the string length
|
||||
was greater or equal to configMAX_TASK_NAME_LEN. */
|
||||
pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The task has not been given a name, so just ensure there is a NULL
|
||||
terminator when it is read out. */
|
||||
pxNewTCB->pcTaskName[ 0 ] = 0x00;
|
||||
}
|
||||
|
||||
/* Ensure the name string is terminated in the case that the string length
|
||||
was greater or equal to configMAX_TASK_NAME_LEN. */
|
||||
pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';
|
||||
|
||||
/* This is used as an array index so must ensure it's not too large. First
|
||||
remove the privilege bit if one is present. */
|
||||
|
@ -3686,7 +3693,7 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
#endif /* configUSE_TRACE_FACILITY */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
|
||||
#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) )
|
||||
|
||||
static configSTACK_DEPTH_TYPE prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )
|
||||
{
|
||||
|
@ -3703,7 +3710,47 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
return ( configSTACK_DEPTH_TYPE ) ulCount;
|
||||
}
|
||||
|
||||
#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */
|
||||
#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
|
||||
|
||||
/* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
|
||||
same except for their return type. Using configSTACK_DEPTH_TYPE allows the
|
||||
user to determine the return type. It gets around the problem of the value
|
||||
overflowing on 8-bit types without breaking backward compatibility for
|
||||
applications that expect an 8-bit return type. */
|
||||
configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask )
|
||||
{
|
||||
TCB_t *pxTCB;
|
||||
uint8_t *pucEndOfStack;
|
||||
configSTACK_DEPTH_TYPE uxReturn;
|
||||
|
||||
/* uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are
|
||||
the same except for their return type. Using configSTACK_DEPTH_TYPE
|
||||
allows the user to determine the return type. It gets around the
|
||||
problem of the value overflowing on 8-bit types without breaking
|
||||
backward compatibility for applications that expect an 8-bit return
|
||||
type. */
|
||||
|
||||
pxTCB = prvGetTCBFromHandle( xTask );
|
||||
|
||||
#if portSTACK_GROWTH < 0
|
||||
{
|
||||
pucEndOfStack = ( uint8_t * ) pxTCB->pxStack;
|
||||
}
|
||||
#else
|
||||
{
|
||||
pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack;
|
||||
}
|
||||
#endif
|
||||
|
||||
uxReturn = prvTaskCheckFreeStackSpace( pucEndOfStack );
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_uxTaskGetStackHighWaterMark2 */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue