Cannot use same queue to get data when queue used in a queue set

embgangsta wrote on Tuesday, April 15, 2014:


I have created a queue set QS1 which has queues QC1 and QD1 as queue members.

My task T is waiting on this QS1 and then process data received in QC1.

Upon this processing, my task needs to wait (my design need to do it this way) directly on QD1 to receive data with a xQueueReceive to get data sent within some UART interrupt.

For information I am using FreeRTOS v7.5.2 on EFM32LG280 chip.

I see that my task is only unblocked after a quite long time whereas data was alread posted soon after xQueueReceive was really executed (seen instrumenting code + tracing data).

It seems that if I remove the QD1 from the queue set QS1, then the data receive is working fine as soon as the first interrupt put data in this QD1 …

So it seems a task cannot use a same queue directly with xQueueReceive when this queue belongs to a queue set …

Is it an expected result ??


rtel wrote on Tuesday, April 15, 2014:

If I understand your question correctly, then yes I think this is the expected results.

If data is sent to a queue that is a member of a queue set then a task that was blocked on the set to which the queue belongs will be unblocked, while a task that was blocked directly on the queue itself will not be unblocked.

You could remove the queue from the set first (if there is a function to do that?), then block on the queue. Doing that would risk the queue set telling you there was something in the queue when there wasn’t (because it had already been removed) but that would not necessarily be a problem provided when you read from a queue handle returned from the set you don’t block and check the return value of the xQueueReceive() call to check you actually got data before you try and process it.


embgangsta wrote on Tuesday, April 15, 2014:

Only one task MY_TASK here is using the queue set QS1 and data queues QC1 / QD1.

If I sum up what my task MY_TASK is doing :

At time T0=0, waiting on QS1
At time T0+deltaT, unblocked on QS1 as QC1 was populated with data
Now the task MY_TASK is doing processing in which we are doing a xQueueReceive on QD1 and no more on the initial queue set.

At this moment I can see my problem appearing.

Is it what you understood ?

rtel wrote on Tuesday, April 15, 2014:

Yes. QD1 is part of the set, so if you block on QD1 you will not unblock when data arrives (in effect, the unblock event is going to the set, not the queue).


embgangsta wrote on Tuesday, April 15, 2014:

Oh ok, so FreeRT is no longer unblocking the QD1 itself, only the QS1 ??

So I really have to remove the QD1 member from QS1 before to use QD1 directly … ? and then add it again …

edwards3 wrote on Tuesday, April 15, 2014:

If your application allows you to get away with it you could simply poll the queue without blocking, maybe with a short delay if the queue is empty:

while(xQueueReady( queue, &var, 0 /* 0 so dont block */ )==0){
vTaskDelay( a_few_ms );

you would probably want a manual time out to make sure you dont sit there forever.

embgangsta wrote on Wednesday, April 16, 2014:


I finally updated my task architecture to introduce the different acquisition modes altogether so I am only using one same mechanism (queue set)

Thanks anyway for support