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

passing strings between tasks

Posted by Dave S on December 10, 2008
What's the best way to pass strings between tasks?
1. xQueueCreate( maxstringlength, sizeof( char ) );
2. xQueueCreate( 1, maxstringlength ); //inefficient because it copies MAX string length instead of actual string length
3. xQueueCreate( 1, sizeof( char* ) ); //also requires semaphores
4. semaphores around a global string?

Thx,
Dave

RE: passing strings between tasks

Posted by dave m on December 10, 2008
Depends whether the receiving task needs to modify the string, and whether the sending task needs its own copy, or needs to release the memory or whatever. For strings that are const after sending (no task needs to modify or delete them), I'd go with 3. If you're really trying to pass a buffer of data from a producer to a consumer (for example), and have the producer generate more data after the consumer is finished, then I'd go with 4: semaphores around a global buffer.

RE: passing strings between tasks

Posted by Dave S on December 10, 2008
Thx Dave.
4 it is.
The producer is generating variable sized non-const 'debug' strings that are output to a port by the consumer.

RE: passing strings between tasks

Posted by dave m on December 10, 2008
Oh yeah, totally. That's a great way to handle debugging output (everything spews into a common circular buffer, and some low-priority task prints it out when it has a chance). It can get pretty complex if you're doing timestamping and making sure messages interleave on a line-by-line basis, plus the buffer has to be pretty big if you have a lot of high-priority output, but a robust debug/error reporting scheme makes development MUCH easier.


[ 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