Quality RTOS & Embedded Software

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


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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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.


Careers

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

Renesas

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