CN110968448A - Method for monitoring multitask running state - Google Patents
Method for monitoring multitask running state Download PDFInfo
- Publication number
- CN110968448A CN110968448A CN201911216817.1A CN201911216817A CN110968448A CN 110968448 A CN110968448 A CN 110968448A CN 201911216817 A CN201911216817 A CN 201911216817A CN 110968448 A CN110968448 A CN 110968448A
- Authority
- CN
- China
- Prior art keywords
- task
- surv
- value
- monitoring
- 0xff
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 26
- 238000012544 monitoring process Methods 0.000 title claims abstract description 25
- 241000282472 Canis lupus familiaris Species 0.000 claims description 27
- 238000012840 feeding operation Methods 0.000 claims description 16
- 230000002159 abnormal effect Effects 0.000 claims description 10
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/3006—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0751—Error or fault detection not based on redundancy
- G06F11/0754—Error or fault detection not based on redundancy by exceeding limits
- G06F11/0757—Error or fault detection not based on redundancy by exceeding limits by exceeding a time limit, i.e. time-out, e.g. watchdogs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1438—Restarting or rejuvenating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
A method of monitoring the operational status of a plurality of tasks, the method comprising the steps of: defining a one-dimensional array of N Task elements as a global variable Task _ Surv [ N ]; (N is a positive integer and N >1) in the initialization Task, performing initial value 0xFF operation on each element in the defined global variable array Task _ Surv; in the continuously scheduled tasks, only assigning 0xFF operation to one element Task _ Surv [ i ] (i is a corresponding Task number and takes any integer from 0 to N-1) in the global variable array Task _ Surv; the task scheduler schedules each task according to the priority order; monitoring operation is added in the interrupt service program, and when the interrupt is executed once, the task is monitored once.
Description
Technical Field
The invention relates to the technical field of task monitoring, in particular to a method for monitoring a multitask running state.
Background
In the running process of a multitask operating system, in order to ensure the reliable running of the system, the running state of each task is usually monitored, abnormal conditions possibly caused in the running process of the task, such as 'running away', 'entering dead loop', 'being hung up abnormally' and the like, are responded in time, measures such as software reset or hardware reset are implemented, and the system enters a normal running state after being restarted.
The prior method is that only a dog feeding function is added in a single task, or the dog feeding function is added in all tasks, the dog feeding function is only simply met, but a good monitoring function cannot be achieved, and the restarting can be realized only if the tasks with the dog feeding function are abnormal. Therefore, unified management of dog feeding operation is not facilitated, specific abnormal task names or task numbers cannot be monitored, and certain difficulty is brought to code debugging.
Disclosure of Invention
In order to solve the above problems, the present invention provides a method for monitoring a multitask operation state, and the embodiment of the present invention discloses the following technical solutions:
a method of monitoring the operational status of a plurality of tasks, the method comprising the steps of:
defining a one-dimensional array of N Task elements as a global variable Task _ Surv [ N ]; (N is a positive integer and N >1)
In an initialization Task, performing initial value 0xFF operation on each element in a defined global variable array Task _ Surv;
in the continuously scheduled tasks, only assigning 0xFF operation to one element Task _ Surv [ i ] (i is a corresponding Task number and takes any integer from 0 to N-1) in the global variable array Task _ Surv;
the task scheduler schedules each task according to the priority order;
monitoring operation is added in the interrupt service program, and when the interrupt is executed once, the task is monitored once.
In a first possible implementation manner, the initialization task includes: initializing the array Task _ Surv, feeding dogs, creating and starting tasks, and starting interrupts.
In a second possible implementation, the dog feeding operation may be performed by and only by the interrupt service routine that initializes the task and adds task monitoring functionality.
In a third possible implementation manner, the adding of the monitoring operation in the interrupt service routine includes performing a one-down operation, a non-zero determination, and a dog feeding operation on each element, and specifically includes the following steps:
judging whether the numerical value of the array Task _ Surv [ i ] is nonzero after being subjected to subtraction operation, if the numerical value is nonzero, performing a normal Task, and performing a dog feeding operation; (i is the corresponding task number, and takes any integer from 0 to N-1)
If the numerical value is zero, judging the task to be an abnormal task, outputting a task number i value, stopping the dog feeding operation, and restarting the system.
In a fourth possible implementation manner, the method further includes that when the interrupt service program is abnormal, the dog feeding operation is interrupted, and the system is restarted.
In a fifth possible implementation manner, when the task is an exception task, the method specifically includes:
the value of the Task _ Surv [ i ] is not assigned with the maximum value of 0xFF, and the operation of subtracting one is carried out until the value of the Task _ Surv [ i ] is subtracted to 0, the value of i is output, the feeding of dogs is stopped, and the system is restarted;
when a normal Task is present, the value of Task _ Surv [ i ] is written to the maximum value of 0 xFF.
In a sixth possible implementation, the maximum value of 0xFF may be replaced with the WORD type assignment of 0 xFFFF.
Therefore, the invention defines a plurality of tasks into a one-dimensional array as a global variable, performs initialization processing, scheduling and monitoring on the one-dimensional array, can output the value of the task number i when the tasks are abnormal, and can realize monitoring of a plurality of continuously scheduled tasks.
Drawings
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
Fig. 1 is a flowchart illustrating a method for monitoring a multitask operation state.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, a method for monitoring a multitask operation state includes the steps of:
s1, defining a one-dimensional array of N Task elements as a global variable Task _ Surv [ N ]; (N is a positive integer and N >1)
S2, in the initialization Task, performing an initial value 0xFF operation on each element in the defined global variable array Task _ Surv, where Task _ Surv [ i ] ═ 0 xFF;
s3, in the continuously scheduled tasks, only assigning 0xFF operation to one element Task _ Surv [ i ] (i is a corresponding Task number and takes a value from 0 to N-1) in the global variable array Task _ Surv;
s4, the task scheduler schedules each task according to the priority order;
s5, adding a monitoring operation to the interrupt service routine, and monitoring the task once when the interrupt is executed once. The interrupt time may be determined based on the urgency of task monitoring.
The S2 initialization tasks at least include: and initializing the array Task _ Surv, feeding dogs, creating and starting tasks, opening interrupts and the like.
Adding the dog feeding operation in the interrupt service routine in the step S5 includes: only the initialization task and the interrupt service program added with the task monitoring function can execute the dog feeding operation, and other tasks or interrupt service programs cannot execute the dog feeding operation.
The method for adding the monitoring operation in the interrupt service program comprises the following steps of performing one-reduction operation, non-zero judgment and dog feeding operation on each element:
judging whether the numerical value of the array Task _ Surv [ i ] is nonzero after being subjected to subtraction operation, if the numerical value is nonzero, performing a normal Task, and performing a dog feeding operation; (i is the corresponding task number, and takes any integer from 0 to N-1)
If the numerical value is zero, judging the task to be an abnormal task, outputting a task number i value, stopping the dog feeding operation, and restarting the system.
When the task is an abnormal task, the method specifically comprises the following steps: and the value of the Task _ Surv [ i ] is not assigned with the maximum value of 0xFF, and the operation of subtracting one is carried out until the value of the Task _ Surv [ i ] is subtracted to 0, the value of i is output, the feeding of the dog is stopped, and the system is restarted.
When a normal Task is present, the value of Task _ Surv [ i ] is written to the maximum value of 0 xFF.
The assignment of Task _ Surv [ i ] will affect the decision time, and if the real-time requirement is higher, the assignment of Task _ Surv [ i ] can be reduced appropriately. For tasks that run regularly, such as only once a day, it can also be monitored, as long as the initial value of Task _ Surv [ i ] is increased in the corresponding Task, and if 0xFF is not enough, the data type can be changed, such as changing to WORD type assignment 0xFFFF, as long as it is ensured that Task _ Surv [ i ] is not decreased to 0 within the scheduling interval time.
If the program exception causes that the interrupt service program can not be normally executed, the dog feeding operation can not be continuously carried out, and the system is restarted.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (7)
1. A method for monitoring a multitask operation state, the method comprising the steps of:
defining a one-dimensional array of N Task elements as a global variable Task _ Surv [ N ]; (N is a positive integer and N >1)
In an initialization Task, performing initial value 0xFF operation on each element in a defined global variable array Task _ Surv;
in the continuously scheduled tasks, only assigning 0xFF operation to one element Task _ Surv [ i ] (i is a corresponding Task number and takes any integer from 0 to N-1) in the global variable array Task _ Surv;
the task scheduler schedules each task according to the priority order;
monitoring operation is added in the interrupt service program, and when the interrupt is executed once, the task is monitored once.
2. The method of claim 1, wherein the initialization task comprises: initializing the array Task _ Surv, feeding dogs, creating and starting tasks, and starting interrupts.
3. The method of claim 1 wherein the watchdog operation is performed by and only by interrupt service routines during initialization of the task and addition of the task monitoring function.
4. The method as claimed in claim 1, wherein the adding of the monitoring operation in the interrupt service routine includes performing a one-down operation, a non-zero determination, and a dog feeding operation for each element, and includes the steps of:
judging whether the numerical value of the array Task _ Surv [ i ] is nonzero after being subjected to subtraction operation, if the numerical value is nonzero, performing a normal Task, and performing a dog feeding operation; (i is the corresponding task number, and takes any integer from 0 to N-1)
If the numerical value is zero, judging the task to be an abnormal task, outputting a task number i value, stopping the dog feeding operation, and restarting the system.
5. The method of claim 4, further comprising interrupting the feeding of the dog and restarting the system when the interrupt service routine is abnormal.
6. The method as claimed in claim 4, wherein the task is an exception task, and the method comprises:
the value of the Task _ Surv [ i ] is not assigned with the maximum value of 0xFF, and the operation of subtracting one is carried out until the value of the Task _ Surv [ i ] is subtracted to 0, the value of i is output, the feeding of dogs is stopped, and the system is restarted;
when a normal Task is present, the value of Task _ Surv [ i ] is written to the maximum value of 0 xFF.
7. The method of claim 5, wherein a maximum value of 0xFF can be replaced with a WORD type assignment of 0 xFFFF.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911216817.1A CN110968448B (en) | 2019-12-03 | 2019-12-03 | Method for monitoring multi-task running state |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911216817.1A CN110968448B (en) | 2019-12-03 | 2019-12-03 | Method for monitoring multi-task running state |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110968448A true CN110968448A (en) | 2020-04-07 |
CN110968448B CN110968448B (en) | 2023-11-28 |
Family
ID=70032731
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911216817.1A Active CN110968448B (en) | 2019-12-03 | 2019-12-03 | Method for monitoring multi-task running state |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110968448B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114416408A (en) * | 2021-12-13 | 2022-04-29 | 飞腾信息技术有限公司 | Interrupt processing method and device |
CN114510495A (en) * | 2022-04-21 | 2022-05-17 | 北京安华金和科技有限公司 | Database service data consistency processing method and system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101937371A (en) * | 2010-08-27 | 2011-01-05 | 北京星网锐捷网络技术有限公司 | Method and device for monitoring task execution state in embedded system |
US20160188363A1 (en) * | 2014-12-25 | 2016-06-30 | Alibaba Group Holding Limited | Method, apparatus, and device for managing tasks in multi-task interface |
-
2019
- 2019-12-03 CN CN201911216817.1A patent/CN110968448B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101937371A (en) * | 2010-08-27 | 2011-01-05 | 北京星网锐捷网络技术有限公司 | Method and device for monitoring task execution state in embedded system |
US20160188363A1 (en) * | 2014-12-25 | 2016-06-30 | Alibaba Group Holding Limited | Method, apparatus, and device for managing tasks in multi-task interface |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114416408A (en) * | 2021-12-13 | 2022-04-29 | 飞腾信息技术有限公司 | Interrupt processing method and device |
CN114510495A (en) * | 2022-04-21 | 2022-05-17 | 北京安华金和科技有限公司 | Database service data consistency processing method and system |
CN114510495B (en) * | 2022-04-21 | 2022-07-08 | 北京安华金和科技有限公司 | Database service data consistency processing method and system |
Also Published As
Publication number | Publication date |
---|---|
CN110968448B (en) | 2023-11-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8612986B2 (en) | Computer program product for scheduling ready threads in a multiprocessor computer based on an interrupt mask flag value associated with a thread and a current processor priority register value | |
CN106557369B (en) | Multithreading management method and system | |
CN110968448A (en) | Method for monitoring multitask running state | |
CN108536531B (en) | Task scheduling and power management method based on single chip microcomputer | |
CN109558227B (en) | Monotonic rate task scheduling method based on task execution budget | |
CN111897637B (en) | Job scheduling method, device, host and storage medium | |
US20230409391A1 (en) | Thread priority adjusting method, terminal, and computer-readable storage medium | |
CN111209112A (en) | Exception handling method and device | |
CN112286847B (en) | Method, device and controller for improving response speed of system external interrupt | |
CN113986500A (en) | Task deterministic scheduling method and task diagnosis method in multi-task system | |
CN109947015B (en) | Task execution method and main controller | |
CN109684229B (en) | Chain dependency analysis method and system of directed acyclic graph | |
CN101937371A (en) | Method and device for monitoring task execution state in embedded system | |
JP2006227962A (en) | System and method for monitoring application task | |
CN114035928A (en) | Distributed task allocation processing method | |
JPH10269110A (en) | Method for avoiding hang-up of computer system, and computer system using the same method | |
CN111857689A (en) | Framework, function configuration method of framework, terminal and storage medium | |
JP5452427B2 (en) | Multi-operating system computer, multi-operating system management method, and multi-operating system management program | |
JP2004070582A (en) | Event notification task control processing system and method and its program | |
CN113656468B (en) | Task flow triggering method and device based on NIFI | |
CN111597016B (en) | System task time protection method, system, storage medium and terminal | |
CN106776202B (en) | Method and system for monitoring tasks of embedded operating system | |
KR100424458B1 (en) | Task management method for real time multitasking operation system | |
CN117687825A (en) | External watchdog monitoring method and device, electronic equipment and storage medium | |
JPH11282725A (en) | Computer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |