Summary of the invention
In order to solve application program, cannot know the whether problem in dormancy running status of smart mobile phone, the embodiment of the present invention provides a kind of condition detection method, device and terminal.Described technical scheme is as follows:
According to a first aspect of the invention, provide a kind of condition detection method, described method comprises:
Obtain real time clock period number and processor clock cycle number in predetermined amount of time;
Detect described real time clock period number and whether be greater than described processor clock cycle number;
If testing result is described real time clock period number, be greater than described processor clock cycle number, determine current in dormancy running status.
Further, described in obtain real time clock period number and the processor clock cycle number in predetermined amount of time, comprising:
Every predetermined time interval, obtain real time clock period number and the processor clock cycle number of once take in the predetermined amount of time that current time is terminal.
Further, describedly every predetermined time interval, obtain real time clock period number and the processor clock cycle number of once take in the predetermined amount of time that current time is terminal, comprising:
According to described predetermined time interval, timer is set, described timer is based on real-time clock;
When the timing of described timer arrives constantly, trigger processor and obtain real time clock period number and the processor clock cycle number of take in the predetermined amount of time that current time is terminal.
Further, the described real time clock period number of described detection also comprises after whether being greater than described processor clock cycle number:
If testing result is described real time clock period number, equal described processor clock cycle number, determine current in normal operating condition.
Further, measure the Cycle Length that described real time clock period counts institute's reference and equal to measure the Cycle Length that described processor clock cycle is counted institute's reference.
According to a second aspect of the invention, provide a kind of condition checkout gear, described device, comprising:
Quantity acquisition module, for obtaining real time clock period number and the processor clock cycle number in predetermined amount of time;
Quantity detection module, whether the real time clock period number getting for detection of described quantity acquisition module is greater than the processor clock cycle number that described quantity acquisition module gets;
State determination module, if be that described real time clock period number is greater than described processor clock cycle number for the testing result of described quantity detection module, determines current in dormancy running status.
Further, described quantity acquisition module, specifically for obtaining real time clock period number and the processor clock cycle number of once take in the predetermined amount of time that current time is terminal every predetermined time interval.
Further, described quantity acquisition module, comprising:
Set timer unit and number obtainment unit;
Described set timer unit, for timer being set according to described predetermined time interval, described timer is based on real-time clock;
Described number obtainment unit, while constantly arriving for the timing of the timer in the unit setting of described set timer, triggers processor and obtains real time clock period number and the processor clock cycle number of take in the predetermined amount of time that current time is terminal.
Further, described device, also comprises:
Normal determination module;
Described normal determination module, if be that described real time clock period number equals described processor clock cycle number for the testing result of described quantity detection module, determines current in normal operating condition.
According to a third aspect of the invention we, provide a kind of terminal, it is characterized in that, described terminal comprises the condition checkout gear described in as above second aspect.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is:
By real time clock period number and the processor clock cycle detecting in predetermined amount of time, whether equate, and when real time clock period number is greater than processor clock cycle, assert current in dormancy running status; Solve application program and cannot know the whether problem in dormancy running status of terminal; Reached and can know the current whether information in dormancy running status, avoided because causing application program to occur abnormal effect in dormancy running status.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment mono-
Please refer to Fig. 1, it shows the method flow diagram of the condition detection method that the embodiment of the present invention one provides.This condition detection method can be in the mobile terminal such as smart mobile phone, panel computer, can also be for the PC such as desktop computer, notebook.This condition detection method, comprising:
Step 102, obtains real time clock period number and processor clock cycle number in predetermined amount of time;
Because cpu clock also can be out of service during in dormancy running status in terminal, and RTC(Real-Time Clock, real-time clock) clock is the clock based on crystal oscillator components and parts provide in terminal, no matter terminal power supply opening is still closed, RTC clock periodicity remains stable rate increase, so whether keeping operation by the whether identical CPU of judgement of clock periodicity of these two clocks always.For this reason, first obtain real time clock period number and the processor clock cycle number in predetermined amount of time.
Step 104, detects real time clock period number and whether is greater than processor clock cycle number;
Then, detect RTC clock periodicity and whether be greater than processor cpu clock periodicity, if CPU keeps operation within a predetermined period of time always, RTC real time clock period number should equal cpu clock periodicity; If CPU does not keep operation within a predetermined period of time always, RTC real time clock period number should be greater than cpu clock periodicity.
Step 106, is greater than processor clock cycle number if testing result is real time clock period number, determines current in dormancy running status.
If testing result is real time clock period number, be greater than processor clock cycle number, represent that CPU does not keep operation within a predetermined period of time, determines current in dormancy running status always.
In sum, the condition detection method that the present embodiment provides, by real time clock period number and the processor clock cycle detecting in predetermined amount of time, whether equate, and when real time clock period number is greater than processor clock cycle, assert current in dormancy running status; Solve application program and cannot know the whether problem in dormancy running status of terminal; Reached and can know the current whether information in dormancy running status, avoided because causing application program to occur abnormal effect in dormancy running status.
Embodiment bis-
Please refer to Fig. 2, it shows the method flow diagram of the state acquiring method that the embodiment of the present invention two provides.In the present embodiment, mainly with this condition detection method, for the mobile terminal such as smart mobile phone, panel computer, illustrate.This condition detection method, comprising:
Step 202, obtains real time clock period number and the processor clock cycle number of once take in the predetermined amount of time that current time is terminal every predetermined time interval;
The instant messaging program that in the present embodiment, hypothesis operates in terminal needs whether sense terminals is current illustrates in dormant state.Instant messaging program can be obtained RTC clock periodicity and the cpu clock periodicity of once take in the predetermined amount of time that current time is terminal every predetermined time interval, such as obtained RTC clock periodicity and cpu clock periodicity every 5 minutes.This step specifically can comprise following two sub-steps:
The first, interval arranges timer to schedule, and timer is based on real-time clock;
Instant messaging program to schedule interval arranges at least one timer, and this timer can be the timer based on RTC clock that drives layer to provide.If instant messaging program only arranges a timer, need constantly periodically multiplexing this timer.Certainly, instant messaging program also can arrange a plurality of timers.
The second, when the timing of timer arrives constantly, trigger processor and obtain real time clock period number and the processor clock cycle number of take in the predetermined amount of time that current time is terminal;
When the timing of timer arrives constantly, timer can trigger look-at-me to CPU.If CPU moves, after receiving look-at-me, obtain RTC clock periodicity and cpu clock periodicity; If CPU is current in halted state, also can be reawaked to obtain RTC clock periodicity and cpu clock periodicity by this look-at-me.
It should be noted that, above-mentioned predetermined amount of time and predetermined time interval all measure as a reference with RTC clock, and predetermined amount of time and predetermined time interval can equate or unequal.On the other hand, the Cycle Length of metering RTC clock periodicity institute reference also should equal to measure the Cycle Length of cpu clock periodicity institute reference.If actual cpu clock Cycle Length is not equal to the RTC clock period, but has multiple relation between the two, should first according to changing multiple relation, be converted into the reference clock week after date of formed objects, then measures RTC clock periodicity and cpu clock periodicity.
Step 204, detects real time clock period number and whether is greater than processor clock cycle number;
Instant messaging program detects the RTC clock periodicity getting and whether is greater than cpu clock periodicity, if CPU keeps operation within a predetermined period of time always, RTC real time clock period number should equal cpu clock periodicity; If CPU does not keep operation within a predetermined period of time always, RTC real time clock period number should be greater than cpu clock periodicity.
Step 206, is greater than processor clock cycle number if testing result is real time clock period number, determines current in dormancy running status;
If the testing result of instant messaging program is real time clock period number, be greater than processor clock cycle number, determine current in dormancy running status.After this, instant messaging program can be adjusted the operation strategy of oneself, and such as adopting more reliable heartbeat program and server to keep in touch, more reliable heartbeat program can be the heartbeat program based on RTC clock; Again such as, instant messaging program can also reduce the frequency with server communication; For another example, instant messaging program can also stop and server communication during in dormancy running status in terminal, until terminal detected when normal operating condition, then recommunicate with server, etc.
Step 208, equals processor clock cycle number if testing result is real time clock period number, determines current in normal operating condition.
If the testing result of instant messaging program is real time clock period number, equal processor clock cycle number, determine current in normal operating condition.Instant messaging program can keep original operation strategy constant.
In sum, the condition detection method that the present embodiment provides, by real time clock period number and the processor clock cycle detecting in predetermined amount of time, whether equate, and when real time clock period number is greater than processor clock cycle, assert current in dormancy running status; Solve application program and cannot know the whether problem in dormancy running status of terminal; Reached and can know the current whether information in dormancy running status, avoided because causing application program to occur abnormal effect in dormancy running status.Also, by periodically detecting, make application program can obtain in time the current running status of terminal; Also by utilization, drive the timer based on RTC clock of layer to carry out the execution of detection trigger step, even if reached CPU in run-stopping status, also can be waken up to obtain RTC clock periodicity and cpu clock periodicity, can not occur under dormancy running status, application program just cannot initiatively be moved the effect of any function.
Embodiment tri-
Please refer to Fig. 3, it shows the block diagram of the condition checkout gear that the embodiment of the present invention three provides.This condition checkout gear can be realized becomes the whole or a part of of terminal.This condition checkout gear, comprising: quantity acquisition module 320, quantity detection module 340 and state determination module 360.
Quantity acquisition module 320, for obtaining real time clock period number and the processor clock cycle number in predetermined amount of time;
Quantity detection module 340, whether the real time clock period number getting for detection of described quantity acquisition module 320 is greater than the processor clock cycle number that described quantity acquisition module gets;
State determination module 360, if be that described real time clock period number is greater than described processor clock cycle number for the testing result of described quantity detection module 340, determines current in dormancy running status.
In sum, the condition checkout gear that the present embodiment provides, by real time clock period number and the processor clock cycle detecting in predetermined amount of time, whether equate, and when real time clock period number is greater than processor clock cycle, assert current in dormancy running status; Solve application program and cannot know the whether problem in dormancy running status of terminal; Reached and can know the current whether information in dormancy running status, avoided because causing application program to occur abnormal effect in dormancy running status.
Embodiment tetra-
Please refer to Fig. 4, it shows the block diagram of the condition checkout gear that the embodiment of the present invention four provides.This condition checkout gear can be realized becomes the whole or a part of of terminal.This condition checkout gear, comprising: quantity acquisition module 320, quantity detection module 340, state determination module 360 and normal determination module 380.
Quantity acquisition module 320, specifically for obtaining real time clock period number and the processor clock cycle number of once take in the predetermined amount of time that current time is terminal every predetermined time interval.Specifically, described quantity acquisition module 320, comprising: set timer unit 322 and number obtainment unit 324;
Described set timer unit 322, for timer being set according to described predetermined time interval, described timer is based on real-time clock;
Described number obtainment unit 324, while constantly arriving for the timing of 322 timers that arrange in described set timer unit, triggers processor and obtains real time clock period number and the processor clock cycle number of take in the predetermined amount of time that current time is terminal.
Quantity detection module 340, whether the real time clock period number getting for detection of described quantity acquisition module 320 is greater than the processor clock cycle number that described quantity acquisition module gets;
State determination module 360, if be that described real time clock period number is greater than described processor clock cycle number for the testing result of described quantity detection module 340, determines current in dormancy running status.
Normal determination module 380, if be that described real time clock period number equals described processor clock cycle number for the testing result of described quantity detection module 340, determines current in normal operating condition.
In sum, the condition checkout gear that the present embodiment provides, by real time clock period number and the processor clock cycle detecting in predetermined amount of time, whether equate, and when real time clock period number is greater than processor clock cycle, assert current in dormancy running status; Solve application program and cannot know the whether problem in dormancy running status of terminal; Reached and can know the current whether information in dormancy running status, avoided because causing application program to occur abnormal effect in dormancy running status.
It should be noted that: the condition checkout gear that above-described embodiment provides is when the current running status of sense terminals, only the division with above-mentioned each functional module is illustrated, in practical application, can above-mentioned functions be distributed and by different functional modules, completed as required, the inner structure of the equipment of being about to is divided into different functional modules, to complete all or part of function described above.In addition, the condition checkout gear that above-described embodiment provides and condition detection method embodiment belong to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can come the hardware that instruction is relevant to complete by program, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be ROM (read-only memory), disk or CD etc.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.