# Queue set  - reseting

**URL:** <https://forums.freertos.org/t/queue-set-reseting/7882>\
**Category:** Kernel\
**Created:** [May 28, 2019, 4:28pm UTC](https://forums.freertos.org/t/queue-set-reseting/7882 "2019-05-28T16:28:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 28, 2019, 4:28pm UTC](https://forums.freertos.org/t/queue-set-reseting/7882/1 "2019-05-28T16:28:40Z")

</div>

**[yevpator75](https://sourceforge.net/u/yevpator75/)** wrote on [Tuesday, May 28, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/77d996ad0e/#fffd):

Hello

I have 2 queues and a task that is designed as a state machine.  
In some states I need to pend only on one queue among the two I mentioend above and in one specific state - on both of the queues. For this specific case I created a queue set. Thus, we have:

1. Two separates quees
2. The queue set that consits of 2 the same queues

The problem I’m facing is that whenever I receive a message on on of the queues in some states, this triggers the queue set too and when I move to the task state where I pend on the queue set I immediately wakeup because the queue was set by posting to one of its queues. Then, after my queue set wakes up I need to receive a message from this queue and the queue is empty causing configASSERT to fail.

My question is about a way to overcome the problem I expalined above? THat is to say, if I receive a message on the queue while blocking on it, reset the QueueSet so it wont hurt another queue ?

I do have a couple of ideas :

1. Not to use the Queue set, but to create a separate task for the 2nd queue
2. When I wakeup on the queue set and then I check which is the activated member, to ignore the message if the activated member is empty

Hope my description is clear enough.

Thanks for any advice !

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 30, 2019, 12:53am UTC](https://forums.freertos.org/t/queue-set-reseting/7882/2 "2019-05-30T00:53:53Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, May 30, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/77d996ad0e/#fffd/25c5):

> Hope my description is clear enough.

Afraid not :o) The only way to use a queue set is to always read from  
the queue set first, then always read from the queue the set tells you  
contains data - otherwise the state of the queue and the state of the  
set become inconsistent.

You could do something like every time you write to a queue you follow  
up by writing to a something like a counting semaphore - then have the  
receiving tasks block on the counting semaphore if they need to block,  
then peek each queue to see which contains data when they unblock.
