CN107273229A - Handle method, device and computer-readable recording medium abnormal during timer - Google Patents

Handle method, device and computer-readable recording medium abnormal during timer Download PDF

Info

Publication number
CN107273229A
CN107273229A CN201710375102.5A CN201710375102A CN107273229A CN 107273229 A CN107273229 A CN 107273229A CN 201710375102 A CN201710375102 A CN 201710375102A CN 107273229 A CN107273229 A CN 107273229A
Authority
CN
China
Prior art keywords
variable
return value
timing function
timer
logic
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
CN201710375102.5A
Other languages
Chinese (zh)
Other versions
CN107273229B (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.)
PAX Computer Technology Shenzhen Co Ltd
Original Assignee
PAX Computer Technology Shenzhen Co Ltd
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 PAX Computer Technology Shenzhen Co Ltd filed Critical PAX Computer Technology Shenzhen Co Ltd
Priority to CN201710375102.5A priority Critical patent/CN107273229B/en
Publication of CN107273229A publication Critical patent/CN107273229A/en
Application granted granted Critical
Publication of CN107273229B publication Critical patent/CN107273229B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/004Error avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime

Abstract

The present invention relates to computer software fields there is provided method, device and computer-readable recording medium abnormal during a kind of processing timer, to prevent extremely caused program operation exception during timer.Methods described includes:Define a variable t0;Before time-out judges the code execution of this logic, variable t is assigned to by calling timing function by the return value T ' of the timing function0, the return value T ' of timing function data width is not more than variable t0Data width;Execution prevents variable t0, return value T ' or variable t0Overflowing and/or unroll with return value T ' sums causes the operation of logic error.The technical scheme that the present invention is provided still can exactly carry out overtime judgement when timer occurs and overflows and/or unroll so that program is according to correct logic operation.

Description

Handle method, device and computer-readable recording medium abnormal during timer
Technical field
The invention belongs to computer software fields, more particularly to it is a kind of handle method abnormal during timer, device and Computer-readable recording medium.
Background technology
In the issued transaction programming of computer software, when often enabling some timers and carrying out the progress to some affairs Between timing.If the time-out time set more than timer, can handle a branch of judgement, otherwise, still rest on original Affairs.Obviously, in the programming of this kind of affairs, exception can not occur in the timing of timer.Once occurring abnormal, logic is held It is about to that software developer's expected result can be deviateed.However, always limited (typically 32 words of the bit width of timer It is long), the data width of programming language that is used be also limited, thus be likely to occur the timing of timer overflow and/or Unroll etc. abnormal so that the code for causing time-out to judge occurs judging abnormal, ultimately result in program operation occur it is abnormal.
Problem above is urgently to be resolved hurrily.
The content of the invention
The present invention provides a kind of method, device and the computer-readable recording medium of exception when handling timer, to prevent Only extremely caused program operation exception during timer.
First aspect present invention provides a kind of method of exception when handling timer, including:
Define a variable t0
Before time-out judges that the code of this logic is performed, by calling timing function by the return value of the timing function T ' is assigned to the variable t0, the return value T ' of timing function data width is not more than the variable t0Data width;
Execution prevents the variable t0, return value T ' or the described variables t0Overflow and/or unroll with return value T ' sums Cause the operation of logic error.
Second aspect of the present invention provides a kind of device of exception when handling timer, including:
Variable-definition module, for defining a variable t0
Assignment module, before judging that the code of this logic is performed in the time-out, by calling timing function by institute The return value T ' for stating timing function is assigned to the variable t0, the return value T ' of timing function data width is not more than described Variable t0Data width;
Performing module, the variable t is prevented for performing0, return value T ' or the described variables t0With return value T ' sums Overflowing and/or unrolling causes the operation of logic error.
The third aspect of the embodiment of the present invention provides a kind of computing device, including memory, processor and is stored in In memory and the computer program that can run on a processor, following steps are realized during computing device computer program:
Define a variable t0
Before time-out judges that the code of this logic is performed, by calling timing function by the return value of the timing function T ' is assigned to the variable t0, the return value T ' of timing function data width is not more than the variable t0Data width;
Execution prevents the variable t0, return value T ' or the described variables t0Overflow and/or unroll with return value T ' sums Cause the operation of logic error.
The fourth aspect of the embodiment of the present invention provides a kind of computer-readable recording medium of Panorama Mosaic, calculates Machine readable storage medium storing program for executing is stored with computer program, and following steps are realized when computer program is executed by processor:
Define a variable t0
Before time-out judges that the code of this logic is performed, by calling timing function by the return value of the timing function T ' is assigned to the variable t0, the return value T ' of timing function data width is not more than the variable t0Data width;
Execution prevents the variable t0, return value T ' or the described variables t0Overflow and/or unroll with return value T ' sums Cause the operation of logic error.
It was found from the technical scheme that the invention described above is provided, variable t0Definition and assignment all time-out judge this logic Code perform before implement, compared with prior art, the technical scheme that provides of the present invention, which is performed, prevents variable t0, return value T ' or Variable t0Overflowing and/or unroll with return value T ' sums causes the operation of logic error, so as to be overflowed in timer And/or overtime judgement still can be carried out when unrolling exactly so that program is according to correct logic operation.
Brief description of the drawings
Technical scheme in order to illustrate the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art In required for the accompanying drawing that uses be briefly described, it should be apparent that, drawings in the following description are only some of the present invention Embodiment, for those of ordinary skill in the art, without having to pay creative labor, can also be according to these Accompanying drawing obtains other accompanying drawings.
The implementation process schematic diagram of method abnormal when being processing timer provided in an embodiment of the present invention Fig. 1;
The structural representation of device abnormal when being processing timer provided in an embodiment of the present invention Fig. 2;
Fig. 3 is the structural representation for handling device abnormal during timer that another embodiment of the present invention is provided;
Fig. 4 is the structural representation for handling device abnormal during timer that another embodiment of the present invention is provided;
Fig. 5 is the structural representation of computing device provided in an embodiment of the present invention.
Embodiment
In describing below, in order to illustrate rather than in order to limit, it is proposed that such as tool of particular system structure, technology etc Body details, thoroughly to understand the embodiment of the present invention.However, it will be clear to one skilled in the art that there is no these specific The present invention can also be realized in the other embodiments of details.In other situations, omit to well-known system, device, electricity Road and the detailed description of method, in case unnecessary details hinders description of the invention.
In order to illustrate technical scheme, illustrated below by specific embodiment.
The implementation process schematic diagram of the method abnormal when being processing timer provided in an embodiment of the present invention of accompanying drawing 1, it is main Comprise the following steps S101 to S103, describe in detail as follows:
S101, defines a variable t0
Wherein, variable t0Definable is in whole program code before realizing that time-out judges the code of this logic Position.
S102, before time-out judges that the code of this logic is performed, by calling timing function by the return of timing function Value T ' is assigned to variable t0, wherein, the return value T ' of timing function data width is not more than variable t0Data width.
In embodiments of the present invention, a variable t can defined0Before, timing function is realized in system layer, supply later after It is continuous to call.It should be noted that in order to ensure accuracy of timekeeping, realizing that timing function can be specifically to use hardware meter in system layer When device realize timing function in system layer;The return value T ' of timing function is represented.
In embodiments of the present invention, the return value T ' of timing function data width is not more than variable t0Data width; Can be by return value T ' and variable t0All it is defined as unsigned long.So that C language is realized as an example, it is assumed that timing function is used GetElapsedTime () is represented, then in the code of program, unsigned long t0With unsigned long GetElapsedTime () is represented the return value T ' and variable t of timing function0All it is defined as unsigned long.For example, false If return value T ' and variable t0Data width be 4 bytes, then timing function GetElapsedTimeo () return value T ' reach After 0xffffffff, unrolled again during timing to 0, i.e. if the every timing of timing function GetElapsedTimeo () is once, it is returned Return value T ' increasing 1, then after return value T ' increases to 0xffffffff, timing function GetElapsedTimeo () again timing when, Then timer overflows, and its return value T ' is changed into 0.
S103, execution prevents variable t0, return value T ' or variable t0Overflowing and/or unroll with return value T ' sums causes to patrol Collect the operation of mistake.
In the prior art, for issued transaction program in need time-out judge when, carry out time-out judgement method be:First from Current time is obtained in the timer of system layer as the time base value initial value t of starting0;Or else disconnected ground poll current time is It is no to exceed time base value t0With specified timeouts T sums.For convenience of description, all unify to represent timer with T below The timeouts of setting.Exemplified by programming language C, (wherein, the natural language after " // " is to C languages as follows for the realization of prior art The explanation of speech, similarly hereinafter):
#define T 9000;// the timeouts specified, 9000 milliseconds;
unsigned long t0
t0=GetTickCount ();The equipment of // acquisition program operation is undergone when called from start to timing function Duration (assuming that in units of millisecond), GetTickCount () be timing function, its return value T ' be timer timing Value;
while(1)
{
if(GetTickCount()>t0+T)break;
Sentence 1;
Sentence 2;
}
When timer does not overflow and unrolled, the logic that the time-out that above-mentioned prior art is provided judges is not in ask Topic.If timer occurs to overflow and/or unroll, decision logic will appear from exception, occurs to overflow and/or returns the following is timer Around when caused two kinds of abnormal conditions:
If 1) t0Do not overflow and/or unroll but t0When+T occurs to overflow and/or unroll, it will draw and miss sentencing for time-out It is disconnected, i.e.,:While circulations just start, and the condition that if judges is just true.For example (assuming that t0Data width with T be 4 bytes without Symbol integer, similarly hereinafter):
If t0=0xfffffff0;
T=9000;
Then t0+ T=8984;//t0+ T value is overflowed, and is unrolled to 8984;
Assuming that in while cycle criterions, when GetTickCount () is called first, value is 0xfffffff0, then 0xfffffff0>0xfffffff0+9000 is set up, i.e., the method judged according to the time-out of above-mentioned C language example, if (GetTickCount()>t0+ T) condition be "true", program judge timeouts arrival, jump out while using break sentences Circulation.However, the timeouts of actually timer are not reached, therefore, the logic error of program result in.
If 2) t0+ T does not overflow and/or unrolled but occurs to overflow and/or return when taking duration in cycle criterion first Around just occurring that slowly the not time out false crash that exits is abnormal, i.e.,:In fact the timeouts of timer have been arrived, and if judges Condition remain as "false".For example:
If t0=0xfffffff0;
T=10;
Then t0+T=0xfffffffa
Assuming that value is overflowed when GetTickCount () is called first in the circulating cycle, its return value is unrolled to 0, then 0>0xfffffffa is invalid, i.e. the method that the time-out according to above-mentioned C language example judges, if (GetTickCount ()>t0+ T condition) is "false", and program judges that timeouts are not yet reached.Hereafter, it is necessary to when the timing again of timer is arrived When 0xfffffffb is that GetTickCount () return value is changed into 0xfffffffb again, if (GetTickCount ()>t0+ T when condition) is "true", program just judges that timeouts are reached, and while circulations are jumped out using break sentences.However, timing Device is that 0 timing is 0xfffffffb to clocking value from clocking value, is far longer than the timeouts specified this period, thus very It is very long, it is actually similar with the phenomenon that program crashes.
It is different in order to solve above-mentioned the prior art spilling of timer and/or caused program operation of unrolling when time-out judges Often, as one embodiment of the invention, execution prevents variable t0, return value T ' or variable t0With return value T ' sums overflow and/or Unrolling causes the operation of logic error to be realized with S1031 as follows and S1032:
S1031, cycle criterion return value T ' and variable t0Difference whether be more than constant T, wherein, constant T is specify super When the time limit.
Similarly to the prior art, in embodiments of the present invention, the return value T ' of timing function is represented from setting that program is run The duration undergone when standby called from start to the timing function.Unlike the prior art, the technology that the present invention is provided The return value T ' and variable t of scheme cycle criterion timing function0Difference whether be more than the timeouts i.e. constant T that specifies, without Be cycle criterion timing function return value T ' whether be more than variable t0And constant T difference.
Specifically, step S1031 S ' 1 to S ' 5 can be realized as follows:
S ' 1, sets cycling condition as "true";
S ' 2, calls timing function;
S ' 3, judges the return value T ' and variable t of timing function0Difference whether be more than constant T;
S ' 4, if the return value T ' and variable t of timing function0Difference be not more than constant T, then perform loop body within code Corresponding logic;
Whether S ' 5, it is "true" to judge cycling condition.
S1032, if return value T ' and variable t0Difference be more than constant T, then jump out circulation.
For convenience of description, so that while the and if sentences of C language realize cycle criterion as an example.
The example of timing function is realized the following is system layer, it is assumed that application layer needs the timing function of millisecond precision.Example In system layer realize a timer interrupt service program, the time-count cycle of the timer is 1 millisecond.
The example below application layer realizes the code snippet that time-out judges:
Assuming that t0Do not unroll, and its value is 0xfffffff0, i.e. t0=0xfffffff0, and timing function GetElaspedTime () return value is unrolled, it is assumed that unrolled to 1, i.e. GetElaspedTime ()=1.Due to t0 Return value with GetElaspedTime () is all 4 byte unsigned longs, therefore, if according to prior art, if (GetElaspedTime()>T+t0) in Rule of judgment be "false", i.e. GetElaspedTime ()>T+t0It is invalid, then Still carry out within loop body the corresponding logic of code (perform sentence 1, sentence 2 ...), with the timeouts of timer It is to jump out while circulations not being inconsistent through execution logic expected from arrival, program, and the technology provided according to the present invention, if (GetElaspedTime()-t0>T the Rule of judgment in) is "true", i.e. GetElaspedTime ()-t0>T is set up, therefore is jumped Go out to circulate while, had arrived at the timeouts of timer, execution logic expected from program is to jump out circulation to be consistent.
When the processing timer of the above-mentioned example of accompanying drawing 1 it was found from abnormal method, variable t0Definition and assignment all exist Time-out judges that the code of this logic is implemented before performing, and compared with prior art, the technical scheme that the present invention is provided is performed and prevented Variable t0, return value T ' or variable t0Overflowing and/or unroll with return value T ' sums causes the operation of logic error, so as to Overtime judgement still can be carried out exactly when timer occurs and overflows and/or unroll so that program is according to correct logic Operation.
The schematic diagram of device abnormal when being processing timer provided in an embodiment of the present invention Fig. 2, it can be a meter Calculate equipment or functional module therein.Abnormal device mainly includes variable-definition mould during the processing timer of Fig. 2 examples Block 201, assignment module 202 and performing module 203, are described in detail as follows:
Variable-definition module 201, for defining a variable t0, wherein, variable t0It is located at realization in whole program code super When judge this logic code before position;
Assignment module 202, before judging that the code of this logic is performed in time-out, by calling timing function described The return value T ' of timing function is assigned to variable t0, wherein, the return value T ' of timing function data width is not more than variable t0Number According to width;
Performing module 203, variable t is prevented for performing0, return value T ' or variable t0With return value T ' sums overflow and/or Unrolling causes the operation of logic error.
It should be noted that device provided in an embodiment of the present invention, due to being based on same structure with the inventive method embodiment Think, its technique effect brought is identical with the inventive method embodiment, and particular content can be found in the inventive method embodiment Narration, here is omitted.
During the processing timer of the example of accompanying drawing 2 in abnormal device, the return value T ' of timing function is represented from program fortune The duration that capable equipment is undergone when called from start to timing function, the performing module 203 of the example of accompanying drawing 2 is sentenced including circulation Unit 302 is jumped out in disconnected unit 301 and circulation, abnormal device during the processing timer of such as example of accompanying drawing 3, wherein:
Cycle criterion unit 301, return value T ' and variable t for cycle criterion timing function0Difference whether be more than it is normal T is measured, wherein, constant T is the timeouts specified;
Unit 302 is jumped out in circulation, if return value T ' and variable t for timing function0Difference be more than constant T, then jump out Circulation.
The cycle criterion unit 301 of the example of accompanying drawing 3 includes setup unit 401, call unit 402, the first judging unit Abnormal device during the processing timer of the 403rd, judging unit 405 of logical execution units 404 and second, such as example of accompanying drawing 4, its In:
Setup unit 401, for setting cycling condition as "true";
Call unit 402, for calling timing function;
First judging unit 403, return value T ' and variable t for judging timing function0Difference whether be more than constant T;
Logical execution units 404, if for the first judging unit 403 judged result for timing function return value T ' with Variable t0Difference be not more than constant T, then perform loop body within the corresponding logic of code;
Second judging unit 405, for judging whether the cycling condition is "true"
Fig. 5 is the structural representation for the computing device that one embodiment of the invention is provided.As shown in figure 5, the meter of the embodiment Calculating equipment 5 includes:Processor 50, memory 51 and it is stored in the computer that can be run in memory 51 and on processor 50 Program 52, for example, handle the program of method abnormal during timer.Processor 50 is realized above-mentioned when performing computer program 52 Handle the step in embodiment of the method abnormal during timer, such as the step S101 to S103 shown in Fig. 1.Or, processing Device 50 realizes the function of each module/unit in above-mentioned each device embodiment, such as variable shown in Fig. 2 when performing computer program 52 The function of definition module 201, assignment module 202 and performing module 203.
Exemplary, the computer program 52 of abnormal method mainly includes during processing timer:Define a variable t0; Before the time-out judges that the code of this logic is performed, by calling timing function to assign the return value T ' of the timing function To the variable t0, the return value T ' of timing function data width is not more than the variable t0Data width;Perform anti- The only variable t0, return value T ' or the described variables t0Overflowing and/or unroll with return value T ' sums causes logic error Operation.Computer program 52 can be divided into one or more module/units, and one or more module/unit is stored Performed in memory 51, and by processor 50, to complete the present invention.One or more module/units can be completed The series of computation machine programmed instruction section of specific function, the instruction segment is used to describe computer program 52 in computing device 5 Implementation procedure.For example, computer program 52 can be divided into variable-definition module 201, assignment module 202 and performing module 203 (modules in virtual bench), each module concrete function is as follows:Variable-definition module 201, for defining a variable t0;Assign It is worth module 202, before judging that the code of this logic is performed in the time-out, by calling timing function by the timing letter Several return value T ' is assigned to the variable t0, the return value T ' of timing function data width is not more than the variable t0's Data width;Performing module 203, the variable t is prevented for performing0, return value T ' or the described variables t0With return value T ' Sum, which is overflowed and/or unrolled, causes the operation of logic error.
Computing device 5 can be the computing devices such as desktop PC, notebook, palm PC and cloud server.Meter Calculation equipment 5 may include but be not limited only to processor 50, memory 51.It will be understood by those skilled in the art that Fig. 5 is only to calculate The example of equipment 5, does not constitute the restriction to computing device 5, can include than illustrating more or less parts, or combination Some parts, or different parts, such as terminal device can also include input-output equipment, network access equipment, bus Deng.
Alleged processor 50 can be CPU (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) or other PLDs, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor can also be any conventional processor Deng.
Memory 51 can be the internal storage unit of computing device 5, the hard disk or internal memory of such as computing device 5.Storage Device 51 can also be the External memory equipment of computing device 5, such as the plug-in type hard disk being equipped with computing device 5, intelligent storage Block (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc.. Further, memory 51 can also both include the internal storage unit of computing device 5 or including External memory equipment.Memory 51 are used to store other programs and data needed for computer program and terminal device.Memory 51 can be also used for temporarily Store the data that has exported or will export.
It is apparent to those skilled in the art that, for convenience of description and succinctly, only with above-mentioned each work( Energy unit, the division progress of module are for example, in practical application, as needed can distribute above-mentioned functions by different Functional unit, module are completed, i.e., the internal structure of device is divided into different functional unit or module, to complete above description All or part of function.Each functional unit, module in embodiment can be integrated in a processing unit or Unit is individually physically present, can also two or more units it is integrated in a unit, above-mentioned integrated unit Both it can be realized in the form of hardware, it would however also be possible to employ the form of SFU software functional unit is realized.In addition, each functional unit, mould The specific name of block is also only to facilitate mutually differentiation, is not limited to the protection domain of the application.It is single in said system Member, the specific work process of module, may be referred to the corresponding process in preceding method embodiment, will not be repeated here.
In the above-described embodiments, the description to each embodiment all emphasizes particularly on different fields, without detailed description or note in some embodiment The part of load, may refer to the associated description of other embodiments.
Those of ordinary skill in the art are it is to be appreciated that the list of each example described with reference to the embodiments described herein Member and algorithm steps, can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually Performed with hardware or software mode, depending on the application-specific and design constraint of technical scheme.Professional and technical personnel Described function can be realized using distinct methods to each specific application, but this realization is it is not considered that exceed The scope of the present invention.
, can be with embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method Realize by another way.For example, device described above/terminal device embodiment is only schematical, for example, mould The division of block or unit, only a kind of division of logic function can have other dividing mode when actually realizing, such as multiple Unit or component can combine or be desirably integrated into another system, or some features can be ignored, or not perform.It is another Point, shown or discussed coupling or direct-coupling or communication connection each other can be by some interfaces, device or The INDIRECT COUPLING of unit or communication connection, can be electrical, machinery or other forms.
The unit illustrated as separating component can be or may not be physically separate, be shown as unit Part can be or may not be physical location, you can with positioned at a place, or can also be distributed to multiple networks On unit.Some or all of unit therein can be selected to realize the purpose of this embodiment scheme according to the actual needs.
In addition, each functional unit in each embodiment of the invention can be integrated in a processing unit, can also That unit is individually physically present, can also two or more units it is integrated in a unit.Above-mentioned integrated list Member can both be realized in the form of hardware, it would however also be possible to employ the form of SFU software functional unit is realized.
If integrated module/unit is realized using in the form of SFU software functional unit and as independent production marketing or used When, it can be stored in a computer read/write memory medium.Understood based on such, the present invention realizes above-described embodiment side All or part of flow in method, can also instruct the hardware of correlation to complete by computer program, handle timer The computer program of Shi Yichang method can be stored in a computer-readable recording medium, and the computer program is by processor During execution, the step of each above-mentioned embodiment of the method can be achieved, i.e. define a variable t0;Judge this logic in the time-out Code perform before, be assigned to the variable t by calling timing function by the return value T ' of the timing function0, the timing The return value T ' of function data width is not more than the variable t0Data width;Execution prevents the variable t0, it is described return Value T ' or described variables t0Overflowing and/or unroll with return value T ' sums causes the operation of logic error.Wherein, computer program Including computer program code, computer program code can for source code form, object identification code form, executable file or certain A little intermediate forms etc..Computer-readable medium can include:Any entity or device, note of computer program code can be carried Recording medium, USB flash disk, mobile hard disk, magnetic disc, CD, computer storage, read-only storage (ROM, Read-Only Memory), Random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium Deng.It should be noted that the content that computer-readable medium is included can be according to legislation in jurisdiction and patent practice It is required that carrying out appropriate increase and decrease, such as, in some jurisdictions, according to legislation and patent practice, computer-readable medium is not wrapped Include electric carrier signal and telecommunication signal.The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although The present invention is described in detail with reference to the foregoing embodiments, it will be understood by those within the art that:It still may be used To be modified to the technical scheme described in foregoing embodiments, or equivalent substitution is carried out to which part technical characteristic; And these modification or replace, do not make appropriate technical solution essence depart from various embodiments of the present invention technical scheme spirit and Scope, should be included in the scope of the protection.

Claims (10)

1. a kind of handle method abnormal during timer, it is characterised in that methods described includes:
Define a variable t0
Before time-out judges that the code of this logic is performed, by calling timing function to assign the return value T ' of the timing function To the variable t0, the return value T ' of timing function data width is not more than the variable t0Data width;
Execution prevents the variable t0, return value T ' or the described variables t0Overflowing and/or unroll with return value T ' sums causes The operation of logic error.
2. method abnormal during timer is handled as claimed in claim 1, it is characterised in that the return value of the timing function T ' represents the duration undergone when the equipment run from described program is called from start to the timing function, and the execution is prevented The only variable t0, return value T ' or the described variables t0Overflowing and/or unroll with return value T ' sums causes logic error Operation, including:
Return value T ' described in the cycle criterion and variable t0Difference whether be more than constant T, when the constant T is the time-out specified Limit;
If the return value T ' and the variable t0Difference be more than the constant T, then jump out circulation.
3. method abnormal during timer is handled as claimed in claim 2, it is characterised in that returned described in the cycle criterion Value T ' and the variable t0Difference whether be more than constant T, including:
Cycling condition is set as "true";
Call the timing function;
Judge the return value T ' and the variable t of the timing function0Difference whether be more than the constant T;
If the return value T ' and the variable t0Difference be not more than the constant T, then perform within loop body that code is corresponding patrols Volume;
Whether judge the cycling condition is "true".
4. handle method abnormal during timer as described in claims 1 to 3 any one, it is characterised in that described fixed One variable t of justice0Before, methods described also includes:
The timing function is realized in system layer.
5. method abnormal during timer is handled as claimed in claim 4, it is characterised in that described to realize institute in system layer Timing function is stated, including:
The timing function is realized in system layer using hardware timer.
6. a kind of handle device abnormal during timer, it is characterised in that described device includes:
Variable-definition module, for defining a variable t0
Assignment module, before judging that the code of this logic is performed in time-out, by calling timing function by the timing letter Several return value T ' is assigned to the variable t0, the return value T ' of timing function data width is not more than the variable t0's Data width;
Performing module, the variable t is prevented for performing0, return value T ' or the described variables t0Overflowed with return value T ' sums And/or unroll and cause the operation of logic error.
7. device abnormal during timer is handled as claimed in claim 6, it is characterised in that the return value of the timing function T ' represents the duration undergone when the equipment run from described program is called from start to the timing function, the execution mould Block includes:
Cycle criterion unit, for return value T ' described in cycle criterion and the variable t0Difference whether be more than constant T, it is described often It is the timeouts specified to measure T;
Unit is jumped out in circulation, if for the return value T ' and the variable t0Difference be more than the constant T, then jump out circulation.
8. device abnormal during timer is handled as claimed in claim 7, it is characterised in that the cycle criterion unit bag Include:
Setup unit, for setting cycling condition as "true";
Call unit, for calling the timing function;
First judging unit, return value T ' and the variable t for judging the timing function0Difference whether be more than it is described often Measure T;
Logical execution units, if the judged result for first judging unit is the return value T ' and the variable t0It Difference is not more than the constant T, then performs the corresponding logic of code within loop body;
Second judging unit, for judging whether the cycling condition is "true".
9. a kind of computing device, including memory, processor and it is stored in the memory and can be on the processor The computer program of operation, it is characterised in that realize such as claim 1 to 5 described in the computing device during computer program The step of any one methods described.
10. a kind of computer-readable recording medium, the computer-readable recording medium storage has computer program, its feature exists In the step of realizing such as claim 1 to 5 any one methods described when the computer program is executed by processor.
CN201710375102.5A 2017-05-24 2017-05-24 Method, device and computer readable storage medium for processing timer timing exception Active CN107273229B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710375102.5A CN107273229B (en) 2017-05-24 2017-05-24 Method, device and computer readable storage medium for processing timer timing exception

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710375102.5A CN107273229B (en) 2017-05-24 2017-05-24 Method, device and computer readable storage medium for processing timer timing exception

Publications (2)

Publication Number Publication Date
CN107273229A true CN107273229A (en) 2017-10-20
CN107273229B CN107273229B (en) 2020-06-26

Family

ID=60064134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710375102.5A Active CN107273229B (en) 2017-05-24 2017-05-24 Method, device and computer readable storage medium for processing timer timing exception

Country Status (1)

Country Link
CN (1) CN107273229B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111722671A (en) * 2020-05-13 2020-09-29 百富计算机技术(深圳)有限公司 Timing method, timing device, terminal equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0457135A (en) * 1990-06-27 1992-02-24 Hitachi Ltd Fault processing system for inter-task communication
JPH04326143A (en) * 1991-04-26 1992-11-16 Fujitsu Ltd Time-out monitor and control system for input/output instruction
CN1474241A (en) * 2002-08-07 2004-02-11 华为技术有限公司 Dispatching method for massive timer
US20060156075A1 (en) * 2004-12-14 2006-07-13 Renesas Technology Corp. Semiconductor integrated circuit
US7631114B2 (en) * 2003-03-28 2009-12-08 Renesas Technology Corp. Serial communication device
CN102413017A (en) * 2011-12-01 2012-04-11 中兴通讯股份有限公司 Time-delay performance monitoring method and device
CN103414545A (en) * 2013-07-31 2013-11-27 东软集团股份有限公司 Time-out judging method and system between heterogeneous systems

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0457135A (en) * 1990-06-27 1992-02-24 Hitachi Ltd Fault processing system for inter-task communication
JPH04326143A (en) * 1991-04-26 1992-11-16 Fujitsu Ltd Time-out monitor and control system for input/output instruction
CN1474241A (en) * 2002-08-07 2004-02-11 华为技术有限公司 Dispatching method for massive timer
US7631114B2 (en) * 2003-03-28 2009-12-08 Renesas Technology Corp. Serial communication device
US20060156075A1 (en) * 2004-12-14 2006-07-13 Renesas Technology Corp. Semiconductor integrated circuit
CN102413017A (en) * 2011-12-01 2012-04-11 中兴通讯股份有限公司 Time-delay performance monitoring method and device
CN103414545A (en) * 2013-07-31 2013-11-27 东软集团股份有限公司 Time-out judging method and system between heterogeneous systems

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
戴上举: "《删繁就简单片机入门到精通》", 31 January 2011 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111722671A (en) * 2020-05-13 2020-09-29 百富计算机技术(深圳)有限公司 Timing method, timing device, terminal equipment and storage medium

Also Published As

Publication number Publication date
CN107273229B (en) 2020-06-26

Similar Documents

Publication Publication Date Title
CN108427581A (en) System micro services method and terminal device
CN109753991A (en) Abnormal deviation data examination method and device
CN108334408B (en) Code execution method and device, terminal equipment and computer readable storage medium
CN107256707A (en) A kind of audio recognition method, system and terminal device
CN110021792A (en) Charge control method, device, terminal device and computer storage medium
CN109358873A (en) A kind of application program update method, storage medium and terminal device
CN107168813A (en) Task processing method and system
CN109976875A (en) A kind of data monitoring method and device of super fusion cloud computing system
CN107977504A (en) A kind of asymmetric in-core fuel management computational methods, device and terminal device
CN109446515A (en) Group information analysis method, electronic device and computer readable storage medium
CN108733799A (en) A kind of method for processing report data, device and terminal
CN107273229A (en) Handle method, device and computer-readable recording medium abnormal during timer
Różycki et al. Solving a power-aware scheduling problem by grouping jobs with the same processing characteristic
CN109597697A (en) A kind of resource brings processing method and processing device together
CN109271481A (en) A kind of classification method, system and the terminal device of electric power demand information
US11372633B2 (en) Method, device and terminal apparatus for code execution and computer readable storage medium
CN111651522A (en) Data synchronization method and device
CN107562520A (en) The method and apparatus of the internal memory of dilatation virtual machine
CN107729407A (en) User behavior analysis method and server
CN104572291A (en) Calling method of processors, and electronic equipment
CN114911589A (en) Cross-data-platform fusion computing method, system, terminal and storage medium
CN114840238A (en) Software upgrading method and device, electronic equipment and computer readable storage medium
CN114756365A (en) Computing resource identification method and device and computer readable storage medium
CN114168275B (en) Task scheduling method, system, terminal device and storage medium
CN115951936B (en) Chip adaptation method, device, equipment and medium of vectorization compiler

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