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


Queue Overwrite with more than 1 item

Posted by celephicus1 on September 22, 2014

Before using FreeRTOS I used a simple ring buffer to hold a trace of information, arranged so that if it filled new items would overwrite the oldest, so I always had the newest information if they were written before they can be read. What is the easiest way of implementing this in FreeRTOS, by checking if the queue is ful and then eleting the oldest item before inserting a new one? Or I could just use a semaphore with my existing ring buffer code.

Queue Overwrite with more than 1 item

Posted by heinbali01 on September 23, 2014

Hi Tom,

For tracing, I would keep on using the ring buffer because it is 'lite'.

Here's another example:


which can easily be used during an ISR.

For 'real-time' tracing, I would prefer to occasionally lose a message rather than protect every trace action with a semaphore.

But if you want to use queues, that is possible of course. Note that a queue could either store characters (which is 'expensive') or pointers to messages. And also the caller will have to make sure that there is space by removing an old message if it is full... and action which could also be protected by a semaphore...

Regards, Hein

Queue Overwrite with more than 1 item

Posted by celephicus1 on September 24, 2014

Thanks for the answer, the post you pointed to provided the answers. I shall use my lightweight ringbuffer implementation, with protection whilst I modify the buffer pointers with a critical section, that will disable interrupts for a few cycles only. FreeRTOS queues are far too heavy a solution for just logging a few events. I don't need to log in interrupts, only in tasks, but the critical sections will prevent a task switch in the middle of modifying the ring buffer pointers.

[ 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