Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Remove specific item from FreeRTOS queue

Posted by exgreyfox on October 19, 2016

Is there possibly any way that I can use a FreeRTOS queue in which I can load up several items and then cherry pick and remove certain items other than doing a queuePeek which only lets me know what is coming up next in the queue? In other words, if I have 3 items on a queue (0, 1, 2) and I want to delete item in position 1 and then have item 2 become the new item 1, is there an easy way to do this? I've looked through the API queue library and have only been able to come up with an algorithm which receives the whole queue on a temporary buffer, deletes an item, then dumps the new contents of the buffer back onto the queue :(

Remove specific item from FreeRTOS queue

Posted by rtel on October 19, 2016

The API is designed to work as a queue, although there are mechanisms to break the first in first out paradigm in some places (for example, posting urgent data to the front of the queue, or peak data) there is no mechanism that can allow a queue to be used as a generic buffer from which data can be inserted or removed from any position.

The actual data in a queue is in a circular buffer, so you could hack your own way of doing this. You would need to see the internal structure of the queue itself, which due to data hiding, would mean you would have to add your code into the queue.c source file.

However, consider using other mechanisms too as it doesn't sound like a queue is actually what you want. You could for example use a linked list. Although not part of the public API and therefore not documented the linked list implementation used internally be FreeRTOS can be used by application code. See list.c and list.h. You could of course always implement your own buffering mechanism.

Remove specific item from FreeRTOS queue

Posted by exgreyfox on October 20, 2016

Thanks guys.

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists