CN101561778B - 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
CN101561778B
CN101561778B CN 200810066643 CN200810066643A CN101561778B CN 101561778 B CN101561778 B CN 101561778B CN 200810066643 CN200810066643 CN 200810066643 CN 200810066643 A CN200810066643 A CN 200810066643A CN 101561778 B CN101561778 B CN 101561778B
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.)
Active
Application number
CN 200810066643
Other languages
Chinese (zh)
Other versions
CN101561778A (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

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 to carry through task, and under the multitask cooperation, accomplish.Because system applies is complicated day by day, the number of tasks of multiple task operating system is more and more, and 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 types:
One type 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 surpassed the threshold value of regulation; Just think that endless loop has taken place this task, will interrupt context then and switch to task context, 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 the additional hardware resource, and can only have big limitation, representational patent such as CN02128400 to there being the task of the message accepted to detect.
Another kind ofly be: the storage unit of recording operation essential information is set in advance, starts a detection task, the timer expiry that detection task at every turn 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 deficiency of 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, in the monitoring task of high priority, can accurate in real time measuring task whether be in the endless loop state through pitching pile value, task run state and the total CPU usage of judging monitored task.
For solving the problems of the technologies described above, the present invention realizes through following technical scheme:
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; Said 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 said 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, and 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 all judges this need monitoring of task and be in first state and the N threshold value smaller or equal to the endless loop state of predesignating, endless loop does not take place in then should needs monitoring of task, 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, the entering step e in then should needs monitoring of task;
E. export the endless loop abnormal information.
Among the said 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 said step B, if system adds up CPU usage through the monitoring task of high priority, the then said high priority system monitoring task that is provided with is to create a high priority system monitoring task; If system adds up CPU usage through the monitoring task of high priority; The then said high priority system monitoring task that is provided with is to append in the monitoring task of statistical method of CPU occupation rate the pitching pile code of judging endless loop 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 said steps A.
Further, said 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 through 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 through the monitoring task of high priority; Can pitching pile code that judge endless loop 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 accompanying drawing and specific embodiment.
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 code in the loop body is carried out in the capital again; 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 of just having explained 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 predesignate and comes the identification task that endless loop has taken place, and 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 PPC755 CPU and VXWORKS operating system.
See also Fig. 1; Elder generation joins the grand TASKDEADLOOP_CALL of pitching pile before the first statement of all the task while loop bodies that need monitor task closed loop; 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 through 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, will judge that each task is in the times N zero clearing of first state (promptly being similar to the 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] through 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 6);
8) finish, wait for scheduling next time.
The above is merely 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 spirit of the present invention and the principle, be equal to replacement 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; Said 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 said high priority system monitoring task is used to monitor the task of each needs monitoring change, current whether be the total CPU occupation rate of running status, system whether above the threshold value of predesignating, said pitching pile value is the value of task statistical variable;
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, and 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, be in first state and the N threshold value smaller or equal to the endless loop state of predesignating if this need monitoring of task is all judged in N continuous time detection, endless loop does not take place in then should needs monitoring of task; If the task of this needs monitoring is last task in the current system activity task list, then return 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, the entering step e in then should needs monitoring of task;
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 said 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, if the task of this needs monitoring is last task in the current system activity task list, then 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 said step B; If system adds up CPU usage through the monitoring task of high priority, the then said high priority system monitoring task that is provided with is to create a high priority system monitoring task; If system adds up CPU usage through the monitoring task of high priority; The then said high priority system monitoring task that is provided with is to append in the monitoring task of statistical method of CPU occupation rate the pitching pile code of judging endless loop 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 said steps A.
5. the method for detection multiple task operating system task closed loop according to claim 4 is characterized in that, said 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 CN101561778A (en) 2009-10-21
CN101561778B true 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)

Families Citing this family (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
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
CN106648946B (en) * 2016-10-09 2019-06-21 武汉斗鱼网络科技有限公司 Method and system based on pitching pile mode Rapid shielding client failure
CN106528318B (en) * 2016-11-29 2020-02-04 迈普通信技术股份有限公司 Thread dead loop detection method and device
CN111708670B (en) * 2020-06-10 2023-05-09 中国第一汽车股份有限公司 Method and device for determining task time parameters in real-time operation system and vehicle

Also Published As

Publication number Publication date
CN101561778A (en) 2009-10-21

Similar Documents

Publication Publication Date Title
CN101561778B (en) Method for detecting task closed loop of multi-task operating system
CN106257411B (en) Single instrction multithread calculating system and its method
US9304811B2 (en) Methods and systems to identify and migrate threads among system nodes based on system performance metrics
JP5463885B2 (en) Batch job processing time estimation program, method and apparatus
US8566803B2 (en) Benchmark profiling for distributed systems
CN106713396B (en) Server scheduling method and system
CN109388537B (en) Operation information tracking method and device and computer readable storage medium
CN101278265A (en) Profiling using user-level control mechanism
US20120278594A1 (en) Performance bottleneck identification tool
CN106528318B (en) Thread dead loop detection method and device
CN102736897B (en) The thread of multiple threads is selected
CN104572290A (en) Method and device for controlling message processing threads
CN106980533B (en) Task scheduling method and device based on heterogeneous processor and electronic equipment
CN103744772A (en) Method and system for detecting task running performance
CN103793205A (en) Selective poisoning of data during runahead
US10083066B2 (en) Processing data by using simultaneous multithreading
CN113849296A (en) Apparatus and method for closed loop dynamic resource allocation control framework
CN103645961A (en) Anomaly detection method and system for calculating intensive parallel tasks
CN111382026A (en) Caton monitoring method, device, system, storage medium and computer equipment
Shoukourian et al. Predicting energy consumption relevant indicators of strong scaling hpc applications for different compute resource configurations
CN103154919A (en) Exception control in a multiprocessor system
CN114138341B (en) Micro instruction cache resource scheduling method, micro instruction cache resource scheduling device, program product and chip
US9563494B2 (en) Systems and methods for managing task watchdog status register entries
CN102495793B (en) Method for detecting endless loop task
US20060080660A1 (en) System and method for disabling the use of hyper-threading in the processor of a computer system

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