Multi-task watchdog monitoring principle and implementation

In order to improve the reliability and security of a microcomputer system in an embedded system, a common method is to use a "watchdog." The watchdog is divided into hardware watchdogs and software watchdogs. The hardware watchdog adopts the “watchdog” circuit. Through the timer, the microcomputer task, “feeding the dog”, is constrained in the running time. The task must be completed within the maximum specified time range, otherwise the system is restarted. The software watchdog uses the processor internal timer to limit the theoretical maximum running time of the task as a time constraint. If the task exceeds this time span, the task is forcibly exited. The above watchdog uses a single-task sequence mechanism that is easy to implement. In a multitasking system, the situation is slightly more complicated. If each task is like a single task system, as long as one task works normally and “feeds the dog” regularly, the watchdog timer will not overflow, and only all tasks have problems. The timer will overflow. Mr. Ye Bangli from Chongqing Normal University once discussed and solved this problem in the Windows system [1]. Some people have talked about it in embedded systems [2], but there is no specific implementation method.

In this paper, the u C / OS - II operating system is ported to the LPC2132 kernel produced by PHILIPS. Based on the system's message mechanism and priority permissions, a task with the highest priority is set as a monitor to monitor all tasks running on the microcomputer. As long as a task fails, the monitoring task delays feeding the dog, overflows the timer, and restarts the system to ensure that the microcomputer and all tasks are in a stable state for a long period of time.

Multi-task watchdog monitoring principle and implementation

1 System Overview

1.1 Introduction to hardware and development environment

The uC/OS-II operating system was ported to the development board of the LPC2132. The LPC2132 is a 32-bit ARM7TDMI-STM core microprocessor supporting real-time emulation and tracking with 64kB high-speed FLASH memory, 4 communication interfaces, 2 32-bit timers, 1 10-bit 8-channel ADC, and 2 hardware interfaces. 47 GPIOs and up to 9 edge or level triggered external interrupts are sufficient for general application and expansion needs.

uC/OS-II is a preemptive multi-tasking real-time operating system. Its source code is open and portable, and it is easy to use, easy to develop and popular. uC/OS-II can manage up to 64 tasks, which are usually functions of an infinite loop. In the current version, the tasks with priority levels 0, 1, 2, 3, OS_LOWEST_PRIO-3, OS_LOWEST_PRIO-2, OS_LOWEST_PRIO-1, OS_LOWEST_PRIO are retained, so the user can have 5 6 tasks at the same time, enough Meet the various requirements of user design.

1.2 System implemented functions

In a multitasking system, it is often desirable to restart a task when there is a problem, without restarting the entire system, so as not to affect the operation of other critical tasks, and restart the system when the task is restarted multiple times. Restart the system when there is an error in the main program of the system or if there is a problem with the system hardware. The watchdog based on the above analysis mainly implements the following functions.

(1) When a task has an exception, the software watchdog restarts the task.

(2) When a certain task fails to restart multiple times, restart the system.

(3) When the operating system itself is abnormal, or when the system hardware is abnormal, the software watchdog or the hardware watchdog restarts the microprocessor.

2 multi-tasking watchdog monitoring principle

In combination with the LPC2132's built-in hardware watchdog and uC/OS-II operating system, a task with the highest priority is set as a monitor to monitor the normal operation of each application task. This monitor is called a software watchdog. This task sets a timer for each monitored task. The monitored task is cleared to the corresponding timer within the set time, which is called “feed soft dog”. In the case that the monitored tasks are working normally, the software watchdog periodically clears the built-in hardware watchdog timer, which is called “feeding the dog”. If a task of the monitored task group fails, the software watchdog cannot "feed the soft dog" within the set time, and the corresponding timer overflows. The system kernel sends an instruction to point the stack address of the task to it. Start address, reset the task, if the task cannot be started effectively within the set number of times, delay "feeding the dog", the hardware watchdog counter overflows, and restart the system. In addition, when the monitor task itself fails, the hardware watchdog timer cannot be cleared in time to restart the system.

3 software implementation

3.1 Communication between application tasks and software watchdogs

When information is passed between the multitasking software watchdog and each application task, each application task sends a running status message to the monitor, and the monitor task also sends a message to each task. In the case of more application tasks, if the mailbox is used for communication, a large number of invalid operations will be caused, and programming will become cumbersome. Therefore, message queues are used in the monitor task to implement message transmission with each application task. Two mailboxes are set in each application task, one for sending messages to the monitor message queue and one for receiving messages sent by the monitor task message queue. When an application task is executing an error, the OSQPost() function is called to send a message to the monitor task message queue. The monitor task reads the message from the message queue by calling the OSQPend() function, and then calls the OSMboxPost() function to the application. The message receiving mailbox of the task sends a message representing a different meaning, and the task calls the OSMboxPend() function to read the message from the mailbox and perform the corresponding operation.

3.2 Implementation of the multitasking software watchdog

The multitasking watchdog monitors the operational status of each task by checking whether each application task "feeds a soft dog" within a specified time. With the microprocessor's timer interrupt mechanism, a timing unit and a run flag are assigned to each task, and the timer interrupt is independently timed according to the status of the running flag. When a task in the system is idle, periodically “feed the soft dog” at a time interval smaller than the “feed soft dog” setting; when the task is executed, it is expected to perform the longest time required, and use The timer parameter in the monitor is set slightly longer than the maximum time-consuming interval, and the periodic "feed soft dog" module is interrupted, and the timer in the monitor task is counted down. When the task is normally executed, send a signal to "feed soft dog", clear the timer, reset the task, and resume the periodic "feed soft dog" module; when the task execution is abnormal, it cannot be set. The software watchdog is cleared during the time interval, causing the corresponding timer in the monitor to overflow. The monitor task sends an instruction through the kernel service, points the stack address of the task to its starting address, restarts the task, and accumulates the task. The number of resets, clear the timer of the task.

4 Conclusion

Combined with the LPC2132 built-in hardware watchdog and uC/OS-II operating system, a software watchdog capable of multitasking management is designed. The watchdog can not only effectively monitor various application tasks, but also can affect other applications. In the case of normal operation of the task, the task is restarted until the system is restarted after multiple restarts are invalid, and the purpose of mutually independent application tasks is not excessively restrained. In addition, the watchdog can also automatically restart when the main program and hardware problems, to ensure that the system runs stably for a long time.

ZGAR AZ Vape Pods 5.0S

ZGAR AZ Vape Pods 5.0S

ZGAR electronic cigarette uses high-tech R&D, food grade disposable pod device and high-quality raw material. All package designs are Original IP. Our designer team is from Hong Kong. We have very high requirements for product quality, flavors taste and packaging design. The E-liquid is imported, materials are food grade, and assembly plant is medical-grade dust-free workshops.

From production to packaging, the whole system of tracking, efficient and orderly process, achieving daily efficient output. WEIKA pays attention to the details of each process control. The first class dust-free production workshop has passed the GMP food and drug production standard certification, ensuring quality and safety. We choose the products with a traceability system, which can not only effectively track and trace all kinds of data, but also ensure good product quality.



We offer best price, high quality Pods, Pods Touch Screen, Empty Pod System, Pod Vape, Disposable Pod device, E-cigar, Vape Pods to all over the world.

Much Better Vaping Experience!




ZGAR AZ Pods 5.0S Pods,ZGAR AZ Vape Pods 5.0S,ZGAR AZ Vape Pods 5.0S Pod System Vape,ZGAR AZ Vape Pods 5.0S Disposable Pod Vape Systems

Zgar International (M) SDN BHD , https://www.zgarpods.com

This entry was posted in on