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


xQueueReceive - cannot empty queue

Posted by motico123 on June 9, 2016

Hi guys, We encountered a strange behavior of xQueueReceive function, it goes as follows:

  1. We created a Queue using xQueueCreate function.
  2. We created a task using xTaskCreate function, this task is waiting on the queue with xTickToWait=portMAX_DELAY which means it's blocking without timeout till a message is inserted to the queue.
  3. The problem is that from time to time when our device comes back from reset, the queue message counter is showing 1 although there are already 2 messages in the queue (the last message and the one before it). This creates a sort of continuous 1 message delay (instead of picking msg[N] we always pick up msg[N-1]).
  4. We've tried several workarounds:
  5. We used xQueueReset in order to "re-start" the queue, with no help – the message counter goes to 0, but the queue still had the previous message inside it.
  6. We called xQueueReceive() with xTickToWait=0 in order to empty the queue but that did not help either.

It seems like the queue message counter is somehow missing the "1'st time message", not incrementing itself and this cannot be cleaned until reset. Any idea will be appreciated.

Thanks in advance!

xQueueReceive - cannot empty queue

Posted by rtel on June 9, 2016

When you say:

when our device comes back from reset

do you mean it works the first time, but not after a reset. I so, is this a hard or soft reset, and is the C start up code correctly clearing the .bss segment when the system comes out of reset?

xQueueReceive - cannot empty queue

Posted by motico123 on June 9, 2016

Hi, Reset = soft reset

Also, please note that it is does not happen after every reset, it is quite random. Once it happens it remains until next reset, if it is OK - it will remain OK at least until the next reset.

xQueueReceive - cannot empty queue

Posted by rtel on June 10, 2016

From your description it sounds like the soft resets are not functioning as you expect them to. At a guess I would say your C start up code is not clearing RAM as you expect after a soft reset. I would guess that the problem never occurs after a hard reset - if that is the case then I'm not sure this is actually a FreeRTOS issue.

[ 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