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


Passing Status and Info between Tasks

Posted by PBXNewbie on July 19, 2007
If multiple tasks are trying to write to the same queue, do I need to do anything differently to protect these queue writes from context switches?

For example, say I have an application with multiple tasks, each gathering information from different sources. One additional task is responsible for reporting this information through a communications pipe. Can I create one queue that each of the producer tasks writes to and the consumer task reads from, or do I need to have multiple queues, one for each producer task?

If I also want to have a status variable that is accessed by each of these tasks, can I merely create a global variable and surround any reads and writes to this variable with:
// write to or read from global variable


RE: Passing Status and Info between Tasks

Posted by Richard on July 19, 2007
You can have multiple readers and multiple writers to a single queue with no problem. Tasks will block on queue reads and writes in their priority order. The kernel takes care of the multiple access issues for you.

Regarding the status variable. You can use the critical sections as you note in your post. This is only necessary if there are multiple writers to the variable, or if the data type of the variable is larger than the natural type of the machine (meaning accesses to the variable are not atomic). A task that just reads a variable of the natural type or smaller does not need the critical section


RE: Passing Status and Info between Tasks

Posted by PBXNewbie on July 20, 2007

That makes life easy!

[ 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