Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

FreeRTOS vTaskDelete() calls causes an Hang.

Posted by balajisubrcyp on June 14, 2018

Hi All,

I am spawning a thread using below function in FreeRTOS v9.0.0

    result = xTaskCreate( (TaskFunction_t)entry_function, name, (unsigned short)(stack_size / sizeof( portSTACK_TYPE )), (void*)arg, (unsigned portBASE_TYPE) priority, thread );

    return ( result == (signed portBASE_TYPE) pdPASS ) ? WWD_SUCCESS : WWD_THREAD_CREATE_FAILED;

    This Task is created. In this task I run an Iperf Server thread which receive packets from a remote endpoint with data rate of 60Mbps. After about 400 seconds, the Iperf Thread quits and in the calling thread

   vTaskDelete(NULL); 

   is called before exiting the function. this functions calls to remove the pxTCB from the list and here it hangs..
   (UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )

{ /* The list item knows which list it is in. Obtain the list from the list item. */ Listt * const pxList = ( Listt * ) pxItemToRemove->pvContainer;

pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
)

Is this know problem with FreeRTOS the vTaskDelete(NULL) to remove resources fo r current thread causes an system hang..

Thanks Balaji.


FreeRTOS vTaskDelete() calls causes an Hang.

Posted by rtel on June 14, 2018

I'm not sure I full understand the scenario. When the Iperf server quits does the task that was running call vTaskDelete( NULL ), or does another task call that? A task cannot exit just by returning from its implementing function, if that is what the iPerf task is doing, and a task can only delete itself if it uses NULL as the parameter to vTaskDelete() (it must use a valid handle to delete a different task).

Also deleting a task does not automatically delete the resources created by that task, if that is part of your question, it only deletes the task control block and stack that were created by the FreeRTOS itself.

A couple of other points not related to your question:

1 - stack sizes are specified in words, not bytes, so deleting by sizeof( portSTACK_TYPE) might be creating a stack that is one quarter the size you think it is.

2 - the portBASETYPE, etc. types were deprecated long long before FreeRTOS V9.0.0. The equivalent now is BaseTypet. portBASETYPE will only be recongised if you have configENABLEBACKWARD_COMPATIBILITY set to 1 (or undefined, in which case it defaults to 1).


FreeRTOS vTaskDelete() calls causes an Hang.

Posted by balajisubrcyp on June 14, 2018

Hi Richard, When the Iperf server quits does the task that was running call vTaskDelete( NULL ), or does another task call that? >> Here the running task (Iperf server thread spawned) wants to exit and calls vTaskDelete(NULL) , it is the same task which is deleting itself.

Yes I understand the resources are not deleted, But I want the task to exit and another lower priority task to run, Here the Iperf Server task was running at Priority 7 and another console thread task runs at priority 4 which is lower. But the lower priority thread (console) 4 never runs because of this hang. ( for example: the console thread has to input the serial characters which it does not because of the hang.)

Regarding point 1. that portStack_TYPE is inside the Free RTOS kernel I donot modify that code.

I will check back on the portBASE_TYPE, again I am not modifying the FreeRTOS code here, not sure about this I will check.

Thanks Balaji.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo & Nuvoton Cortex-M23 demo.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner