Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在这两个函数中,为什么需要执行WATCHDOG_RESET()?_C_Linux - Fatal编程技术网

在这两个函数中,为什么需要执行WATCHDOG_RESET()?

在这两个函数中,为什么需要执行WATCHDOG_RESET()?,c,linux,C,Linux,我不知道这段代码的上下文 但很可能是因为您不想让您的操作持续太长时间,以至于看门狗超时(并重置您的设备…) 比如说, char NS16550_getc(NS16550_t com_port) { while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) { #ifdef CONFIG_USB_TTY extern void usbtty_poll(v

我不知道这段代码的上下文

但很可能是因为您不想让您的操作持续太长时间,以至于看门狗超时(并重置您的设备…)

比如说,

    char NS16550_getc(NS16550_t com_port)
    {
        while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {    
    #ifdef CONFIG_USB_TTY    
        extern void usbtty_poll(void);    
        usbtty_poll();    
    #endif
    //why do we require to call this watch dog reset
        WATCHDOG_RESET();    
    }
    //return the rbr value 
        return serial_in(&com_port->rbr);
    }

在上面的代码中,您正在这个while循环中重复验证某些条件,现在这个循环可能会运行很长时间,如果您不重置看门狗计时器(或踢踢看门狗),看门狗可能最终会超时。

但是while循环中的每一次条件都满足,那么设备会重置吗?
    char NS16550_getc(NS16550_t com_port)
    {
        while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {    
    #ifdef CONFIG_USB_TTY    
        extern void usbtty_poll(void);    
        usbtty_poll();    
    #endif
    //why do we require to call this watch dog reset
        WATCHDOG_RESET();    
    }
    //return the rbr value 
        return serial_in(&com_port->rbr);
    }
while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {    
    #ifdef CONFIG_USB_TTY    
        extern void usbtty_poll(void);    
        usbtty_poll();    
    #endif
    //why do we require to call this watch dog reset
        WATCHDOG_RESET();    
    }