From the course: Introduction to FreeRTOS and Basic Task Management

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Suspending a task

Suspending a task

- [Instructor] In this lesson, we're going to learn how to suspend a task and we're going to make it more interesting by monitoring a variable to determine when to suspend a task. Let's start by analyzing what a current project does. So over here at line 50 and 51, we find out that the project creates two tasks and they both have the same priority level. When we scroll down to the task functions at lines 64 and 81, we realize that task1 does a bit of work by counting from 1 to 100,000 and then increments its task profiler. Task2, on the other hand, simply increments its task profiler. Our job in this lesson is to increment a global variable that we shall call the suspend_monitor. And when this global variable crosses a particular threshold, we would suspend task2. So let's start off by defining this threshold at our TODO item one over here. So I'll come to line nine and say define. We'll call this SUSPEND_THRESH and we'll set it to 150, meaning 150 iterations. After 150 iterations…

Contents