# Can I call xQueueAddToSet while xQueueSelectFromSet is running?

**URL:** <https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036>\
**Category:** Kernel\
**Created:** [November 3, 2020, 7:33pm UTC](https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036 "2020-11-03T19:33:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpfrey](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@dpfrey](https://forums.freertos.org/u/dpfrey)\
**Post date:** [November 3, 2020, 7:33pm UTC](https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036/1 "2020-11-03T19:33:32Z")

</div>

I have a use case where there are multiple tasks each of which have one queue where they are pushing results. I want to have a single task running processing elements from all of these queues. My plan was to have the single processing task use a Queue Set to monitor the multiple client queues.

Here is my question: If the Queue Set currently contains 2 queues and the processing task is blocked from calling `XQueueSelectFromSet`, is it safe for another thread to call `XQueueAddToSet` to add another queue to watch? And furthermore, assuming that the previous operation is safe, will adding an element to the queue which was just added to the Queue Set unblock the task that called `XQueueSelectFromSet` prior to the new queue being added into the set?

---

<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:** [November 3, 2020, 10:51pm UTC](https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036/2 "2020-11-03T22:51:13Z")

</div>

It should be ok, but it is rarely necessary to use a queue set. Are you able to have all the tasks post to the same queue?

---

<div class="post-metadata">

**Author:** ![dpfrey](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@dpfrey](https://forums.freertos.org/u/dpfrey)\
**Post date:** [November 3, 2020, 10:56pm UTC](https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036/3 "2020-11-03T22:56:08Z")

</div>

Using a single queue is another solution that I considered and I may end up there eventually. The disadvantage of that solution is that every queue element then has to be sized based on the client with the largest payload.

Thanks for the clarification on queue sets!

---

<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:** [November 4, 2020, 1:23am UTC](https://forums.freertos.org/t/can-i-call-xqueueaddtoset-while-xqueueselectfromset-is-running/11036/4 "2020-11-04T01:23:52Z")

</div>

Have a look at the “Alternatives to using queue sets” section on this page [https://www.freertos.org/Pend-on-multiple-rtos-objects.html](https://www.freertos.org/Pend-on-multiple-rtos-objects.html)
