# Scheduling Freezing When adding an Extra Task

**URL:** <https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340>\
**Category:** Kernel\
**Created:** [June 28, 2022, 12:22pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340 "2022-06-28T12:22:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 28, 2022, 12:22pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/1 "2022-06-28T12:22:48Z")

</div>

Hello everyone.

I have a program that has 6 task, 4 of these tasks will run based on a combination of hardware and software events while the other 2 are set to run periodically. I will give them names below to make my explanation a bit clearer:

Task A1 - This task will run if Mode A is selected on a dip switch at power up time. It is  
controlled with an event group  
Task A2 - This task is will run if a software event occurs in Task A1. It is also controlled with  
an event group  
Task B1 - This task will run if Mode B is selected on a dip switch at power up time. It is  
controlled with an event group  
Task B2 - This task is will run if a software event occurs in Task A1. It is also controlled  
with an event group  
Task WD - This task is used to control an internal watchdog. Runs periodically  
Task 4-20 - This task is used to control an external 4-20 chip. Runs periodically.

When I comment out one of the 4-20 tasks everything works great and is scheduled/executed exactly as I expect. If I am running in Mode A and comment out one of the Mode B tasks everything works as expected. If I am running in Mode B and comment out one of the Mode A tasks everything works as expected. The issue comes when I run in either Mode A or Mode B with all tasks created. When I do this the system will behave as expected until the 4-20 task is given a time slice. At that point the system will freeze. I have removed all of the task code from the 4-20 task and have just added a vTaskDelay() to rule out some code I have written in that task causing the issue and the system still freezes. Initially this seemed like a memory issue, but I was able to run all of these tasks individually with significantly smaller stack sizes than I have set now and they have behaved as expected individually. I have also added guards when the tasks are created to ensure all of the tasks are created properly. If there is any other information that you need please let me know.

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 28, 2022, 2:02pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/2 "2022-06-28T14:02:22Z")

</div>

For some reason when I include only a function to change an LED value in the 4-20 task the system doesn’t freeze. The freezing only seems to occur when I use vTaskDelay().

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 28, 2022, 2:50pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/3 "2022-06-28T14:50:50Z")

</div>

Monitor the xTickCount variable. Does it keep inrementing when you hit the freeze? Alternatively, can you check whether your timer interrupt is being invoked in the frozen state?

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 28, 2022, 3:00pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/4 "2022-06-28T15:00:25Z")

</div>

When the system freezes up the xTickCount variable doesn’t increase. It doesn’t freeze at a value either, it comes up as not identifier not found. I am not sure how to check if the timer interrupt is being invoked but I have attached a screenshot from tracealyzer showing the freeze.

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/2/2ae7658fe3bb8d0c9ef810b4d63253d9d8032c8d.png)

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 28, 2022, 3:05pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/5 "2022-06-28T15:05:53Z")

</div>

Why do the ISRs not show in your tracealyer diagram? If they did, you could easily see if your timer still fires.

My suspicion is that one of your tasks claims the critical section and then gets suspended - classical system deadlock.

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 28, 2022, 3:09pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/6 "2022-06-28T15:09:33Z")

</div>

The processor I am using has an MPU which I believe would keep Tracealyzer from tracking the ISR. Task #7 is the 4-20 task that currently just vTaskDelays() for 2000 ticks. I’m not quite sure how that would be claiming the critical section.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 28, 2022, 3:13pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/7 "2022-06-28T15:13:23Z")

</div>

possibly a misconfiguration of your maxsyscall level or a faulty implementation of some port function if you do not use the crit section explicitly. But I assume you are beyond configuration issues…

Note that the culprit is not necessarily the 4-20 task, it may simply be a catalyst to expose an elsewhere problem.

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 28, 2022, 3:51pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/8 "2022-06-28T15:51:37Z")

</div>

I’m definitely not ruling out being beyond configuration issues I’m pretty new at this lol. I am using a TI processor using the Arm Cortex-R4F. The FreeRTOS source files that were produced by the HAL tool included a config header file that does not include any mention of configMAX\_SYSCALL\_INTERRUPT\_PRIORITY or configKERNEL\_INTERRUPT\_PRIORITY. Is this normal or am I missing something?

> Note that the culprit is not necessarily the 4-20 task, it may simply be a catalyst to expose an elsewhere problem.

This was my thinking as well, I am just trying to track what may be causing that issue in that task specifically as other tasks are also using the vTaskDelay function but the issue is always after the 4-20 task is called.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [June 30, 2022, 10:02am UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/9 "2022-06-30T10:02:58Z")

</div>

Are you able to debug this one? Have you defined configASSERT and enabled stack overflow checking? Can you share code snippets or a minimal project showing the problem?

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 30, 2022, 12:13pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/10 "2022-06-30T12:13:41Z")

</div>

I have defined configASSERT to disable interrupts and pause. I’m not sure if I have overflow checking enabled, is that in the config header file? When I put a breakpoint before the vTaskDelay() in the last task that runs before the system freezes I am able to step through the whole process with no errors showing. This seems like it would indicate that there is some conflict with the ISR but I’m not sure how to go about confirming or fixing this.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 30, 2022, 12:24pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/11 "2022-06-30T12:24:22Z")

</div>

Can you check where your PC register points to at freeze time? It is typically either at the hard fault handler infinite loop or somewhere in the idle task.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [June 30, 2022, 12:39pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/12 "2022-06-30T12:39:46Z")

</div>

> [@mercera](#):
>
> I’m not sure if I have overflow checking enabled, is that in the config header file?

> **[FreeRTOS - stacks and stack overflow checking](https://www.freertos.org/Stacks-and-stack-overflow-checking.html)**
>
> FreeRTOS is a portable, open source, mini Real Time kernel. A free RTOS for small embedded systems

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 30, 2022, 12:43pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/13 "2022-06-30T12:43:43Z")

</div>

![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/b/b28b74fce7ec580158e81a1c0ec92b063caa0f1d.png)  
When I pause the debugger while the system is frozen this is what I get on the program counter. I can add a break point else where if you need more information.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 30, 2022, 12:48pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/14 "2022-06-30T12:48:10Z")

</div>

your pc at that address does not make sense. What MCU are you using? Can we see your freertosconfig.h file and some code?

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 30, 2022, 12:57pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/15 "2022-06-30T12:57:28Z")

</div>

I am using the RM44L520 by TI and here is are screenshots of the Config file.

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/a/a10a290323f951e3b2043c43354ea3011c208fab.png)  
 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/5/50be77a5276400a30ac90fc4fba7a6872381eeb8.png)

I can’t show a whole lot of code but here is the 4-20 task as of right now:

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/c/c10f9be8e037d75d8c871b3cc1943ec2aaddb45a.png)  
The rest is commented out. If there is nothing I can try now based on the information that I have provided I can try and replicate the bug in a project with the proprietary code removed.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 30, 2022, 1:08pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/16 "2022-06-30T13:08:21Z")

</div>

Does your IDE also have a source code window? Can we see a screen shot of that one in the frozen and then stopped state?

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 30, 2022, 1:10pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/17 "2022-06-30T13:10:56Z")

</div>

I’m not 100% sure if this is what you’re looking for but when I pause the debugger in the frozen state this is where I land:

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/0/08965133441e2361493f0382b94b21c6b2bb26bc.png)

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 30, 2022, 1:21pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/18 "2022-06-30T13:21:12Z")

</div>

ok, so it is not a system deadlock but a fault. There is a standard check list to work off in that case - do implement the stack overflow checks. Also, we need to know what your maxsyscall priority is - if it is not in your freertosconfig.h, it must be somewhere else. In that turn, also let us know what the priorities of all your isrs are.

Is all your driver code part of the FreeRTOS distribution, or was some ofnit provided by your board manufacturer?

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [June 30, 2022, 1:22pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/19 "2022-06-30T13:22:21Z")

</div>

@mercera You really should post code as code.  
Use 3 tildes **‘~’** or backticks **‘`’** to enclose multi-line code blocks and the **\</\>** button for intraline `code`. Thanks !

---

<div class="post-metadata">

**Author:** ![mercera](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@mercera](https://forums.freertos.org/u/mercera)\
**Post date:** [June 30, 2022, 1:54pm UTC](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340/20 "2022-06-30T13:54:57Z")

</div>

I am going to add the stack over flow checks now. I have searched the entire work space for configKERNEL\_INTERRUPT\_PRIORITY and configMAX\_SYSCALL\_INTERRUPT\_PRIORITY and there is only once instance of configMAX\_SYSCALL\_INTERRUPT\_PRIORITY and it is in a comment and there is no mention of configKERNEL\_INTERRUPT\_PRIORITY anywhere.

[Next page](https://forums.freertos.org/t/scheduling-freezing-when-adding-an-extra-task/15340.md?page=2)
