# FreeRTOS: Timer service task overrun, daemon task missed deadline

- **ID:** `embedded/freertos-timer-service-task-overrun`
- **Domain:** embedded
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

Timer service task (daemon) is overloaded with too many active software timers or long callback execution, causing it to miss its scheduling deadline.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| FreeRTOS 10.5.1 | active | — | — |
| ESP-IDF 5.1.2 | active | — | — |

## Workarounds

1. **Reduce number of active timers or move long callbacks to separate tasks. Example: if (xTimerIsTimerActive(xTimer)) { xTimerStop(xTimer, 0); }** (85% success)
   ```
   Reduce number of active timers or move long callbacks to separate tasks. Example: if (xTimerIsTimerActive(xTimer)) { xTimerStop(xTimer, 0); }
   ```
2. **Increase configTIMER_TASK_STACK_DEPTH in FreeRTOSConfig.h to 512 or more to prevent stack overflow, and set configTIMER_QUEUE_LENGTH to 20.** (90% success)
   ```
   Increase configTIMER_TASK_STACK_DEPTH in FreeRTOSConfig.h to 512 or more to prevent stack overflow, and set configTIMER_QUEUE_LENGTH to 20.
   ```

## Dead Ends

- **** — Increasing timer service task priority does not fix overrun; the issue is CPU time exhaustion, not priority inversion. (88% fail)
- **** — Adding more timer service tasks creates contention and worsens overrun due to scheduler overhead. (92% fail)
