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

Function xTaskCreateRestricted

tasks.c:1159–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1157#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1158
1159 BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
1160 TaskHandle_t * pxCreatedTask )
1161 {
1162 TCB_t * pxNewTCB;
1163 BaseType_t xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
1164
1165 configASSERT( pxTaskDefinition->puxStackBuffer );
1166
1167 if( pxTaskDefinition->puxStackBuffer != NULL )
1168 {
1169 /* Allocate space for the TCB. Where the memory comes from depends
1170 * on the implementation of the port malloc function and whether or
1171 * not static allocation is being used. */
1172 pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) );
1173
1174 if( pxNewTCB != NULL )
1175 {
1176 /* Store the stack location in the TCB. */
1177 pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer;
1178
1179 #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
1180 {
1181 /* Tasks can be created statically or dynamically, so note
1182 * this task had a statically allocated stack in case it is
1183 * later deleted. The TCB was allocated dynamically. */
1184 pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY;
1185 }
1186 #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */
1187
1188 prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,
1189 pxTaskDefinition->pcName,
1190 ( uint32_t ) pxTaskDefinition->usStackDepth,
1191 pxTaskDefinition->pvParameters,
1192 pxTaskDefinition->uxPriority,
1193 pxCreatedTask, pxNewTCB,
1194 pxTaskDefinition->xRegions );
1195
1196 prvAddNewTaskToReadyList( pxNewTCB );
1197 xReturn = pdPASS;
1198 }
1199 }
1200
1201 return xReturn;
1202 }
1203
1204#endif /* portUSING_MPU_WRAPPERS */
1205/*-----------------------------------------------------------*/

Callers

nothing calls this directly

Calls 3

prvInitialiseNewTaskFunction · 0.85
prvAddNewTaskToReadyListFunction · 0.85
pvPortMallocFunction · 0.50

Tested by

no test coverage detected