CN101561778A - Method for detecting task closed loop of multi-task operating system - Google Patents

Method for detecting task closed loop of multi-task operating system Download PDF

Info

Publication number
CN101561778A
CN101561778A CN 200810066643 CN200810066643A CN101561778A CN 101561778 A CN101561778 A CN 101561778A CN 200810066643 CN200810066643 CN 200810066643 CN 200810066643 A CN200810066643 A CN 200810066643A CN 101561778 A CN101561778 A CN 101561778A
Authority
CN
China
Prior art keywords
task
monitoring
high priority
pitching pile
code
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
Application number
CN 200810066643
Other languages
Chinese (zh)
Other versions
CN101561778B (en
Inventor
廖通
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN 200810066643 priority Critical patent/CN101561778B/en
Publication of CN101561778A publication Critical patent/CN101561778A/en
Application granted granted Critical
Publication of CN101561778B publication Critical patent/CN101561778B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method for detecting task closed loop of a multi-task operating system, comprising the following steps: embedding piling code in task inlet function loop bodies, and measuring whether the task is in closed loop state accurately in real time by determining the piling value of the monitored task, the task operation state and the total CPU occupancy factor in the monitoring task of high priority. The invention is accurate, reliable and efficient and is easy to realize by embedding the piling code in the loop body inlet of the task to be monitored; if the system counts the CPU occupancy rate through the monitoring task of high priority, the piling code determining the closed loop can be added to the monitoring task for counting the CPU occupancy rate, thereby greatly utilizing the system resources; the piling code can be defined as macro which is embedded at the inlet of the task loop body, thus the invention can be realized flexibly.

Description

A kind of method that detects the multiple task operating system task closed loop
Technical field
The invention belongs to the multiple task operating system field, be specifically related to a kind of method that detects the multiple task operating system task closed loop.
Background technology
In computer software, all adopted the multiple task operating system of certain form basically, all application and function all are by the task carrying, and under the multitask cooperation, finish.Because system applies is complicated day by day, the number of tasks of multiple task operating system is more and more, the running status of task is the important effect of play more and more in the cooperation of multitask, software is in the process of exploitation, owing to such-and-such reason, endless loop may take place in task, and then can not handle other message, if Mission Monitor method efficiently can be provided accurately, will be beneficial to research staff's location greatly.
In present operating system, the method for existing endless loop monitoring mainly contains two classes:
One class is: utilize the clock that the communication debug system provides or start a hardware timer, the Interrupt Service Routine of timer or clock is constantly monitored each task to processing time of message separately, judge the operation of extraordinary time of certain task or processing time of certain message is surpassed the threshold value of regulation, just think that endless loop has taken place this task, to interrupt context then and switch to task context, and in the task context of system, transfer and read call stack function and output.The major defect of the method is to use hardware timer or clock, needs extra hardware resource, and can only detect at the task that the message accepted is arranged, and has big limitation, representational patent such as CN02128400.
Another kind ofly be: the storage unit that sets in advance the recording operation essential information, start a detection task, the timer expiry that each detection task is provided with, that will preserve last executable operations task before the current point in time is identified to the storage unit the inside, if the sign of certain task continuous appear at the storage unit the inside, think that then endless loop has taken place this task, but this is a kind of method of adopting a little, accuracy is lower, and needs extra storage space, representational patent such as CN03121092.
Summary of the invention
The objective of the invention is to overcome the deficiencies in the prior art, a kind of method that detects the multiple task operating system task closed loop is provided.This method embeds the pitching pile code in each task entrance function loop body, can accurate in real time measuring task whether be in the endless loop state by pitching pile value, task run state and the total CPU usage of judging monitored task in the monitoring task of high priority.
For solving the problems of the technologies described above, the present invention is achieved by the following technical solutions:
A kind of method that detects the multiple task operating system task closed loop comprises the steps:
A. embed the pitching pile code in the loop body porch of all need monitoring of tasks, and predesignate the threshold value of the total CPU occupation rate of threshold value and system of the endless loop state of the task of needing monitoring; Described pitching pile code is the code that the task statistical variable is increased progressively;
B., high priority system monitoring task is set, starts and initialization; Whether pitching pile value size, the pitching pile value that described high priority system monitoring task is used to monitor the task of each needs monitoring change, current whether be whether the total CPU occupation rate of running status, system above the threshold value of predesignating;
C. high priority system monitoring task regularly detects the pitching pile value that each needs the task of monitoring;
D. judge whether each need monitoring of task endless loop has taken place: in high priority system monitoring task, by detecting the task that each need be monitored successively to the low priority order from high priority, if it is non-vanishing to need the task of monitoring to satisfy its pitching pile value, the pitching pile value is constant, current is running status, and the total CPU occupation rate of system surpasses four conditions of threshold value of predesignating, judge that then this need monitoring of task is in first state (promptly approximate endless loop state), if N continuous time detection is all judged this need monitoring of task and is in first state and the N threshold value smaller or equal to the endless loop state of predesignating, then endless loop does not take place in the task of this needs monitoring, returns step C; If N continuous time detection all judges this need monitoring of task and be in first state and the N threshold value greater than the endless loop state of predesignating, endless loop has taken place in then should needs monitoring of task, enters step e;
E. export the endless loop abnormal information.
Among the described step D, if need the task of monitoring not satisfy described four conditions, then the task of this needs monitoring is not in first state, and it is in the number of times zero clearing of first state, returns step C.
Among the described step B, if system adds up CPU usage by the monitoring task of high priority, the then described high priority system monitoring task that is provided with is to create a high priority system monitoring task; If system adds up CPU usage by the monitoring task of high priority, then describedly be provided with in the monitoring task that high priority system monitoring task is the pitching pile code that will the judge endless loop statistical method that appends to the CPU occupation rate and CPU occupation rate statistics is carried out synchronously.
The pitching pile code is the same for its code of task of different needs monitoring in the described steps A.
Further, described pitching pile code is grand.
Use the method for detection multiple task operating system task closed loop of the present invention to have following beneficial effect: the inventive method embeds the pitching pile code by the loop body porch in all need monitoring of tasks, not only accurately and reliably, efficiently, and implementation method is simple; If system adds up CPU usage by the monitoring task of high priority, the pitching pile code of judging endless loop can be appended in the monitoring task of statistical method of CPU occupation rate, carry out synchronously with CPU occupation rate statistics, can utilize system resource greatly like this, the pitching pile code can be defined as grand, only need embed that this is grand just passable in the porch of task loop body, implement comparatively flexible.
Description of drawings
Fig. 1 is the process flow diagram of the inventive method.
Embodiment
In order to understand the present invention better, the present invention is done to describe further below in conjunction with the drawings and specific embodiments.
In multiple task operating system, consider that each task all includes a loop body, when rescheduling this task by system kernel at every turn, the capital re-executes the code in the loop body, if add a statistical variable in the porch of loop body, every execution once, value increases progressively, each like this rescheduling when carrying out this task, the value of statistical variable will increase progressively.If this task generation endless loop, because this task is always in running status, the value of statistical variable then begins just to have remained unchanged beginning to take place endless loop always so, utilizes this characteristic of task entity just can be used for the detection task whether endless loop has taken place.Surpassed the threshold value of predesignating if judge the statistical variable value time non-vanishing and that the statistical variable value is constant of task, the task that just illustrated was carried out, and was not scheduled again.But can't conclude whether endless loop takes place, be switched to other task because also might be, so whether need this task of further decision current is running status, and the total CPU occupation rate of system surpasses the threshold value of predesignating and comes the identification task that endless loop has taken place, can guarantee task so always in running status and did not switch away, thereby endless loop has taken place in judgement accurately.
The pitching pile code is exactly the code that a task statistical variable is increased progressively in fact, code itself is very simple, and also is identical to the task of different needs monitoring, can be defined as grand, because the stationkeeping of code is in the loop body porch of task, so be referred to as the pitching pile code.
The 3G system is made up of a plurality of embedded systems, is the example explanation with one of them veneer embedded system here, and this system uses PPC755CPU and VXWORKS operating system.
See also Fig. 1, the grand TASKDEADLOOP_CALL of pitching pile is joined before the first statement of all the task while loop bodies that need monitor task closed loop earlier, use the reserved field spare4 of VXWORKS operating system TCB to preserve the pitching pile value, the TASKDEADLOOP_CALL macro definition is:
#define?TASKDEADLOOP_CALL{
Get current task TCB;
Reserved field spare4 numerical value among the TCB is increased progressively.
}
High priority system monitoring task is set then, can create the periodic monitor task of a priority 30, if system adds up CPU usage by the monitoring task of high priority, then needn't create this task, can directly utilize having created of task, carry out synchronously with statistics CPU occupation rate, before task while circulation, will respectively need the reserved field spare4 zero clearing of monitor task TCB in the initialization, to judge that each task is in the times N zero clearing of first state (promptly approximate endless loop state), and will monitor task call taskDelay (2*SECONDTOTICK) when two seconds fixed response times are set; Handle below in task, doing:
1) obtain current system activity task list aiTaskIdList[TaskNum by system call taskIdListGet], TaskNum is current system activity task number;
2) task among the aiTaskIdList is according to priority established current system activity task list sequence number i=0 by high to low series arrangement, begin to travel through each task, forward 3 to);
3) judge simultaneously whether following four conditions are all set up, if set up, that just shows that task is in first state (promptly approximate endless loop state), changes 4 over to), otherwise change 7 over to);
The pitching pile value of task i is non-vanishing;
Value was the same when the pitching pile value of task i detected with last time;
Task i is current to be running status;
The total CPU usage of system surpasses the threshold value of predesignating;
4) N++ is if N judges then that greater than the threshold value of regulation endless loop has taken place this task, changes 5 over to), otherwise change 6 over to);
5) output endless loop task relevant information, debugging or resetting system;
6) i++ if i equals TaskNum, changes 8 over to), otherwise change 3 over to);
7) N=0 changes 8);
8) finish, wait for scheduling next time.
The above only is preferred embodiment of the present invention;, not should be pointed out that for the person of ordinary skill of the art in order to restriction the present invention; any modification of being done within every the spirit and principles in the present invention, be equal to and replace or improvement etc., all should be included within protection scope of the present invention.

Claims (5)

1. a method that detects the multiple task operating system task closed loop is characterized in that, comprises the steps:
A. embed the pitching pile code in the loop body porch of all need monitoring of tasks, and predesignate the threshold value of the total CPU occupation rate of threshold value and system of the endless loop state of the task of needing monitoring; Described pitching pile code is the code that the task statistical variable is increased progressively;
B., high priority system monitoring task is set, starts and initialization; Whether pitching pile value size, the pitching pile value that described high priority system monitoring task is used to monitor the task of each needs monitoring change, current whether be whether the total CPU occupation rate of running status, system above the threshold value of predesignating;
C. high priority system monitoring task regularly detects the pitching pile value that each needs the task of monitoring;
D. judge whether each need monitoring of task endless loop has taken place: in high priority system monitoring task, by detecting the task that each need be monitored successively to the low priority order from high priority, if it is non-vanishing to need the task of monitoring to satisfy its pitching pile value, the pitching pile value is constant, current is running status, and the total CPU occupation rate of system surpasses four conditions of threshold value of predesignating, judge that then this need monitoring of task is in first state, if N continuous time detection is all judged this need monitoring of task and is in first state and the N threshold value smaller or equal to the endless loop state of predesignating, then endless loop does not take place in the task of this needs monitoring, returns step C; If N continuous time detection all judges this need monitoring of task and be in first state and the N threshold value greater than the endless loop state of predesignating, endless loop has taken place in then should needs monitoring of task, enters step e;
E. export the endless loop abnormal information.
2. the method for detection multiple task operating system task closed loop according to claim 1, it is characterized in that, among the described step D, if need the task of monitoring not satisfy described four conditions, then the task of this needs monitoring is not in first state, it is in the number of times zero clearing of first state, returns step C.
3. the method for detection multiple task operating system task closed loop according to claim 1 and 2, it is characterized in that, among the described step B, if system adds up CPU usage by the monitoring task of high priority, the then described high priority system monitoring task that is provided with is to create a high priority system monitoring task; If system adds up CPU usage by the monitoring task of high priority, then describedly be provided with in the monitoring task that high priority system monitoring task is the pitching pile code that will the judge endless loop statistical method that appends to the CPU occupation rate and CPU occupation rate statistics is carried out synchronously.
4. the method for detection multiple task operating system task closed loop according to claim 3 is characterized in that, the pitching pile code is the same for its code of task of different needs monitoring in the described steps A.
5. the method for detection multiple task operating system task closed loop according to claim 4 is characterized in that, described pitching pile code is grand.
CN 200810066643 2008-04-15 2008-04-15 Method for detecting task closed loop of multi-task operating system Active CN101561778B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200810066643 CN101561778B (en) 2008-04-15 2008-04-15 Method for detecting task closed loop of multi-task operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200810066643 CN101561778B (en) 2008-04-15 2008-04-15 Method for detecting task closed loop of multi-task operating system

Publications (2)

Publication Number Publication Date
CN101561778A true CN101561778A (en) 2009-10-21
CN101561778B CN101561778B (en) 2012-12-19

Family

ID=41220591

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200810066643 Active CN101561778B (en) 2008-04-15 2008-04-15 Method for detecting task closed loop of multi-task operating system

Country Status (1)

Country Link
CN (1) CN101561778B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN102063361A (en) * 2010-12-28 2011-05-18 四川长虹电器股份有限公司 Method for reducing probability of dead halt of embedded software
CN103257898A (en) * 2012-02-15 2013-08-21 北京邦天信息技术有限公司 Resource allocation method and system in embedded system
WO2014161373A1 (en) * 2013-04-01 2014-10-09 中兴通讯股份有限公司 System fault detection and processing method, device, and computer readable storage medium
CN104391754A (en) * 2014-10-13 2015-03-04 北京星网锐捷网络技术有限公司 Method and device for processing task exception
CN106528318A (en) * 2016-11-29 2017-03-22 迈普通信技术股份有限公司 Thread endless loop detection method and device
CN106648946A (en) * 2016-10-09 2017-05-10 武汉斗鱼网络科技有限公司 Method and system for quickly shielding client fault based on instrumentation mode
CN111708670A (en) * 2020-06-10 2020-09-25 中国第一汽车股份有限公司 Method and device for determining task time parameters in real-time operating system and vehicle

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN102063361A (en) * 2010-12-28 2011-05-18 四川长虹电器股份有限公司 Method for reducing probability of dead halt of embedded software
CN103257898A (en) * 2012-02-15 2013-08-21 北京邦天信息技术有限公司 Resource allocation method and system in embedded system
US9720761B2 (en) 2013-04-01 2017-08-01 Zte Corporation System fault detection and processing method, device, and computer readable storage medium
WO2014161373A1 (en) * 2013-04-01 2014-10-09 中兴通讯股份有限公司 System fault detection and processing method, device, and computer readable storage medium
CN104102572A (en) * 2013-04-01 2014-10-15 中兴通讯股份有限公司 Method and device for detecting and processing system faults
CN104391754B (en) * 2014-10-13 2017-08-25 北京星网锐捷网络技术有限公司 A kind of processing method and processing device of task abnormity
CN104391754A (en) * 2014-10-13 2015-03-04 北京星网锐捷网络技术有限公司 Method and device for processing task exception
CN106648946A (en) * 2016-10-09 2017-05-10 武汉斗鱼网络科技有限公司 Method and system for quickly shielding client fault based on instrumentation mode
CN106648946B (en) * 2016-10-09 2019-06-21 武汉斗鱼网络科技有限公司 Method and system based on pitching pile mode Rapid shielding client failure
CN106528318A (en) * 2016-11-29 2017-03-22 迈普通信技术股份有限公司 Thread endless loop detection method and device
CN106528318B (en) * 2016-11-29 2020-02-04 迈普通信技术股份有限公司 Thread dead loop detection method and device
CN111708670A (en) * 2020-06-10 2020-09-25 中国第一汽车股份有限公司 Method and device for determining task time parameters in real-time operating system and vehicle

Also Published As

Publication number Publication date
CN101561778B (en) 2012-12-19

Similar Documents

Publication Publication Date Title
CN101561778B (en) Method for detecting task closed loop of multi-task operating system
US9304811B2 (en) Methods and systems to identify and migrate threads among system nodes based on system performance metrics
JP5888629B2 (en) Method, apparatus and system for scheduling processor cores in a multiprocessor core system
CN1828544B (en) Mechanism to exploit synchronization overhead to improve multithreaded performance
US8495652B2 (en) IT system behavior measurement and analysis system and method thereof
US9032375B2 (en) Performance bottleneck identification tool
CN106713396B (en) Server scheduling method and system
CN106528318B (en) Thread dead loop detection method and device
CN103810035A (en) Intelligent context management
CN101853191B (en) Method for detecting task endless loop in operating system and operating system
CN103793205A (en) Selective poisoning of data during runahead
US20140013091A1 (en) Causing an interrupt based on event count
CN103645961A (en) Anomaly detection method and system for calculating intensive parallel tasks
CN102622300B (en) Infinite loop or similar infinite loop detection method in multitask system
CN106844103B (en) Non-volatile processor spare capacity setting, Memory Backup method and system
Duffy et al. An experimental comparison of event driven and multi-threaded sensor node operating systems
CN110457133A (en) A kind of processing method and system of operating-system resources exception
CN114138341A (en) Scheduling method, device, program product and chip of micro-instruction cache resources
US20060080660A1 (en) System and method for disabling the use of hyper-threading in the processor of a computer system
US7971190B2 (en) Machine learning performance analysis tool
Sawalha et al. Thread scheduling for heterogeneous multicore processors using phase identification
CN102817727B (en) Embedded real-time control method and embedded real-time control device of diesel generating set
CN101149702A (en) Operating system failure testing method and device
US11847041B2 (en) System and method for probe injection for code coverage
CN100407133C (en) Method and system for branch prediction

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant