Quality RTOS & Embedded Software

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


transferring large data via queue - Design

Posted by jinx on May 7, 2010
I have an application where I need to write large being transferred between two tasks: a producer and a consumer. To make it more efficient, I want to abide by the design given in the FreeRTOS Practical Guide and use pointers to the data to populate the queue. The solution I came up seems complicated and I wanted to see if anyone on the forum had a simpler approach.

I set the Queue of length 5, so I can potentially put in 5 pointers to my 5 data-sets into the queue before the sending (producer) task will block. I then set up a circular buffer of 5 data-sets (structs) for the data itself. Now, since I want the sending task to block in case the data-sets are full (all 5 places are used up), I thought I'd use a 5-count semaphore to block access to the data-set to allow the sending task to block. (The sending task cannot block on the queue directly because it doesn't yet have the address of the data-set to populate the queue with).

The way this will work, I envision, is that the sending task will acquire a semaphore to access the data-set and then write the new value to one of the 5 spots in the data-set. Assuming that there is a spot available, and the write is successful, the sending task will then write a pointer to the data-set to the queue. The receiving task (consumer) since it is blocked on the queue, will then unblock and will be able to access the data by dereferencing the pointer in the queue assuming the queue is not full.

Is this a good way to set this up? Or is there a less complicated way? I'd like your input.


RE: transferring large data via queue - Design

Posted by Richard Damon on May 7, 2010
What I do is set up two queue, one to send pointers for full buffers from the producer to the consumer, and a second one to send pointers for empty buffers from the consumer to the producer. Your initialization code just needs to fill the empty buffer queue, and off things go.

[ 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