CN107368402A - The method for calculating cpu busy percentage - Google Patents
The method for calculating cpu busy percentage Download PDFInfo
- Publication number
- CN107368402A CN107368402A CN201710556781.6A CN201710556781A CN107368402A CN 107368402 A CN107368402 A CN 107368402A CN 201710556781 A CN201710556781 A CN 201710556781A CN 107368402 A CN107368402 A CN 107368402A
- Authority
- CN
- China
- Prior art keywords
- busy percentage
- cpu busy
- variable
- window
- idlecounter
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3452—Performance evaluation by statistical analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/3024—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Computer Hardware Design (AREA)
- Probability & Statistics with Applications (AREA)
- Evolutionary Biology (AREA)
- Bioinformatics & Computational Biology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a kind of method for calculating cpu busy percentage, it includes:Operating system is obtained to be completely under Idle tasks, in a window period, maximum MaxIdleCounter that variable IdleCounter can add up;Obtain in software normal course of operation, in a window time, variable IdleCounter accumulated value IdleCounterSum in Idle tasks;Cpu busy percentage=1000 (the IdleCounterSum*1000)/MaxIdleCounter.The method of the calculating cpu busy percentage of the present invention need not be not take up hardware resource by specific purpose tool;And do not increase system software overhead, the system start time is not influenceed;In addition, in the present invention, in a cpu busy percentage calculation window, the time that system is in idle task is the accumulated value secondary indication by variable, independent of hardware, there is preferable versatility.
Description
Technical field
The present invention relates to embedded real-time control field, more particularly to a kind of method for calculating cpu busy percentage.
Background technology
In embedded real-time control field, cpu busy percentage measurement be in real-time control software development process one it is important
Work, cpu busy percentage is mainly for assessment of Control System Software reliability of operation and controller hardware chip type selecting.Such as China
Patent of invention (authorize publication number CN101493789, authorized announcement date on July 29th, 2009) discloses a kind of CPU that obtains and utilized
The method and device of rate, methods described include:In a threshold time, poll total number of instructions and the service order for counting CPU are total
Number;The utilization rate of the CPU is calculated according to the poll total number of instructions and service order sum.The method needs when realizing
Will be by the poll instruction in specific purpose tool Statisti-cal control system software and service order.
Chinese invention patent (authorize publication number CN104077209A, authorized announcement date on October 1st, 2014) discloses one
The method that kind determines processor utilization, including:Clock is passed when being performed via the first counter on processor to code
Cycle counting number;Total counting number via the second counter on processor to the free-running operation clock cycle;Held with by code
Clock periodicity divided by the sum of free-running operation clock cycle during row, to determine cpu busy percentage.The method needs extra take
Two-way hardware timer resource.In uC/OS II operating systems, a statistics task statistics cpu busy percentage is specially devised,
The cpu busy percentage calculating cycle that is delayed is needed to realize statistics task function, when system has been moved.The method needs
Additionally one task of increase, and the system time starting time is longer in system.
The content of the invention
It is an object of the present invention to provide a kind of method for calculating cpu busy percentage, and it need not be not take up hard by specific purpose tool
Part resource;And do not increase system software overhead, the system start time is not influenceed.
The present invention solves technical problem and adopted the following technical scheme that:A kind of method for calculating cpu busy percentage, it includes:
Obtain operating system to be completely under Idle tasks, in a window period, variable IdleCounter can add up
Maximum MaxIdleCounter;
Obtain in software normal course of operation, in a window time, variable IdleCounter's is cumulative in Idle tasks
Value IdleCounterSum;
Cpu busy percentage=1000- (the IdleCounterSum*1000)/MaxIdleCounter.
Optionally, after os starting, create conditions, make operating system be in Idle states maintain a window when
Between, a variable IdleCounter accumulation operations are performed in Idle tasks, calculate a window time, variable can add up
Maximum, to obtain MaxIdleCounter.
Optionally, in a particular task or interruption, to calculate cpu busy percentage window time as the cycle, one is set
Window timeout flag position;According to the flag bit, whether set decides whether that carrying out a cpu busy percentage calculates to Idle tasks.
The present invention has the advantages that:The present invention calculating cpu busy percentage method need not by specific purpose tool,
It is not take up hardware resource;And do not increase system software overhead, the system start time is not influenceed;In addition, in the present invention, one
In cpu busy percentage calculation window, the time that system is in idle task is the accumulated value secondary indication by variable, independent of
In hardware, there is preferable versatility.
Brief description of the drawings
Fig. 1 is the method schematic diagram of the calculating cpu busy percentage of the present invention;
Fig. 2 is the implementation process schematic diagram of the calculating cpu busy percentage of the present invention;
Embodiment
Technical scheme is further elaborated with reference to embodiment and accompanying drawing.
Embodiment 1
A kind of method for calculating cpu busy percentage is present embodiments provided, based on embedded OS, in Idle tasks
In, with certain window period, calculate CPU utilization rate.
Cpu busy percentage=1000- (the IdleCounterSum*1000)/MaxIdleCounter;Wherein
MaxIdleCounter is that operating system is completely under Idle tasks, and in a window period, IdleCounter can add up
Maximum, in operating system actual motion, MaxIdleCounter directly uses precalculated value.
IdleCounterSum be software normal course of operation in, in a window time, variable in Idle tasks
IdleCounter accumulated value.
In the present embodiment, the cpu busy percentage is using a window time as cycle real-time update.
CPU is in the time of Idle states, by the following method secondary indication.A variable is performed in Idle tasks
The accumulation operations of (such as IdleCounter), variable accumulated value correspond to the time that CPU is in Idle states.
After os starting, create conditions, operating system is in Idle states (operation Idle tasks) and maintain one
Individual window time, variable (such as IdleCounter) accumulation operations are performed in Idle tasks, when calculating a window
Between, maximum that variable can add up, to obtain MaxIdleCounter.
In a particular task or interruption, to calculate cpu busy percentage window time as the cycle, a window time-out is set
Flag bit.According to the flag bit, whether set decides whether that carrying out a cpu busy percentage calculates to Idle tasks.
In a window period, the time that CPU is in Idle tasks passes through the IdleCounter indirect table of accumulated value
Show.The window period timeout flag position for calculating cpu busy percentage is configured by task TASK A, according to calculating cpu busy percentage
Window requirements, also other tasks in selectively actuatable system.
As shown in Fig. 2 the method implementation process that calculating CPU is utilized is in two stages, first stage is to calculate operation
System is completely under Idle tasks, a calculating cpu busy percentage window period, the maximum that variable IdleCounter can add up,
This stage, which needs to create conditions, to be ensured that other tasks are not run in system and (such as waits one to calculate CPU utilizations in initialization task
Rate window time, then starting other tasks).Second stage is in running, is directly counted using the first stage
The maximum MaxIdleCounter that IdleCounter can add up is calculated, calculates cpu busy percentage according to the method described above.
The sequencing of above example only for ease of describing, does not represent the quality of embodiment.
Finally it should be noted that: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.
Claims (3)
- A kind of 1. method for calculating cpu busy percentage, it is characterised in that including:Obtain operating system to be completely under Idle tasks, in a window period, variable IdleCounter can add up most Big value MaxIdleCounter;Obtain in software normal course of operation, in a window time, variable IdleCounter accumulated value in Idle tasks IdleCounterSum;Cpu busy percentage=1000- (the IdleCounterSum*1000)/MaxIdleCounter.
- 2. the method according to claim 1 for calculating cpu busy percentage, it is characterised in that after os starting, create Condition, operating system is in Idle states and maintain a window time, a variable is performed in Idle tasks IdleCounter accumulation operations, calculate a window time, the maximum that variable can add up, to obtain MaxIdleCounter。
- 3. the method according to claim 2 for calculating cpu busy percentage, it is characterised in that in a particular task or interruption In, to calculate cpu busy percentage window time as the cycle, a window timeout flag position is set;Idle tasks are according to the flag bit Whether set decides whether that carrying out a cpu busy percentage calculates.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710556781.6A CN107368402A (en) | 2017-07-10 | 2017-07-10 | The method for calculating cpu busy percentage |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710556781.6A CN107368402A (en) | 2017-07-10 | 2017-07-10 | The method for calculating cpu busy percentage |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107368402A true CN107368402A (en) | 2017-11-21 |
Family
ID=60305236
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710556781.6A Pending CN107368402A (en) | 2017-07-10 | 2017-07-10 | The method for calculating cpu busy percentage |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107368402A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109933487A (en) * | 2017-12-19 | 2019-06-25 | 深圳光启合众科技有限公司 | The monitoring method and device of intelligent robot |
CN110941325A (en) * | 2019-10-17 | 2020-03-31 | 华为技术有限公司 | Frequency modulation method and device of processor and computing equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1664789A (en) * | 2004-03-04 | 2005-09-07 | 中兴通讯股份有限公司 | Method for real-time CPU occupation rate detection of operating systems |
CN101165657A (en) * | 2006-10-16 | 2008-04-23 | 大唐移动通信设备有限公司 | Microprocessor occupancy rate statistic method |
CN101344865A (en) * | 2008-08-15 | 2009-01-14 | 中兴通讯股份有限公司 | CPU occupancy rate measuring method and apparatus |
CN103164321A (en) * | 2013-03-20 | 2013-06-19 | 华为技术有限公司 | Occupancy rate measuring method and device of central processing unit |
KR20140039527A (en) * | 2012-09-24 | 2014-04-02 | 주식회사 좋은친구 | Hacking monitoring method, media recorded with program for hacking monitoring, and terminal embedded with program for hacking monitoring |
CN104077209A (en) * | 2013-03-29 | 2014-10-01 | 通用汽车环球科技运作有限责任公司 | Method of calculating cpu utilization |
-
2017
- 2017-07-10 CN CN201710556781.6A patent/CN107368402A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1664789A (en) * | 2004-03-04 | 2005-09-07 | 中兴通讯股份有限公司 | Method for real-time CPU occupation rate detection of operating systems |
CN101165657A (en) * | 2006-10-16 | 2008-04-23 | 大唐移动通信设备有限公司 | Microprocessor occupancy rate statistic method |
CN101344865A (en) * | 2008-08-15 | 2009-01-14 | 中兴通讯股份有限公司 | CPU occupancy rate measuring method and apparatus |
KR20140039527A (en) * | 2012-09-24 | 2014-04-02 | 주식회사 좋은친구 | Hacking monitoring method, media recorded with program for hacking monitoring, and terminal embedded with program for hacking monitoring |
CN103164321A (en) * | 2013-03-20 | 2013-06-19 | 华为技术有限公司 | Occupancy rate measuring method and device of central processing unit |
CN104077209A (en) * | 2013-03-29 | 2014-10-01 | 通用汽车环球科技运作有限责任公司 | Method of calculating cpu utilization |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109933487A (en) * | 2017-12-19 | 2019-06-25 | 深圳光启合众科技有限公司 | The monitoring method and device of intelligent robot |
CN109933487B (en) * | 2017-12-19 | 2024-05-07 | 潘明旭 | Intelligent robot monitoring method and device |
CN110941325A (en) * | 2019-10-17 | 2020-03-31 | 华为技术有限公司 | Frequency modulation method and device of processor and computing equipment |
CN110941325B (en) * | 2019-10-17 | 2022-05-06 | 华为技术有限公司 | Frequency modulation method and device of processor and computing equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101236513B (en) | Distributed task system and distributed task management process | |
EP2819009A3 (en) | Task scheduling for highly concurrent analytical and transaction workloads | |
CN103268247B (en) | Method and device for executing task and adjusting number of remaining threads in thread pool | |
EP2701074A1 (en) | Method, device, and system for performing scheduling in multi-processor core system | |
CN103294533A (en) | Task flow control method and task flow control system | |
CN102110015B (en) | Method and device for determining task progress and task processing time | |
RU2015114568A (en) | AUTOMATED RESOURCE USE PROFILING | |
JP2004533674A5 (en) | ||
CN104915253A (en) | Work scheduling method and work processor | |
CN106598740B (en) | System and method for limiting CPU utilization rate occupied by multithreading program | |
US20130047158A1 (en) | Method and System for Real Time Detection of Resource Requirement and Automatic Adjustments | |
WO2009057208A1 (en) | Resource assignment program, management node, resource assignment method, and parallel computer system | |
WO2021253851A1 (en) | Cluster distributed resource scheduling method, apparatus and device, and storage medium | |
JP2014033367A5 (en) | ||
CN107368402A (en) | The method for calculating cpu busy percentage | |
CN107624181B (en) | Virtual machine management method and apparatus including idling and scheduling of virtual processors | |
EP3935503A1 (en) | Capacity management in a cloud computing system using virtual machine series modeling | |
KR101770736B1 (en) | Method for reducing power consumption of system software using query scheduling of application and apparatus for reducing power consumption using said method | |
CN104820616A (en) | Task scheduling method and device | |
CN104102513A (en) | Kepler-architecture based CUDA (compute unified device architecture) runtime parameter transparent-optimization method | |
CN108132840B (en) | Resource scheduling method and device in distributed system | |
CN105511937A (en) | Batch virtual machine blue screen monitoring method suitable for cloud platform | |
JP2013149221A (en) | Control device for processor and method for controlling the same | |
CN109992314A (en) | Data reporting method, device, terminal and storage medium | |
US20160055037A1 (en) | Analysis controller, analysis control method and computer-readable medium |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20171121 |