MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / prvInitialiseNewTask

Function prvInitialiseNewTask

tasks.c:1300–1581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1298/*-----------------------------------------------------------*/
1299
1300static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
1301 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1302 const uint32_t ulStackDepth,
1303 void * const pvParameters,
1304 UBaseType_t uxPriority,
1305 TaskHandle_t * const pxCreatedTask,
1306 TCB_t * pxNewTCB,
1307 const MemoryRegion_t * const xRegions )
1308{
1309 StackType_t * pxTopOfStack;
1310 UBaseType_t x;
1311
1312 #if ( portUSING_MPU_WRAPPERS == 1 )
1313 /* Should the task be created in privileged mode? */
1314 BaseType_t xRunPrivileged;
1315
1316 if( ( uxPriority & portPRIVILEGE_BIT ) != 0U )
1317 {
1318 xRunPrivileged = pdTRUE;
1319 }
1320 else
1321 {
1322 xRunPrivileged = pdFALSE;
1323 }
1324 uxPriority &= ~portPRIVILEGE_BIT;
1325 #endif /* portUSING_MPU_WRAPPERS == 1 */
1326
1327 /* Avoid dependency on memset() if it is not required. */
1328 #if ( tskSET_NEW_STACKS_TO_KNOWN_VALUE == 1 )
1329 {
1330 /* Fill the stack with a known value to assist debugging. */
1331 ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) ulStackDepth * sizeof( StackType_t ) );
1332 }
1333 #endif /* tskSET_NEW_STACKS_TO_KNOWN_VALUE */
1334
1335 /* Calculate the top of stack address. This depends on whether the stack
1336 * grows from high memory to low (as per the 80x86) or vice versa.
1337 * portSTACK_GROWTH is used to make the result positive or negative as required
1338 * by the port. */
1339 #if ( portSTACK_GROWTH < 0 )
1340 {
1341 pxTopOfStack = &( pxNewTCB->pxStack[ ulStackDepth - ( uint32_t ) 1 ] );
1342 pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 !e9033 !e9078 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. Checked by assert(). */
1343
1344 /* Check the alignment of the calculated top of stack is correct. */
1345 configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
1346
1347 #if ( configRECORD_STACK_HIGH_ADDRESS == 1 )
1348 {
1349 /* Also record the stack's high address, which may assist
1350 * debugging. */
1351 pxNewTCB->pxEndOfStack = pxTopOfStack;
1352 }
1353 #endif /* configRECORD_STACK_HIGH_ADDRESS */
1354 }
1355 #else /* portSTACK_GROWTH */
1356 {
1357 pxTopOfStack = pxNewTCB->pxStack;

Callers 4

xTaskCreateStaticFunction · 0.85
xTaskCreateRestrictedFunction · 0.85
xTaskCreateFunction · 0.85

Calls 3

vListInitialiseItemFunction · 0.85
pxPortInitialiseStackFunction · 0.50

Tested by

no test coverage detected