# Problems with Task Priorities

**URL:** <https://forums.freertos.org/t/problems-with-task-priorities/3986>\
**Category:** Kernel\
**Created:** [June 3, 2009, 8:50am UTC](https://forums.freertos.org/t/problems-with-task-priorities/3986 "2009-06-03T08:50:14Z")\
**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:** [June 3, 2009, 8:50am UTC](https://forums.freertos.org/t/problems-with-task-priorities/3986/1 "2009-06-03T08:50:14Z")

</div>

**[mathias3](https://sourceforge.net/u/mathias3/)** wrote on [Wednesday, June 03, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/b396b636/#330d):

Hi

I have several tasks running in my application. Basically I want them to run periodically in a fix order. Unfortunately the execution seems to mix up so I do not achieve the desired order.

Task 1 (priority 6) should execute every 10ms and increments a variable (time base in 10ms steps). It blocks calling vTaskDelayUntil.

Task 2 (priority 4) depends on the variable’s value and should also execute every 10ms. It also blocks calling vTaskDelayUntil.

As far as I know Task 1 should always enter the running state first due to its higher priority. After Task 1 having blocked, Task 2 should enter the running state (never missing an increment). I assume this scenario should repeat for ever periodically. How can it happen that Task 1 sometimes gets executed twice before Task 2 enters the running state? Is my approach wrong? Can a task leave the blocked state prior to the elapsing of the desired delay time (what reasons are possible)? Thanks for helping.

Regards,  
Mathias

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 3, 2009, 9:07am UTC](https://forums.freertos.org/t/problems-with-task-priorities/3986/2 "2009-06-03T09:07:53Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Wednesday, June 03, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/b396b636/#330d/cf7c):

If your tasks are at different priorities then it should work I think, but it will depend on what else your system is doing. For example, is it possible that Task 2 is getting starved of processing time?

Can you cut your app down to the bare bones and still get this behavior? If so then post the code ([pastebin.com](http://pastebin.com) seems to be a good place to put source code and keep the formatting).

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 4, 2009, 5:56am UTC](https://forums.freertos.org/t/problems-with-task-priorities/3986/3 "2009-06-04T05:56:50Z")

</div>

**[mathias3](https://sourceforge.net/u/mathias3/)** wrote on [Thursday, June 04, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/b396b636/#330d/df2e):

Dave,

Thank you for your suggestions. Since my project has become quite big it was the right way to cut it down. I guess to question FreeRTOS was a bit too fast (it works fine as expected). I am using two EVK1100 with ATMEL’s AT32UCA0512. Both boards are using DHCP but unfortunately had the same MAC address. Therefore they got the same IP from the DHCP server!! I believe this troubled my application completely and leaded to getting starved some tasks.

Anyway it helped me to discuss the problem with you. Thanks!
