Child task to access message queue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Child task to access message queue

1,341 Views
CarlFST60L
Senior Contributor II

Hi,

 

Is there an easy way to allow any child task to receive messages from a private message queue? The code was orginally written as if the queue ID was enough information to access the messages on the queue.


Example

'Main_Task' creates pool / queue to the task 'RXI_Task'

'Main_Task' calls various functions which get data via the message queue to 'RXI_Task'

 

'Main_Task' then creates several child tasks which can call the same functions called from 'Main_Task', these functions get the data via 'RXI_Task' queue. The problem is when these child tasks are created, the message queue ID is no longer enough to get the messages from 'RXI_Task', only 'Main_Task' can access those messages.

 

There is a mutex protecting the functions from multipule tasks trying to access the msgq.

 

Do i have to rewrite this? or is there some other way?

 

 

0 Kudos
Reply
2 Replies

479 Views
MQXuser
Contributor III

Hi Carl,

 

Are you closing(with your Main Task) and reopening the Message Queue with the child task trying to receive the message?

Remember that Only the task that opens a private message queue can receive messages from the queue.

 

And just a small question, if you are protecting the msgq with a mutex, should we protect message pools

with mutex too? I thought MQX protected this functions  by default?

 

msg_ptr = (GENERIC_DATA_MSG_PTR)_msg_alloc(mp_QuadSPI);

 

If different priority tasks have calls to the instruction above, should we use Mutex to prevent simultaneous access?

 

Regards,

 

0 Kudos
Reply

479 Views
CarlFST60L
Senior Contributor II
Maybe it makes no sense, but it would be nice if what ever task knows the queue ID could get messages with that queue ID. Or is there was a simple way you could change ownership of the message queue.
0 Kudos
Reply