2017-03-09 65 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));