Requesting data from another task

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

Requesting data from another task

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.

Requesting data from another task

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

Requesting data from another task

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:-).

Requesting data from another task

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