services/task_wdt/index.html · services/task_wdt/index.rst 공식 원문 ↗

Zephyr 3.7.0 · Services · Fault Recovery

Task Watchdog

여러 task의 생존 신호를 한 kernel timer로 감시하고 system 복구 경계를 만듭니다.

Official pathservices/task_wdt/index.html
Source fileservices/task_wdt/index.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Task별 software watchdog channel, 가장 이른 deadline 기반 kernel timer, scheduler 고장을 막는 hardware fallback과 channel lifecycle을 설명합니다.

Scope

One global instance

Channels

Per-task deadlines

Fallback

Hardware watchdog

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 83D0EBE1FE235EAD7DA69A27DC06C899584E5AADB4C3A922388C6824D0877555
.. _task_wdt_api:

Task Watchdog
#############

Overview
********

Many microcontrollers feature a hardware watchdog timer peripheral. Its purpose
is to trigger an action (usually a system reset) in case of severe software
malfunctions. Once initialized, the watchdog timer has to be restarted ("fed")
in regular intervals to prevent it from timing out. If the software got stuck
and does not manage to feed the watchdog anymore, the corrective action is
triggered to bring the system back to normal operation.

In real-time operating systems with multiple tasks running in parallel, a
single watchdog instance may not be sufficient anymore, as it can be used for
only one task. This software watchdog based on kernel timers provides a method
to supervise multiple threads or tasks (called watchdog channels).

An existing hardware watchdog can be used as an optional fallback if the task
watchdog itself or the scheduler has a malfunction.

The task watchdog uses a kernel timer as its backend. If configured properly,
the timer ISR is never actually called during normal operation, as the timer is
continuously updated in the feed calls.

It's currently not possible to have multiple instances of task watchdogs.
Instead, the task watchdog API can be accessed globally to add or delete new
channels without passing around a context or device pointer in the firmware.

The maximum number of channels is predefined via Kconfig and should be adjusted
to match exactly the number of channels required by the application.

Configuration Options
*********************

Related configuration options can be found under
:zephyr_file:`subsys/task_wdt/Kconfig`.

* :kconfig:option:`CONFIG_TASK_WDT`

* :kconfig:option:`CONFIG_TASK_WDT_CHANNELS`

* :kconfig:option:`CONFIG_TASK_WDT_HW_FALLBACK`

* :kconfig:option:`CONFIG_TASK_WDT_MIN_TIMEOUT`

* :kconfig:option:`CONFIG_TASK_WDT_HW_FALLBACK_DELAY`

API Reference
*************

.. doxygengroup:: task_wdt_api

Part 3

한국어 전문 번역

Overview

많은 microcontroller에는 hardware watchdog timer가 있습니다. 심각한 software malfunction이 생겼을 때 보통 system reset 같은 조치를 실행하는 장치입니다. Initialize한 뒤에는 timeout이 일어나지 않도록 일정 간격으로 watchdog을 다시 시작, 즉 feed해야 합니다. Software가 멈춰 feed하지 못하면 복구 조치가 실행되어 system을 정상 상태로 되돌립니다.

여러 task가 병렬 실행되는 RTOS에서는 hardware watchdog 하나만으로 각 task의 생존 여부를 구분하기 어렵습니다. Zephyr Task Watchdog는 kernel timer 기반 software watchdog으로 여러 thread 또는 task를 각각의 watchdog channel로 감시합니다.

기존 hardware watchdog은 선택 fallback으로 함께 사용할 수 있습니다. Task watchdog 자체나 scheduler가 고장 나 kernel timer callback도 실행되지 않는 상황에서는 독립 hardware가 마지막 복구 수단이 됩니다.

Task watchdog backend는 kernel timer입니다. 정상 동작 중에는 feed 호출이 timer deadline을 계속 갱신하므로 timer ISR이 실제로 호출되지 않아야 합니다. ISR이 실행됐다는 것은 적어도 한 channel이 약속한 시간 안에 feed하지 못했다는 뜻입니다.

Task watchdog instance를 여러 개 만드는 기능은 현재 지원하지 않습니다. 대신 firmware 전역에서 context나 device pointer를 전달하지 않고 API를 호출해 channel을 추가하거나 삭제합니다.

최대 channel 수는 Kconfig에서 미리 정합니다. Application이 실제로 요구하는 channel 수와 정확히 맞추면 정적 memory 낭비를 줄이고 channel 부족을 설계 시점에 드러낼 수 있습니다.

Task watchdog supervision과 fallback
Application tasks각 task가 자기 channel ID를 주기적으로 feed
task_wdt_feed()
Kernel timer가장 가까운 channel deadline으로 재설정
정상: ISR 실행 안 함
Timeout callback멈춘 task를 감지해 callback 또는 system reset
scheduler 자체가 멈추면
Hardware watchdog선택 fallback이 전체 system을 복구

Configuration Options

관련 설정은 subsys/task_wdt/Kconfig에 있습니다.

  • CONFIG_TASK_WDT: Task Watchdog subsystem을 활성화합니다.
  • CONFIG_TASK_WDT_CHANNELS: 동시에 설치할 수 있는 최대 channel 수를 정합니다.
  • CONFIG_TASK_WDT_HW_FALLBACK: hardware watchdog fallback 사용을 활성화합니다.
  • CONFIG_TASK_WDT_MIN_TIMEOUT: 허용할 minimum software timeout을 정합니다.
  • CONFIG_TASK_WDT_HW_FALLBACK_DELAY: software watchdog deadline 뒤 hardware fallback이 만료되기까지의 추가 delay를 정합니다.

API Reference

전역 API는 initialize, channel 설치·삭제·feed를 제공하며 callback type으로 channel별 복구 동작을 연결합니다.

task_wdt_callback_t
Channel timeout 때 호출되는 callback type입니다. Channel별 user_data를 받아 application-specific recovery를 수행합니다.
task_wdt_init
Task watchdog의 kernel timer를 준비하고 선택적으로 hardware watchdog fallback을 구성합니다. task_wdt_add()와 task_wdt_feed()보다 먼저 호출해야 합니다. Fallback이 필요 없으면 hw_wdt에 NULL을 넘깁니다. Hardware assignment 미지원은 -ENOTSUP이며 timeout 설치 실패는 hardware watchdog API의 음수 errno를 전달합니다.
task_wdt_add
Millisecond 단위 reload_period, timeout callback과 user data로 channel을 설치합니다. 성공하면 이후 feed에 사용할 0 이상의 channel ID를 반환합니다. Callback이 NULL이면 system reset handler를 사용합니다. 잘못된 period는 -EINVAL, channel 고갈은 -ENOMEM입니다.
task_wdt_delete
설치된 channel을 제거해 slot을 다시 사용할 수 있게 합니다. ID는 task_wdt_add()가 반환한 값이어야 하며 설치된 timeout이 없으면 -EINVAL입니다.
task_wdt_feed
지정 channel의 deadline을 갱신합니다. 내부적으로 설치된 모든 channel을 살펴 다음으로 만료될 timeout에 맞춰 공용 kernel timer를 다시 설정합니다. 존재하지 않는 channel이면 -EINVAL입니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.