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




Loading

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.

Thanks!

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 ]    [ 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