Watchdog Task Pattern in FreeRTOS
📖 Scenario: You are building a simple embedded system using FreeRTOS. To keep the system reliable, you want to create a watchdog task that monitors if another task is running properly by checking a shared flag.
🎯 Goal: Build a FreeRTOS program with two tasks: a workerTask that sets a flag periodically, and a watchdogTask that checks this flag to detect if the worker is alive. If the worker stops setting the flag, the watchdog will print a warning message.
📋 What You'll Learn
Create a global volatile flag variable called
workerAlive initialized to 0Create a
workerTask that sets workerAlive to 1 every 1000 millisecondsCreate a
watchdogTask that checks workerAlive every 1500 millisecondsIf
workerAlive is 1, the watchdog resets it to 0 and prints "Worker is alive"If
workerAlive is 0, the watchdog prints "Warning: Worker not responding"💡 Why This Matters
🌍 Real World
Watchdog tasks are used in embedded systems to detect if critical tasks stop working and to trigger recovery actions.
💼 Career
Understanding watchdog patterns is important for embedded software engineers working on reliable real-time systems.
Progress0 / 4 steps