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

Requesting data from another task

Posted by Holger on June 16, 2010
Hello there,

i'm new to the freertos and programmed avrs in a mainloop style so far. For a new project i want to learn more about the intertask communication and the best practises.

So far no problem in the understanding of the RTOS but now i have the following problem.

I have a GUI task which displays the status of other tasks ( UART active, temperatures, usb, ...) So i need some status information from the tasks. My goal is to make independed tasks, which in future could developed by seperate programmers. So they only need to know the messages how to communicate with each other.

Solution 1: The Peripheral tasks sending continously the status data. For me this makes no sense.

Solution 2: The Gui Task uses a shared memory variable from the other task protected by a semaphore. Advantage: No memory overhead, but the GUI task needs to know about the task and its member variables..

Solution 3: The Gui Task requests the data by a Message through a Queue to the corresponding task. The Task will answer in a different queue with the requested data. So the advantage is, you only need to know the messages but not about the task. So different programmers could program independed tasks with only one defined interface ( Messages).

So what are your suggestions about this problem regarding performance, reuse, simply and robustness?


Best reagrds,

Holger

RE: Requesting data from another task

Posted by Dave on June 16, 2010
“Solution 1: The Peripheral tasks sending continously the status data. For me this makes no sense.


I think it makes no sense to send the data unless it has changed, and the change is in some way significant.



“Solution 2: The Gui Task uses a shared memory variable from the other task protected by a semaphore. Advantage: No memory overhead, but the GUI task needs to know about the task and its member variables..


You could end up with a lot of semaphores which will not be efficient.


“Solution 3: The Gui Task requests the data by a Message through a Queue to the corresponding task. The Task will answer in a different queue with the requested data. So the advantage is, you only need to know the messages but not about the task. So different programmers could program independed tasks with only one defined interface ( Messages).


How about have a single queue that the GUI tasks reads. When other tasks post they post the data value and the meaning of the data. That way there is only one queue, everything is serialized, and your app will be efficient.

RE: Requesting data from another task

Posted by Holger on June 17, 2010
Hi Davedoors.

In my GUI task, this is only one point of the menu. So this is a special case. My menu should also setup the parameters for each pheriperal. In this case i will send messages through a queue to each task. My Problem is getting the data from the other task on request.

Best regards

Holger


RE: Requesting data from another task

Posted by Juha Kuusama on June 18, 2010
I had the same problem. In my solution, a task sends out a message when the status changes, but only then. The message is sent to a message passing task, which then sends the message out the any task wanting to know about statuses. That is handy, since I don't need to touch any any of the other tasks if I want to add a logger task, a serial port reporting task or whatever.

By the way, I'm using shared memory for the status info. The task need to know either about the messages or the variables, and I don't see a big difference either way. I have functions to read and write to the shared memory, and then the status messages are simply "task1 status changed" and the monitor task calls read status variable function; no need to make it any more complicated:-).

RE: Requesting data from another task

Posted by Holger on June 22, 2010
Hi there,

now i had another idea to solve this:

I have two queues:

1) CommandQueue:
This queue will get events from other tasks. (setting vars, execute functions,etc) It also will receive a RequestEvent from another task. This request is not send to the CommandQueue from that task, but to the RequestQueue of that task.


2) RequestQueue:
In this queue we will receive requested data from other tasks. Since there is only data written on request of this task, there is no collision with other tasks.

I find this system easy to use, because you can simple wrap this to the uart, spi, I2C to communicate with other peripherals.

Best regards,

Holger


[ 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