Quality RTOS & Embedded Software

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


Deleting queue task waiting on OK?

Posted by JC on October 26, 2008
If task A is writing to a queue with portMAX_DELAY as the timeout, and the task blocks because the queue is full, what happens when task B deletes the queue with vQueueDelete()?

I probably missed something looking through the source code, but I would think if that xTasksWaitingToSend and xTasksWaitingToReceive lists should be evaluated and the corresponding tasks returned a non-pdPASS return value.

My scenario is that I have a uIP telnetd task that sends and receives via queues to the higher priority monitor task. If printf() from the monitor tasks blocks because the uIP buffers are full, and the socket is subsequently closed, it would appear that because the waiting task is never signaled the queue has been deleted, that the system will deadlock since the uIP task will never clean out the queue.

The monitor runs at a higher task so that the uIP task can be killed from the console. The console should always have control, regardless of what other tasks may have a seizure, which the exception of an exception that requires a reset.

I suppose it might be possible to have uIP close socket process repeatedly read the queue with a wait time of 0 until nothing is returned.

All this is sub-ideal. It'd be better to have the uIP telnetd task run its own instance of the command interpreter. This gets rather problematic with the protosockets implementation, and all it's squirrely little rules that it seems to have about tasks blocking. And the newlib/syscalls implementation gets complimicated since it now has to become much more telnet aware. As it is, it appears the best way is to use a couple queues to pass commands and output back and forth, and have uIP use xQueuePeek() to avoid blocking.

I'm open to suggestions on this. I may be approaching this from a bad angle.


RE: Deleting queue task waiting on OK?

Posted by Richard on October 26, 2008
The way the code is currently you cannot delete a queue that has tasks blocked on it. The QueueDelete function just frees the heap RAM it grabbed when it was created. The best solution might be to extend the queue delete function to unblock tasks first, but this too would be problematic as the tasks would be in a confused state if they unblocked without having either completed their block period or successfully accessed the queue (they would in fact just attempt to block again within the API function itself).

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

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

Latest News

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

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


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