CN100353333C - Method for detecting dead circulation - Google Patents
Method for detecting dead circulation Download PDFInfo
- Publication number
- CN100353333C CN100353333C CNB031210929A CN03121092A CN100353333C CN 100353333 C CN100353333 C CN 100353333C CN B031210929 A CNB031210929 A CN B031210929A CN 03121092 A CN03121092 A CN 03121092A CN 100353333 C CN100353333 C CN 100353333C
- Authority
- CN
- China
- Prior art keywords
- endless loop
- bus
- circulation
- function
- current
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The present invention discloses a method for detecting dead circulation, which comprises the steps: A. setting a memory unit for recording the essential information of operation in advance; B. recording the essential information of the operation in the memory unit; testing whether the dead circulation occurs or not according to occurrence rules of the memory elements recorded in the memory unit, if the dead circulation occurs, then stop the corresponding operation of the dead circulation, else, return to step B. The method of the present invention can be used for effectively detecting the dead circulation which probably occurs in object references, function calls, operation sequences, etc. Therefore, the method effectively avoids system suspension caused by the dead circulation, and is reliable and practical.
Description
Technical field
The present invention relates to the object reference administrative skill, particularly about a kind of detection method of endless loop.
Background technology
The inventor is in publication number is 1503147 Chinese patent application, the disposal route of object relationship in a kind of database had once been proposed, this method is based on the administrative skill of the object reference that concerns bus, this technology makes all relation between objects can be summed up as adduction relationship, therefore, when having an object oA reference object oB, also may there be object oB reference object oA simultaneously; Object oA reference object oB perhaps appears, object oB reference object oC, and object oC is the situation of reference object oA again, and above quoting all is called circular reference.In object circular reference process, generally, the variation that oA can occur causes the variation of oB, the variation of oB and then cause the variation of oA again, and the variation of the oA that follows has caused the variation of oB again, thereby may cause producing endless loop.Seldom occur object circular reference situation in the application system, still,, the possibility that endless loop takes place is just arranged, just might cause system to produce gross error in case endless loop takes place, and then make system phenomenon occur hanging in case circular reference occurred.
In various SDK (Software Development Kit) or in the Software Development Platform of independently building, all provide the function of calling between the function, i.e. function f A call function fB, function f B call function fC, function f C is the situation of call function fA again, also endless loop might take place in such cases.
In the application of industry automatic control and artificial intelligence, relate to the sequence of operations step, in this operation steps sequence, the situation of endless loop also may appear.
More than based between quoting between the object, the function call and the industrial automation process in operation steps can be summed up as a kind of operation, all operations forms the sequence of operation in chronological order.
No matter be the operation in which kind of system, endless loop will produce very big harm to system in case take place, and gently then system makes mistakes, and heavy then system hangs or collapses.Therefore, how to detect the endless loop that circular reference produced between the object of system's generation in service, or call the endless loop of generation between the function, perhaps endless loop of the sequence of operation or the like, and handle a major issue that has also become application system development to consider effectively.
Summary of the invention
In view of this, the invention discloses a kind of detection method of endless loop, make it in the application system operational process, can in time detect the endless loop phenomenon that the sequence of operation takes place, and then avoid effectively and may hang by the system that endless loop causes.
A kind of detection method of endless loop, this method are to realize like this.
A. set in advance the storage unit of recording operation essential information;
B. in storage unit, write down the essential information of each operation, according to the occurrence law of the element that writes down in the current memory cell, formation is recalled detection to judge whether to occur endless loop according to standard endless loop parameter, if, then stop the operation of endless loop correspondence, otherwise, return step B.
Described steps A further comprises: the threshold value of storage element number in the storage unit is set,
Then before the recording operation essential information, this method further comprises:
Whether threshold value element number set in the element number of judging current record in the storage unit and the steps A equate, if equate, then removes in the storage unit element information of record at first, execution in step B, otherwise, direct execution in step B.
Described standard endless loop parameter comprises circulation possibility length maximal value, circulation may length minimum value and minimum cycle index.
Judge whether among the step B that endless loop occurring further comprises:
B1. whether judge minimum cycle index greater than 1, if greater than, be initial element with current record, execution in step B2, otherwise, determine the current endless loop that do not occur, finish then;
B2. from initial element, according to the reverse element that will compare of choosing of circulation possibility length;
Whether all elements of choosing among the B3. more described step B2 is equal, if equate, and execution in step B4, otherwise, determine the current endless loop that do not occur, finish then;
B4. judge and whether detect number of times less than circulation possibility minimum length, if less than, then setting first reverse element of current initial element is initial element, execution in step B2, otherwise, determine the current endless loop that occurs.
The essential information of operation described in the steps A concerns the essential information of bus message for process; Or the relevant information called of the interface function relevant with concerning bus; Or be and concern call relation between the irrelevant function of bus; Or be relation between the sequence of operation.
Described through concerning that the essential information of bus message comprises type of message and message parameter information.
The relevant information that the described interface function relevant with concerning bus calls comprises interface function name and function parameter information.
Described and concern that the call relation between the irrelevant function of bus comprises the function name that is called.
The described sequence of operation comprises operation steps title or code name.
This method further comprises: before stopping endless loop, judge whether to stop circulation according to current state, and the judged result notice is concerned bus, if do not stop circulation, then continue execution in step B, if stop circulation, concern that bus abandons current message, and empty storage unit.
Step B further comprises: when stopping endless loop, by call back function notice application system generation endless loop mistake.
The present invention is by each operation essential information is carried out record, and the rule of analytic record element appearance, quote or call situation so that in time detect the endless loop that may exist, and with this endless loop a situation arises in time notifies application system, handled by application system, thereby avoid effectively and may hang phenomenon by the system that endless loop causes, this method is reliable, practical.
Description of drawings
Fig. 1 is the schematic flow sheet of the specific embodiment of realization the inventive method.
Embodiment
Core concept of the present invention is: set in advance a storage unit; Extract the essential information of each operation in the various sequences of operation, and the information of extracting is recorded in the storage unit that sets in advance, the rule by element in the analyzing stored unit occurs judges whether to occur endless loop.
With through concerning that the message of bus or function are example, describe technical scheme of the present invention in detail below.
In the present embodiment, the method that detected object is quoted endless loop is: will rank through the related news that concern bus, and the message of queuing is monitored, thereby realize the endless loop that occurs in the object reference process is detected.The object that is cited will be notified those objects of quoting this object that is cited after having taken place to change, and handles so that these objects after this object that is cited changes, are made some responses.In the middle of the reality, the be cited interface function of object variation of the response that shows as the object reference reference object that is cited and provide is provided for this response, or the object that is cited sends a notification message to reference object.Because in concern the bus design model, more than the operation of notice reference object is by to concerning notification message of bus transmission, or realizes by the relevant interface function that the call relation bus provides.Therefore, for the detection of quoting the endless loop that may cause between the object, can perhaps, check the endless loop of object reference to the record that concerns the related notification message that bus interface is received by to concerning the be called record of situation of relevant interface function that bus provides.
For writing down the relevant information in each message, present embodiment at first is provided with a storage unit, and record is each through concerning the message of bus in chronological order, promptly stores in storage unit through concerning the message sequence of bus.For complexity and the speed up processing that reduces detection, the length maximal value of the message sequence of storing in this storage unit can be set, can only in limited message, carry out so that detect.Here, storage unit can be round-robin queue, also can be chained list.In the present embodiment, the storage unit of setting is formation.
Referring to shown in Figure 1, the specific implementation of present embodiment may further comprise the steps:
Step 102, concern bus record essential information, the essential information formation of a notice of formation through the notice of the object that concern bus.If the notifying operation between the object shows as reference object and the object and concern between the bus form that sends message mutually of being cited, then in the storage unit that sets in advance, write down the essential information of issuing the message that concerns bus, perhaps, record concerns the essential information of the message that bus is sent in the storage unit that sets in advance, form the essential information formation of a message, wherein, the essential information of message comprises type of message, message parameter information; If the notifying operation between the object shows as reference object or the object that is cited to concerning calling of interface function that bus provides, and, concern calling of interface function that bus provides reference object or the object that is cited, then the record reference object or the relevant information of object that be cited in the storage unit that sets in advance to concerning that interface function that bus provides calls, perhaps, the relevant information of calling that concerns the interface function that bus provides reference object or the object that is cited, form the formation of a function call relevant information, wherein, the function call relevant information comprises the interface function name, and function parameter information.
Sub for example, suppose to concern that bus provides in all interface function, parameter mostly is 6 most, and then the structural information of the queue element (QE) of record function call essential information is { function name, parameter 1, parameter 2, parameter 3, parameter 4, parameter 5, parameter 6} in formation.Be less than 6 interface function for those number of parameters, the argument section that lacks is set to sky, such as, concern that notice that bus provides revises among the interface function ModifyoINotify (LONG oIID) of the object instance that is cited and have only a parameter, then when the object that is cited takes place to revise, application system is called this interface function, at this moment, concerns that bus generates a queue element (QE) { " ModifyoINotify ", oIID, NULL, NULL, NULL, NULL, NULL}, the NULL here can be 0, also can be some specific values of in advance appointing.For for simplicity, can be with a digital representative function name, such as with 3 representatives " ModifyoINotify ", then Yi Shang queue element (QE) can be recorded as 3, oIID, NULL, NULL, NULL, NULL, NULL}.Then, concern that bus adds this newly-generated queue element (QE) in the formation.Because comprised the information of object instance in the parameter, therefore, here, the parameter of record mainly is the value of parameter, rather than the type of parameter.
Here can repeat evaluation algorithm by element circulation in a kind of formation, promptly backtracking method judges whether formation endless loop occurs.This determination methods is by setting in advance standard endless loop parameter, and according to these parameters formation is recalled to detect and realize.Standard endless loop parameter comprises the cycle index of the minimum appearance that circulation possibility length minimum value, circulation possibility length maximal value, requirement detect etc.
Backtracking method is the element that arrives from current check, element in the reverse detection formation, the each inspection by circulation may length be decided the mode of choosing of the queue element (QE) that compares, and decided the number of the queue element (QE) that will compare by the cycle index of minimum appearance.This method is a situation about dynamically increasing progressively in formation, can reduce the relatively trouble of state of application system record, thereby improve detection efficiency.
Such as, detected formation is Item[i], wherein, i is 0,1, the integer of 2......N; The circulation minimum length is set to 2, and the circulation maximum length is set to 3, and requiring the cycle index of the minimum appearance of detection is 4.The situation that circulations such as A, B, A, B, A, B, A, B or A, B, C, A, B, C, A, B, C, A, B, C repeat promptly occurs, all will be detected.Concrete testing process is as follows:
Being provided with and detecting current progress is to detect to reach j+1 element, that is, the element that current detection arrives is Item[j], then carry out following steps:
Steps A. for length of the cycle 2 circular test, application program judge whether (Item[j]=Item[j-2]=Item[j-4]=Item[j-6]), and (ItemU-1]=Item[j-3]=Item[j-5]=Item[j-7]), if then this circulation will be detected.Otherwise expression does not also have to find that the length of the cycle that satisfies condition is 2 circulation at present.
It for length of the cycle 3 circular test, application program judge whether (Item[j]=Item[j-3]=Item[j-6]=Item[j-9]=Item[j-12]), and (Item[j-1]=Item[j-4]=Item[j-7]=Item[j-10]=Item[j-13]), and (Item[j-2]=Item[j-5]=Item[j-8]=Item[j-11]=Item[j-14]), if then this circulation will be detected.Otherwise expression does not also have to find that the length of the cycle that satisfies condition is 3 circulation at present.
Step B. changes current progress into and reaches j+2 element, i.e. Item[j+1], also, the value of j+1 is increased by 1 get final product.Then, change steps A and continue to carry out, reach till the tail element that has detected formation up to the detection progress.
Because message through when relation bus, just appends a tail element in the formation, simultaneously at every turn, with the element of this element as the arrival of current detection progress, relevant detection is carried out in formation, therefore, when increasing an element in each formation, according to backtracking method, begin to do one-time detection from the rear of queue element and get final product, rather than inspection all to begin to carry out complete detection from first element of formation at every turn, thereby, remove unnecessary judgement from, improved detection efficiency.
Whether step 105, applied system analysis current state are that endless loop has really taken place, whether should stop this circulation with decision, if not, then application system is by the rreturn value of call back function, such as, the rreturn value of call back function is that 0 expression does not stop circulation, notifies to concern that bus does not stop this circulation, and execution in step 106 then; If endless loop takes place, the application system rreturn value by call back function equally then, such as, the rreturn value of call back function is that 1 expression stops this circulation, notifies to concern that bus stops this circulation, execution in step 107 then.
In said process, concern bus according to the rule of formation judge be endless loop after, can directly stop this circulation.But, by concerning that the circulation that bus stops may cause the imperfect of data, therefore, the foregoing description is by application system the termination cycling condition to be set in call back function further to determine whether to stop this circulation, when application system is confirmed to be the endless loop generation, can do some relevant treatment, then, the notice of the rreturn value by call back function concerns that bus falls loop termination again.The relevant treatment of application system can comprise, finishes corresponding data-backoff function, or notifies the user, the relevant data-backoff of manual execution, thus guaranteed data integrity; Perhaps write the daily record that endless loop takes place; Perhaps be left intact, only notice concerns that bus stops circulation and gets final product.Certainly, the application system loop termination of also can directly checkmating in call back function falls, and then notice concerns that bus does not stop this endless loop, because endless loop has stopped, does not need repetitive operation so concern bus.The present invention adopts the call back function mechanism that concerns that bus provides in above-mentioned example, make application system that participation handling dead round-robin chance arranged, and this mode will more help to guarantee the robustness of application system.
It below mainly is endless loop detection at function call mode that concerns bus or message process mode.Certainly, concern the information of calling of the interface function that bus also can provide various reference objects or the object that is cited by record, and these information are carried out the mode of analyzing and processing, a situation arises to detect endless loop.
The detection of object reference endless loop and disposal route can also provide system developer various directed flexibly monitoring means, assist known circular reference and very possible those objects of endless loop of quoting of having taken place of application system development person's key monitoring, to guarantee the specific aim and the high-level efficiency of monitoring.For example,, make application system can on purpose monitor special object, particular message or specific interface function and call by concerning that bus gives information or the filtering function of the information of function call record, thus the treatment effeciency of raising application system.
Situation about calling mutually when the present invention can also be applied in the renunciation bus between any function, just the information of the queue element (QE) of record is that the be called information of function gets final product.Such as, be applied in the endless loop that the function in the c program is called mutually and detect.By this method directly being added in the compiler of C, with as a precompiler step, when c program is carried out precompile, directly this detection method is embedded in the middle of c program, like this, can realize effectively function in the c program is called the function that issuable endless loop detects mutually.
For the detection of calling mutually of member function between the object among the C++, the information of the queue element (QE) of requirement record also should comprise title, the function name of instance address information, class; For polymorphic function, also to write down information such as function parameters type.
In addition, the present invention also can be applied in the industrial automation under any situation with sequence of operation, and the information of Ji Lu queue element (QE) is the information of operation steps in such cases, such as action name or code name, and may significant operating environment parameter.
In a word, for different application, the information content of the queue element (QE) of described record is also different, during practical application, should decide the information content of the queue element (QE) that will write down according to concrete application.
Claims (11)
1, a kind of detection method of endless loop is characterized in that, this method may further comprise the steps:
A. set in advance the storage unit of recording operation essential information;
B. in storage unit, write down the essential information of each operation, according to the occurrence law of the element that writes down in the current memory cell, formation is recalled detection to judge whether to occur endless loop according to standard endless loop parameter, if, then stop the operation of endless loop correspondence, otherwise, return step B.
2, method according to claim 1 is characterized in that, described steps A further comprises: the threshold value of storage element number in the storage unit is set,
Then before the recording operation essential information, this method further comprises:
Whether threshold value element number set in the element number of judging current record in the storage unit and the steps A equate, if equate, then removes in the storage unit element information of record at first, execution in step B, otherwise, direct execution in step B.
3, method according to claim 1 is characterized in that, described standard endless loop parameter comprises circulation possibility length maximal value, circulation may length minimum value and minimum cycle index.
4, method according to claim 3 is characterized in that, judges whether to occur endless loop among the step B and further comprises:
B1. whether judge minimum cycle index greater than 1, if greater than, be initial element with current record, execution in step B2, otherwise, determine the current endless loop that do not occur, finish then;
B2. from initial element, according to the reverse element that will compare of choosing of circulation possibility length;
Whether all elements of choosing among the B3. more described step B2 is equal, if equate, and execution in step B4, otherwise, determine the current endless loop that do not occur, finish then;
B4. judge and whether detect number of times less than circulation possibility minimum length, if less than, then setting first reverse element of current initial element is initial element, execution in step B2, otherwise, determine the current endless loop that occurs.
5, method according to claim 1 is characterized in that, the essential information of operation described in the steps A concerns the essential information of bus message for process; Or the relevant information called of the interface function relevant with concerning bus; Or be and concern call relation between the irrelevant function of bus; Or be relation between the sequence of operation.
6, method according to claim 5 is characterized in that, and is described through concerning that the essential information of bus message comprises type of message and message parameter information.
7, method according to claim 5 is characterized in that, the relevant information that the described interface function relevant with concerning bus calls comprises interface function name and function parameter information.
8, method according to claim 5 is characterized in that, and is described and concern that the call relation between the irrelevant function of bus comprises the function name that is called.
9, method according to claim 5 is characterized in that, the described sequence of operation comprises operation steps title or code name.
10, method according to claim 5, it is characterized in that, this method further comprises: before stopping endless loop, judge whether to stop circulation according to current state, and the judged result notice is concerned bus, if do not stop circulation, then continue execution in step B, if stop circulation, concern that bus abandons current message, and empty storage unit.
11, method according to claim 1 is characterized in that, step B further comprises: when stopping endless loop, by call back function notice application system generation endless loop mistake.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB031210929A CN100353333C (en) | 2003-03-20 | 2003-03-20 | Method for detecting dead circulation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB031210929A CN100353333C (en) | 2003-03-20 | 2003-03-20 | Method for detecting dead circulation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1532704A CN1532704A (en) | 2004-09-29 |
CN100353333C true CN100353333C (en) | 2007-12-05 |
Family
ID=34285568
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB031210929A Expired - Fee Related CN100353333C (en) | 2003-03-20 | 2003-03-20 | Method for detecting dead circulation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100353333C (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100394399C (en) * | 2006-02-22 | 2008-06-11 | 迈普(四川)通信技术有限公司 | Method for testing closed loop or similar closed loop task |
CN101639725B (en) * | 2008-07-31 | 2013-07-17 | 国际商业机器公司 | Device and method for processing instruction and executive control device used by same |
CN111638967A (en) * | 2020-06-01 | 2020-09-08 | 杭州鸿雁电器有限公司 | Scene processing method and device, storage medium and processor |
CN115174287A (en) * | 2022-05-12 | 2022-10-11 | 芜湖美的厨卫电器制造有限公司 | Target link processing method and device, computer storage medium and equipment |
CN117648202B (en) * | 2024-01-30 | 2024-05-14 | 深圳市纷享互联科技有限责任公司 | Heterogeneous system data synchronization process endless loop detection method, system and medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5016167A (en) * | 1987-12-21 | 1991-05-14 | Amdahl Corporation | Resource contention deadlock detection and prevention |
US5764976A (en) * | 1995-02-06 | 1998-06-09 | International Business Machines Corporation | Method and system of deadlock detection in a data processing system having transactions with multiple processes capable of resource locking |
CN1377148A (en) * | 2001-03-27 | 2002-10-30 | 华为技术有限公司 | Method for processing endless loop under real-time multitask |
-
2003
- 2003-03-20 CN CNB031210929A patent/CN100353333C/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5016167A (en) * | 1987-12-21 | 1991-05-14 | Amdahl Corporation | Resource contention deadlock detection and prevention |
US5764976A (en) * | 1995-02-06 | 1998-06-09 | International Business Machines Corporation | Method and system of deadlock detection in a data processing system having transactions with multiple processes capable of resource locking |
CN1377148A (en) * | 2001-03-27 | 2002-10-30 | 华为技术有限公司 | Method for processing endless loop under real-time multitask |
Also Published As
Publication number | Publication date |
---|---|
CN1532704A (en) | 2004-09-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107886238B (en) | Business process management system and method based on mass data analysis | |
CN100487664C (en) | Method and device for locating hardware faults in a data communications network of a parallel computer | |
CN100481021C (en) | Method, system, and apparatus for identifying unresponsive portions of a computer program | |
CN101082875B (en) | Reducing the size of a data stream produced during instruction tracing | |
CN108984708A (en) | Dirty data recognition methods and device, data cleaning method and device, controller | |
CN111241059B (en) | Database optimization method and device based on database | |
CN100353333C (en) | Method for detecting dead circulation | |
CN111200530A (en) | Method and device for performing root cause analysis based on KPI (Key performance indicator) | |
EP0546882A1 (en) | Expert system supporting real time constraints | |
CN112084180A (en) | Method, device, equipment and medium for monitoring vehicle-mounted application quality | |
CN112702215A (en) | Alarm association rule matching priority ordering method, device and storage medium | |
CN102521530A (en) | License recycling method and system | |
CN114461534A (en) | Software performance testing method and system, electronic equipment and readable storage medium | |
CN112818201A (en) | Network data acquisition method and device, computer equipment and storage medium | |
CN115981902A (en) | Fine-grained distributed micro-service system abnormal root cause positioning method and device | |
CN113051725B (en) | DET and RELAP5 coupled dynamic characteristic analysis method based on universal auxiliary variable method | |
CN111913824A (en) | Method for determining data link fault reason and related equipment | |
US6330527B1 (en) | Apparatus and method for modeling frameworks via use of object-oriented analysis information | |
CN106598843B (en) | A kind of software log behavior automatic identifying method based on program analysis | |
Addouche et al. | UML models for dependability analysis of real-time systems | |
CN111723370A (en) | Method and equipment for detecting malicious behavior of container | |
CN104881297A (en) | State machine management method and system | |
CN113807462A (en) | AI-based network equipment fault reason positioning method and system | |
Huang et al. | Design, analysis and implementation of a real-world manufacturing cell controller based on Petri nets | |
CN107066366B (en) | Complex event processing engine state monitoring and disaster recovery method for Internet of things |
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 | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20071205 Termination date: 20200320 |