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

Function prvDeleteTCB

tasks.c:4834–4885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4832#if ( INCLUDE_vTaskDelete == 1 )
4833
4834 static void prvDeleteTCB( TCB_t * pxTCB )
4835 {
4836 /* This call is required specifically for the TriCore port. It must be
4837 * above the vPortFree() calls. The call is also used by ports/demos that
4838 * want to allocate and clean RAM statically. */
4839 portCLEAN_UP_TCB( pxTCB );
4840
4841 /* Free up the memory allocated by the scheduler for the task. It is up
4842 * to the task to free any memory allocated at the application level.
4843 * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
4844 * for additional information. */
4845 #if ( configUSE_NEWLIB_REENTRANT == 1 )
4846 {
4847 _reclaim_reent( &( pxTCB->xNewLib_reent ) );
4848 }
4849 #endif /* configUSE_NEWLIB_REENTRANT */
4850
4851 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( portUSING_MPU_WRAPPERS == 0 ) )
4852 {
4853 /* The task can only have been allocated dynamically - free both
4854 * the stack and TCB. */
4855 vPortFreeStack( pxTCB->pxStack );
4856 vPortFree( pxTCB );
4857 }
4858 #elif ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
4859 {
4860 /* The task could have been allocated statically or dynamically, so
4861 * check what was statically allocated before trying to free the
4862 * memory. */
4863 if( pxTCB->ucStaticallyAllocated == tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB )
4864 {
4865 /* Both the stack and TCB were allocated dynamically, so both
4866 * must be freed. */
4867 vPortFreeStack( pxTCB->pxStack );
4868 vPortFree( pxTCB );
4869 }
4870 else if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_ONLY )
4871 {
4872 /* Only the stack was statically allocated, so the TCB is the
4873 * only memory that must be freed. */
4874 vPortFree( pxTCB );
4875 }
4876 else
4877 {
4878 /* Neither the stack nor the TCB were allocated dynamically, so
4879 * nothing needs to be freed. */
4880 configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB );
4881 mtCOVERAGE_TEST_MARKER();
4882 }
4883 }
4884 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
4885 }
4886
4887#endif /* INCLUDE_vTaskDelete */
4888/*-----------------------------------------------------------*/

Callers 2

vTaskDeleteFunction · 0.85

Calls 1

vPortFreeFunction · 0.50

Tested by

no test coverage detected