Bird
Raised Fist0
FreeRTOSprogramming~20 mins

Health monitoring and heartbeat in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Heartbeat Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of Heartbeat in FreeRTOS

What is the main purpose of implementing a heartbeat mechanism in a FreeRTOS-based embedded system?

ATo reduce the memory usage of the system
BTo increase the CPU clock speed dynamically
CTo monitor task execution and detect if any task has stopped responding
DTo automatically update the firmware over the network
Attempts:
2 left
💡 Hint

Think about how the system knows if a task is alive or stuck.

💻 Command Output
intermediate
1:30remaining
Output of Health Check Task Status

Given a FreeRTOS system with a health monitoring task that prints task statuses, what will be the output if the 'SensorTask' has stopped sending heartbeats?

FreeRTOS
Task Name: SensorTask, Heartbeat Received: No
Task Name: LoggerTask, Heartbeat Received: Yes
Task Name: CommTask, Heartbeat Received: Yes
ASensorTask is flagged as unresponsive
BAll tasks are reported as healthy
CSystem resets immediately without any message
DLoggerTask is flagged as unresponsive
Attempts:
2 left
💡 Hint

Look at which task missed the heartbeat.

❓ Configuration
advanced
2:00remaining
Configuring Heartbeat Interval

Which FreeRTOS configuration setting controls the timing for a heartbeat or health check task to run periodically every 500 milliseconds?

AvTaskDelay(pdMS_TO_TICKS(500));
BvTaskDelay(pdMS_TO_TICKS(50));
CvTaskDelay(pdMS_TO_TICKS(5000));
DvTaskDelay(pdMS_TO_TICKS(5));
Attempts:
2 left
💡 Hint

Convert milliseconds to ticks using the FreeRTOS macro.

❓ Troubleshoot
advanced
2:00remaining
Diagnosing Missing Heartbeats

A FreeRTOS health monitoring task reports missing heartbeats from a critical task. Which of the following is the most likely cause?

AThe critical task is running too fast
BThe health monitoring task has a higher priority than the critical task
CThe system clock frequency is too high
DThe critical task is blocked or stuck and not running
Attempts:
2 left
💡 Hint

Think about why a task would fail to send a heartbeat.

🔀 Workflow
expert
3:00remaining
Sequence of Steps for Implementing Heartbeat Monitoring

What is the correct sequence of steps to implement a heartbeat monitoring system in FreeRTOS?

A2,1,3,4
B1,3,2,4
C3,1,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint

Think about setting up the mechanism before checking it.

Practice

(1/5)
1. What is the main purpose of a heartbeat task in FreeRTOS?
easy
A. To permanently block other tasks from running
B. To repeatedly indicate the system is running and healthy
C. To increase CPU usage by running continuously without delay
D. To handle user input events exclusively

Solution

  1. Step 1: Understand heartbeat task role

    A heartbeat task runs repeatedly to show the system is alive and working properly.
  2. Step 2: Eliminate incorrect options

    Blocking other tasks or handling user input are not typical heartbeat functions.
  3. Final Answer:

    To repeatedly indicate the system is running and healthy -> Option B
  4. Quick Check:

    Heartbeat = system health indicator [OK]
Hint: Heartbeat tasks show system health by running repeatedly [OK]
Common Mistakes:
  • Thinking heartbeat blocks other tasks
  • Assuming heartbeat handles user input
  • Believing heartbeat increases CPU load unnecessarily
2. Which FreeRTOS function is best to use inside a heartbeat task to wait without blocking other tasks?
easy
A. vTaskResume()
B. vTaskSuspend()
C. vTaskDelete()
D. vTaskDelay()

Solution

  1. Step 1: Identify delay function for non-blocking wait

    vTaskDelay() suspends the task for a time, allowing others to run.
  2. Step 2: Understand other functions

    vTaskSuspend() pauses a task indefinitely, vTaskDelete() removes it, and vTaskResume() restarts a suspended task.
  3. Final Answer:

    vTaskDelay() -> Option D
  4. Quick Check:

    Use vTaskDelay() for timed waits [OK]
Hint: Use vTaskDelay() to wait without blocking [OK]
Common Mistakes:
  • Using vTaskSuspend() which blocks indefinitely
  • Confusing vTaskDelete() with delay
  • Trying vTaskResume() to wait
3. Given this heartbeat task snippet, what will be the output if the task runs correctly?
void vHeartbeatTask(void *pvParameters) {
  for (;;) {
    printf("Heartbeat\n");
    vTaskDelay(pdMS_TO_TICKS(1000));
  }
}
medium
A. Prints "Heartbeat" once and stops
B. Prints "Heartbeat" continuously without delay
C. Prints "Heartbeat" every second repeatedly
D. Does not print anything due to syntax error

Solution

  1. Step 1: Analyze the infinite loop

    The for(;;) loop runs forever, printing "Heartbeat" each cycle.
  2. Step 2: Check the delay function

    vTaskDelay(pdMS_TO_TICKS(1000)) pauses the task for 1000 ms (1 second) between prints.
  3. Final Answer:

    Prints "Heartbeat" every second repeatedly -> Option C
  4. Quick Check:

    Infinite loop + vTaskDelay(1s) = repeated print every second [OK]
Hint: Infinite loop with vTaskDelay prints repeatedly [OK]
Common Mistakes:
  • Thinking it prints only once
  • Ignoring the delay causing continuous print
  • Assuming syntax error without checking code
4. Identify the error in this heartbeat task code snippet:
void vHeartbeatTask(void *pvParameters) {
  while(1) {
    printf("Heartbeat\n");
    vTaskDelay(1000);
  }
}
medium
A. vTaskDelay() argument should be in ticks, not milliseconds
B. printf() cannot be used inside tasks
C. while(1) should be for(;;)
D. Missing task notification call

Solution

  1. Step 1: Check vTaskDelay argument type

    vTaskDelay() expects delay in ticks, not milliseconds directly.
  2. Step 2: Correct usage

    Use pdMS_TO_TICKS(1000) to convert 1000 ms to ticks for vTaskDelay.
  3. Final Answer:

    vTaskDelay() argument should be in ticks, not milliseconds -> Option A
  4. Quick Check:

    vTaskDelay(ms) wrong, use pdMS_TO_TICKS(ms) [OK]
Hint: Always convert ms to ticks with pdMS_TO_TICKS() [OK]
Common Mistakes:
  • Passing milliseconds directly to vTaskDelay()
  • Thinking printf() is disallowed in tasks
  • Believing while(1) is invalid syntax
5. You want to implement a heartbeat task that signals system health by toggling an LED every 500 ms and also logs a message every 5 seconds. Which approach is best?
hard
A. Create two separate tasks: one toggling LED every 500 ms, another logging every 5 seconds
B. Use one task with vTaskDelay(500) to toggle LED and count loops to log every 5 seconds
C. Use a single task with vTaskDelay(5000) to do both toggle and log at once
D. Toggle LED and log message without any delay to maximize responsiveness

Solution

  1. Step 1: Understand timing requirements

    LED toggles every 500 ms, logging every 5 seconds require different intervals.
  2. Step 2: Evaluate task design options

    Two separate tasks allow independent timing without complex counting or blocking.
  3. Step 3: Consider drawbacks of other options

    Single task with 500 ms delay and counting adds complexity; 5000 ms delay misses LED timing; no delay wastes CPU.
  4. Final Answer:

    Create two separate tasks: one toggling LED every 500 ms, another logging every 5 seconds -> Option A
  5. Quick Check:

    Separate tasks for different intervals = clean design [OK]
Hint: Use separate tasks for different heartbeat intervals [OK]
Common Mistakes:
  • Trying to handle all timing in one task
  • Using long delays missing faster toggles
  • No delays causing CPU overload
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard