# Blocked task still executes

**URL:** <https://forums.freertos.org/t/blocked-task-still-executes/2476>\
**Category:** Kernel\
**Created:** [May 28, 2009, 5:50pm UTC](https://forums.freertos.org/t/blocked-task-still-executes/2476 "2009-05-28T17:50:03Z")\
**Posts on this page:** 3\
**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, 2009, 5:50pm UTC](https://forums.freertos.org/t/blocked-task-still-executes/2476/1 "2009-05-28T17:50:03Z")

</div>

**[gadkins](https://sourceforge.net/u/gadkins/)** wrote on [Thursday, May 28, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/6d884251/#eaf3):

I have created a very simple shell of a programme that I need to generate four time based tasks and a couple of event ones. Having problem I have simplified it the following:  
static void prvTask5ms( void \*pvParameters )  
{  
&nbsp;&nbsp;&nbsp; // some work here for first time through then  
&nbsp;&nbsp;&nbsp; portTickType lastTickTime;  
&nbsp;&nbsp;&nbsp; int x = 0;  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; // set up counter to start  
&nbsp;&nbsp;&nbsp; lastTickTime = xTaskGetTickCount();  
&nbsp;&nbsp;&nbsp; for(;😉  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Delay from last time run not now  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil(&lastTickTime, (5 / portTICK\_RATE\_MS));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do something  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x++;  
&nbsp;&nbsp;&nbsp; }  
}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

static void prvTask10ms( void \*pvParameters )  
{  
&nbsp;&nbsp;&nbsp; // some work here for first time through then  
&nbsp;&nbsp;&nbsp; portTickType lastTickTime;  
&nbsp;&nbsp;&nbsp; int x = 0;  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; // set up counter to start  
&nbsp;&nbsp;&nbsp; lastTickTime = xTaskGetTickCount();  
&nbsp;&nbsp;&nbsp; for(;😉  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Delay from last time run not now  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelayUntil(&lastTickTime, (10 / portTICK\_RATE\_MS));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do something  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x++;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; }  
}

In execution task prvTask5ms runs first (having a high priority) as you would expect but does not stop running after calling the delay function. Looking at the MPLAB OS window it shows the task to be blocked but executing, following the debug trail also shown the task moving from the running to the blocked queue, just before returning&nbsp; it calls Task yield, this seems to do nothing? So returns straight back to the tasks after that it will never work as the counter are out of sequence.

I have build and run the demo SW and this seems to show the same problem

---

<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 28, 2009, 5:56pm UTC](https://forums.freertos.org/t/blocked-task-still-executes/2476/2 "2009-05-28T17:56:49Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, May 28, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/6d884251/#eaf3/0619):

What is configTICK\_RATE\_HZ set to?&nbsp; Is it possible that (5 / portTICK\_RATE\_MS) is invalid?

Regards.

---

<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, 2009, 9:30pm UTC](https://forums.freertos.org/t/blocked-task-still-executes/2476/3 "2009-05-28T21:30:17Z")

</div>

**[gadkins](https://sourceforge.net/u/gadkins/)** wrote on [Thursday, May 28, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/6d884251/#eaf3/5d55):

The tick rate is set to 1000, I have also tried a vTaskDelayUntil(&lastTickTime, (50/ portTICK\_RATE\_MS)); with no effect?
