2017-03-09 49 views

回答

0

幾乎逐字從shodanex's answer轉化爲相關問題。

如果在內核中啓用了看門狗驅動程序,則看門狗驅動程序會設置一個內核定時器來負責重置看門狗。

如果沒有應用程序打開/ dev/watchdog文件,那麼內核負責重置看門狗。由於它是一個計時器,它不會顯示爲專用內核線程,而是由軟IRQ線程處理。現在,如果一個應用程序打開這個文件,它就會對看門狗負責,並且可以通過寫入文件來重置它,如文檔the watchdog documentation所述。

2016年7月a commit in the 4.7 kernel to watchdog_dev.c爲所有看門狗定時器驅動程序啓用了此行爲。在此之前,它似乎是特定的和司機。行爲似乎沒有記錄在此線程和源代碼以外的任何地方。

/* 
* A worker to generate heartbeat requests is needed if all of the 
* following conditions are true. 
* - Userspace activated the watchdog. 
* - The driver provided a value for the maximum hardware timeout, and 
* thus is aware that the framework supports generating heartbeat 
* requests. 
* - Userspace requests a longer timeout than the hardware can handle. 
* 
* Alternatively, if userspace has not opened the watchdog 
* device, we take care of feeding the watchdog if it is 
* running. 
*/ 

return (hm && watchdog_active(wdd) && t > hm) || 
     (t && !watchdog_active(wdd) && watchdog_hw_running(wdd));