CN100501693C - Method and memory used for analyzing software system CPU occupancy rate - Google Patents

Method and memory used for analyzing software system CPU occupancy rate Download PDF

Info

Publication number
CN100501693C
CN100501693C CNB2007100769856A CN200710076985A CN100501693C CN 100501693 C CN100501693 C CN 100501693C CN B2007100769856 A CNB2007100769856 A CN B2007100769856A CN 200710076985 A CN200710076985 A CN 200710076985A CN 100501693 C CN100501693 C CN 100501693C
Authority
CN
China
Prior art keywords
cpu
overload
address
management system
network management
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
Application number
CNB2007100769856A
Other languages
Chinese (zh)
Other versions
CN101118514A (en
Inventor
林晓翰
陈路远
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CNB2007100769856A priority Critical patent/CN100501693C/en
Publication of CN101118514A publication Critical patent/CN101118514A/en
Application granted granted Critical
Publication of CN100501693C publication Critical patent/CN100501693C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present invention discloses a memorizer and a method for analyzing the CPU occupancy factor of a software system. The method includes the following steps: the memorizer is arranged with a prepared EMS memory when the device is electrified and the memorizer is initialized; a clock interrupt service routine, which is used for sampling the software system regularly, is arranged on the device; a monitor program conducts the periodical monitor on the running state of the CPU of the device, and records the running information of the CPU on the prepared EMS memory; the CPU over loads, the device reports the over loading information of the CPU to a network managing system; after receiving the over loading information, the network managing system outputs a reposition signal to the CPU, and then repositions the over loading of the CPU; the network managing system takes out the running information saved in the prepared EMS memory when the CPU over loads, and conducts analysis. Using the present invention, the software system can catch the over loading information of the CPU automatically, and report the over loading information to the network managing system for the software developer analyzing.

Description

A kind of method and storer that is used for analyzing software system CPU occupancy rate
Technical field
The present invention relates to the software systems field, especially a kind of method and storer that is used for the CPU usage of analyzing software system.
Background technology
Software systems run on personal computer environment or embedded environment, if the execution efficient of a certain subprogram is low, perhaps portfolio is excessive, can cause CPU usage too high, are also referred to as CPU overload.At this moment need software developer's code analysis which the part frequently called or working time long, this part program is optimized.Solve these problems of software systems operation at present, following several method arranged:
1, in the identical business of personal computer environment operation, use the coverage rate statistical tool under the PC platform, the execution number of times and the execution time of statistics codes, it is low to estimate that in view of the above which subprogram is carried out efficient;
2, when in the software systems operational process CPU overload taking place, the function calling relationship that causes the high task of CPU usage is checked at the scene of sending someone, thereby it is low to know which subprogram is carried out efficient.
Yet, in the said method, the weak point of first method is: the software systems that can only be applicable to personal computer environment, if software systems run on embedded environment, just need safeguard personal computer environment and embedded environment two cover programs, increased workload, and personal computer environment and embedded environment have any different after all, can not really find the bottleneck of embedded software system sometimes; The weak point of second method is: must have the people to work at a selected spot at the scene, wait for the moment of CPU overload, waste time and energy, if missed this constantly, just can't analyze.
Therefore, prior art awaits to improve and development.
Summary of the invention
The object of the present invention is to provide a kind of method that is used for analyzing software system CPU occupancy rate, the information when this method can write down and preserve last the overload automatically when CPU overload; For this reason, the present invention also provides a kind of storer that is used for analyzing software system CPU occupancy rate.
For solving above-mentioned purpose, technical scheme of the present invention comprises the steps:
A, on the storer of equipment, be provided with one and reserve internal memory, the described storer of initialization;
B, clock interrupt service routine are regularly gathered the CPU operation information on the described equipment, and are saved on the described reservation internal memory;
The running status of C, the periodic monitoring CPU of watchdog routine when judging described CPU overload, is saved in the CPU operation information that described clock interrupt service routine write down corresponding in the monitoring period in the described reservation internal memory again;
D, network management system are obtained the overload messages of described CPU;
E, described network management system are carried out CPU overload and are resetted after described CPU output reset signal;
Operation information when F, described network management system take out the described CPU overload that is kept at described reservation internal memory is also analyzed.
Wherein, in the described steps A, described reservation internal memory comprises: main memory area, be equipped with memory field, overload region, first address district and logo area; Described first address district also comprises the main memory area first address, is equipped with memory field first address and overload region first address.
Wherein, comprise in the described steps A: during described device initialize program, system program checks whether described logo area all is the sign that CPU overload has taken place, be then keep described main memory area, be equipped with the memory field, the assignment of overload region, first address district and logo area is constant, otherwise divide described main memory area, be equipped with memory field, overload region, first address district and logo area and empty, and to described first address district initialize.
Wherein, among the described step B, described clock interrupt routine comprises a write pointer, the described main memory area first address of this write pointers point.
Wherein, also comprise among the described step B: whenever clock interruption generation, described clock interrupt routine just is deposited into described reservation internal memory with the current device operation information of gathering.
Wherein, described step C also comprises: when described watchdog routine does not monitor described CPU overload in monitoring period, and the CPU operation information that described watchdog routine will need not to preserve described clock interrupt service routine again and be write down.
Wherein, described step D comprises: after described CPU overload, described equipment judges whether to insert described network management system, be then described equipment reports overload messages from described CPU to described network management system, otherwise the operation information of described CPU when described equipment is preserved last the overload automatically, and after described equipment inserted described network management system, described network management system was from the overload messages of last this CPU of the described equipment query of trend.
The present invention also provides a kind of storer that is used for analyzing software system CPU occupancy rate, comprises that one reserves internal memory, is used for the operation information that the store clock interrupt service routine is regularly gathered CPU, and the overload messages of this CPU of monitoring of watchdog routine.
Wherein, described storer, described reservation internal memory comprise main memory area, are equipped with memory field, overload region, first address district and logo area; Described main memory area is used to store the regular CPU operation information of gathering of clock interrupt service routine that watchdog routine monitors in the current monitoring period; The described memory field that is equipped with is used to store the regular CPU operation information of gathering of clock interrupt service routine that watchdog routine monitors in the preceding monitoring period; The CPU operation information that described clock interrupt service routine was write down when described overload region was used to store CPU overload; Logo area is used to store and show the sign whether CPU transships; Described first address district comprises the main memory area first address, is equipped with memory field first address and overload region first address, and this first address district is used to store described main memory area first address, is equipped with memory field first address and overload region first address.
Wherein, described storer, described storer are random access memory, and this random access memory is a nonvolatile memory.
Compared with prior art, adopt the inventive method, the present invention also has the following advantages:
1, software systems can be caught CPU overload information automatically, only increase very a spot of operating load and just overload messages can be reported to network management system;
2, after the CPU overload, if take place to receive resetting that reset signal causes because of software, house dog fault, cpu reset pin, overload messages are not lost;
3, by analyzing CPU overload information, for the execution efficient of deviser's Optimization Software provides foundation.
Description of drawings
Fig. 1 is the realization flow figure of the inventive method;
After Fig. 2 was the inventive method device power, logo area was not " CPU overload has taken place " sign, main memory area, was equipped with the dividing condition synoptic diagram of memory field, overload region, first address district, logo area;
Fig. 3 is the CPU nonoverload in a last monitoring period of the inventive method, perhaps goes up CPU overload in the monitoring period, and CPU also transships in the last monitoring period, former memory field and the main memory area exchange back allocation situation synoptic diagram of being equipped with;
Fig. 4 be the inventive method CPU overload has taken place in a last monitoring period, an and last monitoring period CPU nonoverload, the load that shows CPU is changed to overload from nonoverload, the former memory field that is equipped with just becomes main memory area, former main memory area becomes overload region, former overload region becomes memory field fully, logo area is write the situation of full " CPU overload has taken place " sign;
Fig. 5 is the situation of the inventive method after network management system reports CPU overload information.
Embodiment
Below in conjunction with accompanying drawing, preferred embodiment of the present invention is described in further detail.
The invention provides a kind of storer that is used for analyzing software system CPU occupancy rate, in the present embodiment, described storer is a random access memory, also can be nonvolatile memory.Described storer comprises that one reserves internal memory, be used for the store clock interrupt service routine and regularly gather the operation information of CPU, and the overload messages of this CPU of monitoring of watchdog routine, do not visited by other write operation, therefore, this reservation region of memory is called black box again.
Wherein, described reservation internal memory comprises main memory area, is equipped with memory field, overload region, first address district and logo area; Shown in Fig. 2 to 5, described main memory area is used to store the regular CPU operation information of gathering of clock interrupt service routine that watchdog routine monitors in the current monitoring period; The described memory field that is equipped with is used to store the regular CPU operation information of gathering of clock interrupt service routine that watchdog routine monitors in the preceding monitoring period; The CPU operation information that described clock interrupt service routine was write down when described overload region was used to store CPU overload; Logo area is used to store and show the sign whether CPU transships; Described first address district comprises the main memory area first address, is equipped with memory field first address and overload region first address, and this first address district is used to store described main memory area first address, is equipped with memory field first address and overload region first address.
The size of described reservation internal memory is by actual needs and physical memory decision; And definition " CPU overload has taken place " sign, as:
#define?CPU_OVERLOAD_HAPPENED(unsigned?char)Oxaa。
The present invention also provides a kind of method that is used for analyzing software system CPU occupancy rate, and this method can adopt different realization flows according to the operation conditions of software systems, as embodiment one and two:
Embodiment one
In the present embodiment, this method is used for the CPU usage analysis of embedded device software systems, consults shown in the accompanying drawing 1, and its analysis process step is as follows:
110, during the device power initializes memory, on described storer, mark a reservation internal memory that is used to write down the operation information of described equipment;
120, clock interrupt service routine provides an accurate clock interrupt procedure, its pairing clock interrupt cycle must be enough short, guaranteeing, and the CPU operation information of taking is saved on the described reservation internal memory software systems CPU operation information timing sampling;
130, the running status of the periodic monitoring CPU of watchdog routine, and when judging described CPU overload, the CPU operation information that described clock interrupt service routine write down corresponding in the monitoring period is saved in the described reservation internal memory again; Wherein, monitoring period was beneficial to a plurality of CPU operation information samples of described clock interrupt service routine recorded and stored are preserved again greater than described clock interrupt cycle;
140, after described CPU overload, network management system is obtained the overload messages of this CPU;
150, described network management system is carried out CPU overload and is resetted after described CPU output reset signal;
Operation information when 160, described network management system is taken out the described CPU overload that is kept at described reservation internal memory is also analyzed.
Wherein, in the step 110, during in initialization, whether system program all is " CPU overload has taken place " sign with the checkmark district at described embedded device, if not, then divide above-mentioned 5 zones and empty, and to first address district initialize; If, then keep the assignment in above-mentioned 5 zones constant, also need not to empty.
In the said method step 120, described clock interrupt routine (ISR) comprises a write pointer, and this write pointer points to the main memory area first address of reserving internal memory all the time; And whenever clock interrupt to take place, just (Program Counter PC) deposits the main memory area of reservation internal memory in to this write pointer, the current device operation information of taking is deposited into the main memory area of described reservation internal memory with the programmable counter of current task.
Wherein, in the step 130, the priority of described watchdog routine is higher than all other professional tasks, and in operation at set intervals once; And in the operational process, when described watchdog routine does not monitor described CPU overload in monitoring period, the CPU operation information that described watchdog routine will need not to preserve described clock interrupt service routine again and be write down.
When watchdog routine is moved, if monitor:
1), CPU nonoverload in the last monitoring period, perhaps go up CPU overload in the monitoring period, go up again that CPU also transships in the monitoring period.Under this situation, described watchdog routine is judged the CPU nonoverload, the CPU operation information of preserving when need not to preserve the sampling of clock interrupt routine again, as shown in Figure 3, simultaneously, because after the sampling of clock interrupt routine, need to preserve the CPU operation information, the main memory area of described reservation internal memory and be equipped with the corresponding exchange in position between the memory field, and at main memory area be equipped with the memory field and write the CPU operation information simultaneously, then
A), the main memory area first address assignment of first address district record is the former internal memory first address that is equipped with, the simultaneously former memory field that is equipped with just becomes main memory area;
B), first address district record to be equipped with memory field first address assignment be former main memory first address, former main memory area just becomes memory field fully simultaneously;
2), CPU overload has taken place in the last monitoring period, and go up CPU nonoverload in the monitoring period again, show that the load of CPU is changed to overload from nonoverload.Under this situation, described watchdog routine is judged CPU overload, the CPU operation information of preserving in the time of need preserving the sampling of clock interrupt routine again, equipment operation information when being about to CPU overload is saved in the overload region, and sign is saved in logo area will " CPU overload to have taken place ", writes the CPU operation information at main memory area with being equipped with in the memory field simultaneously, as shown in Figure 4, because this situation is to become overload by the CPU nonoverload, then
A), the main memory area first address assignment of first address district record is the former internal memory first address that is equipped with, the simultaneously former memory field that is equipped with just becomes main memory area;
B), the overload region first address assignment of first address district record is former main memory area first address, former main memory area just becomes overload region simultaneously;
C), first address district record to be equipped with memory field first address assignment be former overload region first address, former overload region just becomes memory field fully simultaneously;
D), logo area is write full CPU_OVERLOAD_HAPPENED sign.
Wherein, in the step 140, after embedded device generation CPU overload, when if described embedded device inserts described network management system, this embedded device reports CPU overload alarm to network management system, and takes out the overload region first address from described first address district, and the content of the overload region additional parameter as alarm is reported, simultaneously network management system is noted the information of overload region, and sends it back and answer message to give embedded device; After described embedded device is received and receiveed the response, overload region and logo area are emptied, as shown in Figure 5.
If during embedded device generation CPU overload, network management system is not linked on the described embedded device, after network management system inserts, this network management system sends the message of " inquiring about last CPU overload " from the trend embedded device, after this embedded device receives query messages, whether elder generation checkmark district all is " CPU overload has taken place " sign, be then to report the CPU overload alarm to network management system, and from first address district taking-up overload region first address, the additional parameter of overload region content as alarm reported, network management system is noted the information of overload region, transmission is receiveed the response to embedded device, after embedded device is received and is receiveed the response, with overload region, logo area empties, as shown in Figure 5; Otherwise not to network management system report and alarm incident.
Wherein, in the step 150, described network management system receives after the described CPU overload information and sends the reset signal horizontal reset of going forward side by side to house dog program, software systems program and cpu reset pin, and the content of reserving internal memory simultaneously remains unchanged, and still can write down the information of last CPU overload.When network management system inserted again, described network management system still can obtain last CPU overload information.
When CPU overload, after if the power down of described embedded device hardware takes place and resetting, will cause the memory contents of random access memory (RAM) device to become random value, at this moment logo area can all not be the CPU_OVERLOAD_HAPPENED sign, when described network management system is linked into described embedded device again, just do not obtain last CPU overload information yet.
Wherein, in the step 160, described network management system taking-up CPU overload information is analyzed the mode that is adopted and is: this network management system is taken out PC value, the functional symbol table of analysis of built-in software image, draw the function that when CPU overload, is moving subsequently, and then understand the software systems CPU usage.
Embodiment two
Present embodiment and embodiment one difference are:
In the present embodiment, this method is used to analyze the CPU usage based on the state machine system of message-driven, be based on the state machine system of message-driven, these state machine software systems can run on PC platform or the embedded type CPU, and its all behaviors are all triggered by message, after a process is only received message, could move, this state machine system is very common, and the ruuning situation when analyzing CPU overload must record the process number and message number.Wherein, for embodiment one, present embodiment changes the step 160 among the embodiment one into:
Described network management system is taken out process number and the message number that is retained in described reservation internal memory, makes statistical study, and the processing procedure that draws which message can cause CPU overload, and then understands the software systems CPU usage.
In sum, adopt the inventive method, have the following advantages:
1, software systems can be caught CPU overload information automatically, only increase very a spot of operating load and just overload messages can be reported to network management system;
2, after the CPU overload, if take place to receive resetting that reset signal causes because of software, house dog fault, cpu reset pin, overload messages are not lost;
3, by analyzing CPU overload information, for the execution efficient of deviser's Optimization Software provides foundation.
In a word, the present invention is not limited to above-mentioned embodiment, anyly is familiar with this operator, without departing from the spirit and scope of the present invention, all should drop within protection scope of the present invention.

Claims (7)

1, a kind of method that is used for analyzing software system CPU occupancy rate is characterized in that, comprises the steps:
A, on the storer of equipment, be provided with one and reserve internal memory, the described storer of initialization;
B, clock interrupt service routine are regularly gathered the CPU operation information on the described equipment, and are saved on the described reservation internal memory;
The running status of C, the periodic monitoring CPU of watchdog routine when judging described CPU overload, is saved in the CPU operation information that described clock interrupt service routine write down corresponding in the monitoring period in the described reservation internal memory again;
D, network management system are obtained the overload messages of described CPU;
E, described network management system are carried out CPU overload and are resetted after described CPU output reset signal;
Operation information when F, described network management system take out the described CPU overload that is kept at described reservation internal memory is also analyzed.
2, method according to claim 1 is characterized in that, in the described steps A, described reservation internal memory comprises main memory area, is equipped with memory field, overload region, first address district and logo area; Described first address district stores the main memory area first address, is equipped with memory field first address and overload region first address.
3, method according to claim 2, it is characterized in that, comprise in the described steps A: during described device initialize, whether system program is checked in the described logo area all is the sign that CPU overload has taken place, be then keep described main memory area, be equipped with the memory field, the assignment of overload region, first address district and logo area is constant; Otherwise divide described main memory area, be equipped with memory field, overload region, first address district and logo area and empty, and to described first address district initialize.
4, method according to claim 2 is characterized in that, among the described step B, described clock interrupt service routine comprises a write pointer, and this write pointer points to described main memory area first address all the time.
5, method according to claim 1 is characterized in that, comprises among the described step B: whenever clock interruption generation, described clock interrupt service routine just is deposited into described reservation internal memory with the current device operation information of gathering.
6, method according to claim 1, it is characterized in that, described step C also comprises: when described watchdog routine does not monitor described CPU overload in monitoring period, and the CPU operation information that described watchdog routine will need not to preserve described clock interrupt service routine again and be write down.
7, method according to claim 1, it is characterized in that, described step D comprises: after described CPU overload, described equipment judges whether to insert described network management system, be then described equipment reports overload messages from described CPU to described network management system, otherwise the operation information of described CPU when described equipment is preserved last the overload automatically, and after described equipment inserted described network management system, described network management system was from the overload messages of last this CPU of the described equipment query of trend.
CNB2007100769856A 2007-09-14 2007-09-14 Method and memory used for analyzing software system CPU occupancy rate Expired - Fee Related CN100501693C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007100769856A CN100501693C (en) 2007-09-14 2007-09-14 Method and memory used for analyzing software system CPU occupancy rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007100769856A CN100501693C (en) 2007-09-14 2007-09-14 Method and memory used for analyzing software system CPU occupancy rate

Publications (2)

Publication Number Publication Date
CN101118514A CN101118514A (en) 2008-02-06
CN100501693C true CN100501693C (en) 2009-06-17

Family

ID=39054642

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007100769856A Expired - Fee Related CN100501693C (en) 2007-09-14 2007-09-14 Method and memory used for analyzing software system CPU occupancy rate

Country Status (1)

Country Link
CN (1) CN100501693C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291590A (en) * 2017-05-24 2017-10-24 珠海金山网络游戏科技有限公司 A kind of system and method for detecting CPU usage and automatically generating performance evaluation file

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102200943B (en) * 2010-03-25 2014-12-03 腾讯科技(深圳)有限公司 Method and equipment for automatically detecting CPU utilization rate based on background
CN105260305B (en) * 2015-10-15 2018-09-07 珠海格力电器股份有限公司 Cpu monitor adjustment method when embedded program operation
CN108628726B (en) * 2017-03-22 2021-02-23 比亚迪股份有限公司 CPU state information recording method and device
CN116048049B (en) * 2023-01-18 2024-05-14 重庆长安汽车股份有限公司 Diagnostic optimization method, device, equipment and medium for automobile ECU software system
CN116701042B (en) * 2023-07-27 2023-10-13 飞腾信息技术有限公司 Memory data retention method, retention device and related equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291590A (en) * 2017-05-24 2017-10-24 珠海金山网络游戏科技有限公司 A kind of system and method for detecting CPU usage and automatically generating performance evaluation file

Also Published As

Publication number Publication date
CN101118514A (en) 2008-02-06

Similar Documents

Publication Publication Date Title
CN100501693C (en) Method and memory used for analyzing software system CPU occupancy rate
CN101615143B (en) Method and device for diagnosing memory leak
CA2753019C (en) Monitoring of distributed applications
RU2526711C2 (en) Service performance manager with obligation-bound service level agreements and patterns for mitigation and autoprotection
US8286134B2 (en) Call stack sampling for a multi-processor system
CN103577335B (en) A kind of internal memory garbage retrieving system and method
CN106487574A (en) Automatic operating safeguards monitoring system
US20100017583A1 (en) Call Stack Sampling for a Multi-Processor System
CN102541634A (en) Probe insertion via background virtual machine
CN109460343A (en) System exception monitoring method, device, equipment and storage medium based on log
CN112800017B (en) Distributed log collection method, device, medium and electronic equipment
US20080126158A1 (en) System and Method for Categorizing Activities in Computer-Accessible Environments
CN101859268A (en) Context switch sampling
CN110147470B (en) Cross-machine-room data comparison system and method
Weng et al. Kmon: An in-kernel transparent monitoring system for microservice systems with ebpf
CN114154035A (en) Data processing system for dynamic loop monitoring
CN113760652A (en) Method, system, device and storage medium for full link monitoring based on application
CN103309843B (en) The collocation method of server and system
CN110932935A (en) Resource control method, device, equipment and computer storage medium
CN116126621A (en) Task monitoring method of big data cluster and related equipment
KR20190078745A (en) Energy IoT TOC platform distributed processing system
CN108023741A (en) One kind monitoring resource using method and server
CN114490091A (en) Method and device for monitoring rule engine performance in industrial data acquisition management system
CN114090644A (en) Data processing method and device
KR20030041612A (en) A method of realtime analyzing server bottlenecks

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

Granted publication date: 20090617

Termination date: 20150914

EXPY Termination of patent right or utility model