# xQueueReceive stops working suddenly during operation 

**URL:** <https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066>\
**Category:** Kernel\
**Created:** [June 30, 2016, 5:46pm UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066 "2016-06-30T17:46:03Z")\
**Posts on this page:** 7\
**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:** [June 30, 2016, 5:46pm UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/1 "2016-06-30T17:46:03Z")

</div>

**[hristozov](https://sourceforge.net/u/hristozov/)** wrote on [Thursday, June 30, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#6b90):

Hi,  
I am using STM32F4 with freeRTOSv8.0.1. IDE is coocox.  
I have a task that blocks on a queue

`xQueueReceive( QueueBtPkg, &bt_pkg_ptr, portMAX_DELAY);`

and three higher priority tasks that puts data on the queue.  
When one of this task puts something on the queue, the queue unlocks it task and everything is OK.  
This works for between few minutes and a couple of hours, then the xQueueReceive stops unlocking it task and becomes full.

My first thought was that this is classic case of task starvation.  
The task where the queue is never executes because the other three higher priority tasks always run.  
In order to check this I created a dummy task

```auto
void task_debug(void * pvParameters) {
	while (1) {
		if (debug_message_cnt_EEG[debug_i_EEG] > 10) {
			asm("nop");
		}
	}
}

```

and put break point on the asm(“nop”). This task has the lowest priority. It priority is lower then the task with the queue. In the if statement I check a value updated by the three sending tasks. This value is returned by uxQueueMessagesWaiting(QueueBtPkg).

`debug_message_cnt_EEG[debug_i_EEG] = uxQueueMessagesWaiting(QueueBtPkg);`

Now I see that the program stops at the break point at asm(“nop”). This means that the queue is not empty but doesn’t unlock the it task. Because the dummy task also has the lowest priority and it is unlocked there is no task starvation.

Anny ideas, what can cause this?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 30, 2016, 5:58pm UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/2 "2016-06-30T17:58:03Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Thursday, June 30, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#7f34):

do you have configASSERT() implemented?  
[http://www.freertos.org/FAQHelp.html](http://www.freertos.org/FAQHelp.html)  
[http://www.freertos.org/RTOS-Cortex-M3-M4.html](http://www.freertos.org/RTOS-Cortex-M3-M4.html)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 1, 2016, 6:23am UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/3 "2016-07-01T06:23:09Z")

</div>

**[hristozov](https://sourceforge.net/u/hristozov/)** wrote on [Friday, July 01, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#c69e):

Yes

---

<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:** [July 1, 2016, 7:35am UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/4 "2016-07-01T07:35:36Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, July 01, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#c69e/fdfd):

You have one task that is draining the queue. When the queue becomes  
full, what is this task doing? Is it still blocked on the queue, or is  
it not blocked on the queue any more?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 1, 2016, 7:49am UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/5 "2016-07-01T07:49:26Z")

</div>

**[hristozov](https://sourceforge.net/u/hristozov/)** wrote on [Friday, July 01, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#8914):

Is it still blocked on the queue

---

<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:** [July 1, 2016, 8:17am UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/6 "2016-07-01T08:17:41Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, July 01, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#8914/bbdd):

How have you determined that? For example, are you examining the data  
structures internally (requires some expert knowledge), viewing the  
system status on a debugger plug-in, adding in your own debug code (for  
example setting a pin on the way into the queue receive function and  
clearing the pin on the way out), or something else?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 1, 2016, 9:08am UTC](https://forums.freertos.org/t/xqueuereceive-stops-working-suddenly-during-operation/6066/7 "2016-07-01T09:08:20Z")

</div>

**[hristozov](https://sourceforge.net/u/hristozov/)** wrote on [Friday, July 01, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/d3890dd6/#b67d):

I am using a dummy task with lower priority then the priority of the task blocking on the queue, please my first post.

Can you point me to documentation on how to examine the data structure internally.
