# Crash when 3 tasks have different priorities

**URL:** <https://forums.freertos.org/t/crash-when-3-tasks-have-different-priorities/1687>\
**Category:** Kernel\
**Created:** [January 22, 2013, 1:58am UTC](https://forums.freertos.org/t/crash-when-3-tasks-have-different-priorities/1687 "2013-01-22T01:58:13Z")\
**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:** [January 22, 2013, 1:58am UTC](https://forums.freertos.org/t/crash-when-3-tasks-have-different-priorities/1687/1 "2013-01-22T01:58:13Z")

</div>

**[gary-e-a](https://sourceforge.net/u/gary-e-a/)** wrote on [Tuesday, January 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/4b993ed8/#0e99):

I am new to FreeRTOS and have been learning using the debug demo project included in Dave Lyneham’s rtos.zip which was referenced in the x86 write up ([http://www.freertos.org/portternee.html).](http://www.freertos.org/portternee.html%29.)

In main() I created 3 tasks,&nbsp; Each task does a forever loop incrementing a counter variable and then SLEEP\_MS(1000).&nbsp; This code works if the 3 tasks have the same priority.&nbsp; But when I change each task’s priority (for example task 1 has priority 1, task 2 has priority 0, and task 3 has priority 2) then the application crashes when vTaskStartScheduler is called.

freertosconfig.h has #define configUSE\_PREEMPTION 0  
The controller board is Tern’s B engine with 512 MB SDRAM.  
Paradigm C++ V7.00.0054, Tern Edition is the development tool.  
The memory model is large.

I would prefer to use preemption but it crashes even when the priorities are identical.&nbsp; Is there something I have to do in addition to the freertosconfig.h #define change?

Thanks

---

<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:** [January 22, 2013, 9:26am UTC](https://forums.freertos.org/t/crash-when-3-tasks-have-different-priorities/1687/2 "2013-01-22T09:26:10Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, January 22, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/4b993ed8/#0a9b):

Hmm.&nbsp; That is very old code, not an official zip file (provided by Dave), and probably uses a very old version of FreeRTOS.&nbsp; I’m afraid there is not much help I can provide in this case.

If you are looking to learn and experiment with FreeRTOS in a convenient environment then you could try using the MSVC project with the Win32 simulator demos, or the Keil simulator demo.

[http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html](http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html)  
[http://www.freertos.org/simple-freertos-demos.html](http://www.freertos.org/simple-freertos-demos.html)

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 27, 2013, 7:10pm UTC](https://forums.freertos.org/t/crash-when-3-tasks-have-different-priorities/1687/3 "2013-01-27T19:10:28Z")

</div>

**[gary-e-a](https://sourceforge.net/u/gary-e-a/)** wrote on [Sunday, January 27, 2013](https://sourceforge.net/p/freertos/discussion/382005/thread/4b993ed8/#3bea):

Thanks Richard.

I have switched to the demo project WizNET\_DEMO\_TERN\_186 for the Tern B Engine 186.&nbsp; I have still encountered task / priority issues with this demo (I am using the Paradigm C/C++ IDE version 7.00 for Tern).

Since I did not have all of the hardware used in this project I commented out the serial and http task creates.&nbsp; I also modified 186.cfg (changed the amount of RAM from 128 to 512, the rdonly map from 0x0800 to 0x7ffff to 0x2c000 to 0x7ffff and the CODE\_START from 0x0800 to 0x2c000) and freertosconfig.h (config\_USE\_IDLE\_HOOK from 1 to 0 configCPU\_CLOCK\_HZ from 80000000 to 40000000).

After downloading the application I set breakpoints inside the various forever loops that are in the created tasks.&nbsp; When I executed the code none of the breakpoints were hit.&nbsp; I did this because an earlier debug session with a breakpoint in the prvCheckTask function in main.c showed that no other task was running so I thought I could confirm this by breakpoints in the forever loops.

What could be causing the lack of task execution other than prvCheckTask (I even changed its priority from tskIDLE\_PRIORITY + 4 to tskIDLE\_PRIORITY + 2)?

Thanjs for your help.

Best regards,

Gary
