函数 uxTaskGetStackHighWaterMark() 可用于获取任务的最少剩余可用栈
#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) { TCB_t *pxTCB; uint8_t *pucEndOfStack; UBaseType_t uxReturn; pxTCB = prvGetTCBFromHandle( xTask ); #if portSTACK_GROWTH < 0 { pucEndOfStack = ( uint8_t * ) pxTCB->pxStack; } #else { pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack; } #endif uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack ); return uxReturn; } #endif /* INCLUDE_uxTaskGetStackHighWaterMark */
任务创建时,把任务栈的值都初始化为 tskSTACK_FILL_BYTE
/* Avoid dependency on memset() if it is not required. */ #if( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 ) { /* Fill the stack with a known value to assist debugging. */ ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) ulStackDepth * sizeof( StackType_t ) ); } #endif /* tskSET_NEW_STACKS_TO_KNOWN_VALUE */
标签:FreeRTOS,pucEndOfStack,uxReturn,uint8,---,uxTaskGetStackHighWaterMark,pxTCB,UBas From: https://www.cnblogs.com/god-of-death/p/17837526.html