TWI447557B - System and method for analyzing a cpu usage rate - Google Patents

System and method for analyzing a cpu usage rate Download PDF

Info

Publication number
TWI447557B
TWI447557B TW098117036A TW98117036A TWI447557B TW I447557 B TWI447557 B TW I447557B TW 098117036 A TW098117036 A TW 098117036A TW 98117036 A TW98117036 A TW 98117036A TW I447557 B TWI447557 B TW I447557B
Authority
TW
Taiwan
Prior art keywords
thread
cpu
time
cpu usage
hardware timer
Prior art date
Application number
TW098117036A
Other languages
Chinese (zh)
Other versions
TW201042419A (en
Inventor
Chi Hsien Chen
Original Assignee
Chi Mei Comm Systems Inc
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 Chi Mei Comm Systems Inc filed Critical Chi Mei Comm Systems Inc
Priority to TW098117036A priority Critical patent/TWI447557B/en
Publication of TW201042419A publication Critical patent/TW201042419A/en
Application granted granted Critical
Publication of TWI447557B publication Critical patent/TWI447557B/en

Links

Landscapes

  • Debugging And Monitoring (AREA)

Description

CPU使用率分析系統及方法CPU usage analysis system and method

本發明涉及一種CPU使用率分析系統及方法,尤其涉及一種應用於移動裝置中的CPU使用率分析系統及方法。The present invention relates to a CPU usage analysis system and method, and more particularly to a CPU usage analysis system and method for use in a mobile device.

ARM(Advanced RISC Machines)架構之移動裝置(如手機和PDA等)大部分採用Nucleus作業系統,在Nucleus作業系統中並沒有Windows作業系統所提供的工作管理員程式,讓用戶可以查看CPU使用率,以便分析瞭解移動裝置的性能。ARM (Advanced RISC Machines) architecture mobile devices (such as mobile phones and PDAs) mostly use the Nucleus operating system. In the Nucleus operating system, there is no work administrator program provided by the Windows operating system, allowing users to view CPU usage. In order to analyze the performance of mobile devices.

目前,部分移動裝置可以透過軟體計時器(如日誌管理軟體,Software Log)來計算CPU的使用率,但使用軟體計時器計算獲得的結果不夠精確。At present, some mobile devices can calculate the CPU usage through a software timer (such as the software management software, Software Log), but the results obtained by using the software timer calculation are not accurate enough.

鑒於以上內容,有必要提供一種CPU使用率分析系統及方法,其可精確計算出移動裝置的CPU使用率。In view of the above, it is necessary to provide a CPU usage analysis system and method that can accurately calculate the CPU usage of a mobile device.

所述CPU使用率分析系統,應用於移動裝置中,該移動裝置配置有硬體計時器。所述系統包括:參數設置模組,用於設置CPU使用率分析週期和每次分析的時間長度;時間讀取模組,用於在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器的當前時間,並將該硬體計時器的值重設為最大值,同時,移動裝置作業系統中的任務調度列表決定下一個執行的線程;計算模組,用於根據所讀取的硬體計時器的當前時間計算該被掛起的線程佔用CPU的時間,並將該計算的時間儲存在一個陣列元素中,該被掛起的線程佔用CPU的時間等於硬體計時器的最大值減去硬體計時器的當前時間;所述計算模組,還用於當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。The CPU usage analysis system is applied to a mobile device configured with a hardware timer. The system includes: a parameter setting module for setting a CPU usage analysis period and a length of time for each analysis; and a time reading module for suspending a thread during each CPU usage analysis period Reading the current time of the hardware timer and resetting the value of the hardware timer to the maximum value. At the same time, the task scheduling list in the mobile device operating system determines the next executed thread; Calculating the time taken by the suspended thread to occupy the CPU according to the current time of the read hardware timer, and storing the calculated time in an array element, the suspended thread occupies the CPU time equal to hard The maximum value of the body timer minus the current time of the hardware timer; the calculation module is further configured to calculate the CPU usage rate according to the values of all the elements in the array when the time length of each analysis arrives.

所述CPU使用率分析方法,應用於移動裝置中,該移動裝置配置有硬體計時器。該方法包括如下步驟:設置CPU使用率分析週期和每次分析的時間長度;在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器的當前時間,並將該硬體計時器的值重設為最大值,同時,移動裝置作業系統中的任務調度列表決定下一個執行的線程;根據所讀取的硬體計時器的當前時間計算該被掛起的線程佔用CPU的時間,並將該計算的時間儲存在一個陣列元素中,該被掛起的線程佔用CPU的時間等於硬體計時器的最大值減去硬體計時器的當前時間;當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。The CPU usage analysis method is applied to a mobile device configured with a hardware timer. The method includes the steps of: setting a CPU usage analysis period and a length of time for each analysis; during each CPU usage analysis period, when a thread is suspended, reading the current time of the hardware timer, and The value of the hardware timer is reset to the maximum value, and the task scheduling list in the mobile device operating system determines the next executed thread; the suspended thread is calculated according to the current time of the read hardware timer Occupies the CPU time, and stores the calculated time in an array element. The time that the suspended thread occupies the CPU is equal to the maximum value of the hardware timer minus the current time of the hardware timer; When the length of time arrives, the CPU usage is calculated based on the values of all the elements in the array.

相較於習知技術,所述的CPU使用率分析系統及方法,應用於移動裝置中,可以精確計算出移動裝置的CPU使用率。Compared with the prior art, the CPU usage analysis system and method are applied to a mobile device, and the CPU usage of the mobile device can be accurately calculated.

參閱圖1所示,係本發明CPU使用率分析系統較佳實施方式的硬體架構圖。該系統應用於移動裝置中(本實施方式以手機為例進行說明),主要包括中央處理器(Central Processing Unit,CPU)1、儲存器2、輸入/輸出設備3及手機主板4。所述中央處理器1分別與所述儲存器2、輸入/輸出設備3和手機主板4相連,該儲存器2與手機主板4相連。輸入/輸出設備3包括LCD液晶顯示螢幕和鍵盤等,用於顯示資料及輸入資訊。其中,所述儲存器2包括作業系統21和CPU使用率分析單元20。Referring to FIG. 1, a hardware architecture diagram of a preferred embodiment of a CPU usage analysis system of the present invention is shown. The system is applied to a mobile device (the mobile phone is taken as an example in the embodiment), and mainly includes a central processing unit (CPU) 1, a memory 2, an input/output device 3, and a mobile phone motherboard 4. The central processing unit 1 is connected to the storage unit 2, the input/output device 3 and the mobile phone main board 4, and the storage unit 2 is connected to the mobile phone main board 4. The input/output device 3 includes an LCD liquid crystal display screen and a keyboard for displaying data and inputting information. The storage 2 includes a work system 21 and a CPU usage analysis unit 20.

所述作業系統21中包含有任務調度列表,該任務調度列表用於控制線程的執行。例如,當一個線程被掛起後,任務調度列表將決定下一個執行的線程。The operating system 21 includes a task scheduling list for controlling execution of the thread. For example, when a thread is suspended, the task schedule list will determine the next thread to execute.

所述中央處理器1用於調用所述CPU使用率分析單元20,並控制該CPU使用率分析單元20的執行。該CPU使用率分析單元20用於利用手機主板4中的硬體計時器40計算CPU的使用率。The central processing unit 1 is configured to call the CPU usage analysis unit 20 and control the execution of the CPU usage analysis unit 20. The CPU usage analysis unit 20 is configured to calculate the CPU usage rate using the hardware timer 40 in the mobile phone motherboard 4.

所述硬體計時器40內嵌於手機主板4中,該硬體計時器40可以是Time1計時器、Time2計時器和Watchdog計時器(看門狗計時器)等,本實施方式中採用Time2計時器。硬體計時器40可以精確到納秒(ns),如Time2計時器的精確度可以達到2.4623納秒,而軟體計時器只能精確到毫秒(ms),一般為4.615毫秒。The hardware timer 40 is embedded in the mobile phone motherboard 4, and the hardware timer 40 can be a Time1 timer, a Time2 timer, and a Watchdog timer (watchdog timer). In this embodiment, the Time2 timer is used. Device. The hardware timer 40 can be accurate to nanoseconds (ns). For example, the accuracy of the Time2 timer can reach 2.4623 nanoseconds, while the software timer can only be accurate to milliseconds (ms), typically 4.615 milliseconds.

參閱圖2所示,係圖1中所示CPU使用率分析單元20的功能模組圖。所述CPU使用率分析單元20包括參數設置模組201、線程設定模組202、時間讀取模組203及計算模組204。本發明所稱的模組是完成一特定功能的電腦程式段,比程式更適合於描述軟體在電腦中的執行過程,因此在本發明以下對軟體描述中都以模組描述。Referring to FIG. 2, it is a functional module diagram of the CPU usage analysis unit 20 shown in FIG. 1. The CPU usage analysis unit 20 includes a parameter setting module 201, a thread setting module 202, a time reading module 203, and a computing module 204. The module referred to in the present invention is a computer program segment for performing a specific function, and is more suitable for describing the execution process of the software in the computer than the program. Therefore, the following description of the software is described in the module.

所述參數設置模組201用於設置CPU使用率分析週期和每次分析的時間長度,其中,每次分析的時間長度從每次CPU使用率分析週期到達的時刻開始計時,且每次分析的時間長度小於或等於CPU使用率分析週期。假設CPU使用率分析週期為10分鐘,每次分析的時間長度為100秒,則每隔10分鐘,分析當前CPU在100秒內的使用率。The parameter setting module 201 is configured to set a CPU usage analysis period and a length of time for each analysis, wherein the length of each analysis starts from the time when the CPU usage analysis period arrives, and each analysis is performed. The length of time is less than or equal to the CPU usage analysis period. Assuming that the CPU usage analysis period is 10 minutes and the length of each analysis is 100 seconds, the usage rate of the current CPU in 100 seconds is analyzed every 10 minutes.

所述線程設定模組202用於設定一個優先順序最低的線程作為空閒運轉線程,並將該空閒運轉線程放置於一個無限迴圈中,以防止作業系統21進入休眠模式。該空閒運轉線程可以是新增的Idle(空閒)線程,或是將現有的一個線程設置成最低優先順序以作為空閒運轉線程。The thread setting module 202 is configured to set a thread with the lowest priority as an idle running thread, and place the idle running thread in an infinite loop to prevent the operating system 21 from entering the sleep mode. The idle running thread may be a new Idle thread or set an existing thread to the lowest priority order as an idle running thread.

所述時間讀取模組203用於在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器40的當前時間。同時,作業系統21的任務調度列表將決定下一個執行的線程。每次讀取完硬體計時器40的當前時間後,時間讀取模組203都將該硬體計時器40的值重設為最大值。在本實施方式中,硬體計時器40的最大值為:0XFFFF。The time reading module 203 is configured to read the current time of the hardware timer 40 when a thread is suspended during each CPU usage analysis period. At the same time, the task scheduling list of the operating system 21 will determine the next thread to execute. The time reading module 203 resets the value of the hardware timer 40 to the maximum value each time the current time of the hardware timer 40 is read. In the present embodiment, the maximum value of the hardware timer 40 is 0×FFFF.

其中,一個線程被掛起的情形包括:Among them, a situation in which a thread is suspended includes:

(1)該線程執行完畢;(1) The thread is executed;

(2)當該線程運行時,作業系統21發出一個中斷請求;(2) When the thread is running, the operating system 21 issues an interrupt request;

(3)當該線程運行時,有其它更高優先順序的線程需要執行,該線程主動釋放一個訊號量而被掛起。(3) When the thread is running, there are other higher priority threads that need to be executed. The thread actively releases a signal and is suspended.

所述計算模組204用於根據硬體計時器40的當前時間計算該被掛起的線程佔用CPU的時間,並將其儲存在一個陣列元素中。其中,該被掛起的線程佔用CPU的時間等於硬體計時器40的最大值減去硬體計時器40的當前時間。The computing module 204 is configured to calculate the time that the suspended thread occupies the CPU according to the current time of the hardware timer 40, and store it in an array element. The time that the suspended thread occupies the CPU is equal to the maximum value of the hardware timer 40 minus the current time of the hardware timer 40.

所述計算模組204還用於當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。具體而言,首先,計算模組204加總該陣列中所有元素得到所有線程佔用CPU的時間之和,然後,計算出每個線程佔用CPU的平均時間,該每個線程佔用CPU的平均時間為所有線程佔用CPU的時間之和除以本次週期內執行的線程個數。最後,計算出本次週期內CPU的使用率,該CPU的使用率等於每個線程佔用CPU的平均時間除以每次分析的時間長度。The computing module 204 is further configured to calculate the CPU usage rate according to the values of all the elements in the array when the time length of each analysis arrives. Specifically, first, the calculation module 204 sums the total time of all the elements in the array to obtain the CPU usage time of all threads, and then calculates the average time occupied by each thread, and the average time occupied by each thread is The sum of the time taken by all threads to occupy the CPU divided by the number of threads executed during this period. Finally, the CPU usage in this cycle is calculated. The CPU usage is equal to the average time spent by each thread on the CPU divided by the length of each analysis.

舉例而言,假設每次分析的時間長度為100秒,本次週期內執行的線程有3個(Thread A、Thread B和Thread C),其中,Thread A佔用CPU的時間為30秒,Thread B佔用CPU的時間為40秒,Thread C佔用CPU的時間為50秒。則每個線程佔用CPU的平均時間為(30+40+50)/3秒,即40秒,本次週期內CPU的使用率為40/100,即40%。For example, suppose the length of each analysis is 100 seconds. There are 3 threads (Thread A, Thread B, and Thread C) executed in this cycle. Thread A takes up CPU time for 30 seconds. Thread B The CPU usage time is 40 seconds, and the Thread C CPU time is 50 seconds. The average time that each thread occupies the CPU is (30+40+50)/3 seconds, that is, 40 seconds. The CPU usage in this cycle is 40/100, which is 40%.

參閱圖3所示,係本發明CPU使用率分析方法較佳實施方式的流程圖。步驟S1,利用參數設置模組201設置CPU使用率分析週期和每次分析的時間長度。Referring to FIG. 3, it is a flow chart of a preferred embodiment of the CPU usage analysis method of the present invention. In step S1, the CPU usage analysis period and the length of each analysis are set by the parameter setting module 201.

步驟S2,時間讀取模組203在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器40的當前時間。同時,作業系統21的任務調度列表將決定下一個執行的線程。每次讀取完硬體計時器40的當前時間後,時間讀取模組203都將該硬體計時器40的值重設為最大值。在本實施方式中,硬體計時器40的最大值為:0XFFFF。In step S2, the time reading module 203 reads the current time of the hardware timer 40 when a thread is suspended during each CPU usage analysis period. At the same time, the task scheduling list of the operating system 21 will determine the next thread to execute. The time reading module 203 resets the value of the hardware timer 40 to the maximum value each time the current time of the hardware timer 40 is read. In the present embodiment, the maximum value of the hardware timer 40 is 0×FFFF.

其中,一個線程被掛起的情形包括:Among them, a situation in which a thread is suspended includes:

(1)該線程執行完畢;(1) The thread is executed;

(2)當該線程運行時,作業系統21發出一個中斷請求;(2) When the thread is running, the operating system 21 issues an interrupt request;

(3)當該線程運行時,有其它更高優先順序的線程需要執行,該線程主動釋放一個訊號量而被掛起。(3) When the thread is running, there are other higher priority threads that need to be executed. The thread actively releases a signal and is suspended.

步驟S3,計算模組204根據所讀取的硬體計時器40的當前時間計算該被掛起的線程佔用CPU的時間,並將其儲存在一個陣列元素中。其中,該被掛起的線程佔用CPU的時間等於硬體計時器40的最大值減去硬體計時器40的當前時間。In step S3, the calculation module 204 calculates the time taken by the suspended thread to occupy the CPU according to the current time of the read hardware timer 40, and stores it in an array element. The time that the suspended thread occupies the CPU is equal to the maximum value of the hardware timer 40 minus the current time of the hardware timer 40.

步驟S4,計算模組204當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。具體而言,首先,計算模組204加總該陣列中所有元素得到所有線程佔用CPU的時間之和,然後,計算出每個線程佔用CPU的平均時間,該每個線程佔用CPU的平均時間等於所有線程佔用CPU的時間之和除以本次週期內執行的線程個數。最後,計算出本次週期內CPU的使用率,該本次週期內CPU的使用率等於每個線程佔用CPU的平均時間除以每次分析的時間長度。In step S4, the calculation module 204 calculates the CPU usage rate according to the values of all the elements in the array when the time length of each analysis arrives. Specifically, first, the calculation module 204 sums the total time of all the elements in the array to obtain the CPU usage time of all threads, and then calculates the average time occupied by each thread, and the average time occupied by each thread is equal to The sum of the time taken by all threads to occupy the CPU divided by the number of threads executed during this period. Finally, the CPU usage in this cycle is calculated. The CPU usage in this cycle is equal to the average time spent by each thread on the CPU divided by the length of each analysis.

在其它實施方式中,所述方法還可以包括如下步驟:在步驟S2之前,線程設定模組202設定一個優先順序最低的線程作為空閒運轉線程,並將該空閒運轉線程放置於一個無限迴圈中,以防止作業系統21進入休眠模式。該空閒運轉線程可以是新增的Idle線程,或是將現有的一個線程設置成最低優先順序以作為空閒運轉線程。In other embodiments, the method may further include the following steps: before step S2, the thread setting module 202 sets a thread with the lowest priority as the idle running thread, and places the idle running thread in an infinite loop. To prevent the operating system 21 from entering the sleep mode. The idle running thread can be a new Idle thread or set an existing thread to the lowest priority order as an idle running thread.

本實施方式中,所述移動裝置可以為手機或PDA(Personal Digital Assistant,個人數位助理)等具有資料處理功能的電子設備。In this embodiment, the mobile device may be an electronic device with a data processing function such as a mobile phone or a PDA (Personal Digital Assistant).

最後應說明的是,以上實施方式僅用以說明本發明的技術方案而非限制,儘管參照較佳實施方式對本發明進行了詳細說明,本領域的普通技術人員應當理解,可以對本發明的技術方案進行修改或等同替換,而不脫離本發明技術方案的精神和範圍。It should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and the present invention is not limited thereto. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that Modifications or equivalents are made without departing from the spirit and scope of the invention.

1...CPU1. . . CPU

2...儲存器2. . . Storage

3...輸入/輸出設備3. . . Input/output device

4...手機主板4. . . I

20...CPU使用率分析單元20. . . CPU usage analysis unit

21...作業系統twenty one. . . working system

40...硬體計時器40. . . Hardware timer

201...參數設置模組201. . . Parameter setting module

202...線程設定模組202. . . Thread setting module

203...時間讀取模組203. . . Time reading module

204...計算模組204. . . Computing module

S1...設置CPU使用率分析週期和每次分析的時間長度S1. . . Set the CPU usage analysis period and the length of each analysis

S2...當一個線程被掛起時,讀取硬體計時器的當前時間S2. . . The current time to read the hardware timer when a thread is suspended

S3...計算該被掛起的線程佔用CPU的時間,並儲存在一個陣列元素中S3. . . Calculate the time that the suspended thread occupies the CPU and store it in an array element

S4...當分析時間長度到達時,計算CPU的使用率S4. . . Calculate CPU usage when the analysis time length arrives

圖1係本發明CPU使用率分析系統較佳實施方式的硬體架構圖。1 is a hardware architecture diagram of a preferred embodiment of a CPU usage analysis system of the present invention.

圖2係圖1中CPU使用率分析單元的功能模組圖。FIG. 2 is a functional block diagram of the CPU usage analysis unit in FIG. 1.

圖3係本發明CPU使用率分析方法較佳實施方式的流程圖。3 is a flow chart of a preferred embodiment of the CPU usage analysis method of the present invention.

S1...設置CPU使用率分析週期和每次分析的時間長度S1. . . Set the CPU usage analysis period and the length of each analysis

S2...當一個線程被掛起時,讀取硬體計時器的當前時間S2. . . The current time to read the hardware timer when a thread is suspended

S3...計算該被掛起的線程佔用CPU的時間,並儲存在一個陣列元素中S3. . . Calculate the time that the suspended thread occupies the CPU and store it in an array element

S4...當分析時間長度到達時,計算CPU的使用率S4. . . Calculate CPU usage when the analysis time length arrives

Claims (10)

一種CPU使用率分析方法,應用於移動裝置中,該移動裝置配置有硬體計時器,該方法包括如下步驟:設置CPU使用率分析週期和每次分析的時間長度;在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器的當前時間,並將該硬體計時器的值重設為最大值,同時,移動裝置作業系統中的任務調度列表決定下一個執行的線程;根據所讀取的硬體計時器的當前時間計算該被掛起的線程佔用CPU的時間,並將該計算的時間儲存在一個陣列元素中,該被掛起的線程佔用CPU的時間等於硬體計時器的最大值減去硬體計時器的當前時間;及當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。A CPU usage analysis method is applied to a mobile device, the mobile device being configured with a hardware timer, the method comprising the steps of: setting a CPU usage analysis period and a length of time for each analysis; analyzing each CPU usage rate During the period, when a thread is suspended, the current time of the hardware timer is read, and the value of the hardware timer is reset to the maximum value, and the task scheduling list in the mobile device operating system determines the next one. Executing thread; calculating the time taken by the suspended thread to occupy the CPU according to the current time of the read hardware timer, and storing the calculated time in an array element, the suspended thread occupies the CPU The time is equal to the maximum value of the hardware timer minus the current time of the hardware timer; and when the length of each analysis arrives, the CPU usage is calculated based on the values of all the elements in the array. 如申請專利範圍第1項所述之CPU使用率分析方法,其中,在步驟讀取硬體計時器的當前時間之前還包括:設定一個優先順序最低的線程作為空閒運轉線程,並將該空閒運轉線程放置於一個無限迴圈中。The CPU usage analysis method of claim 1, wherein before the current time of reading the hardware timer, the step further comprises: setting a thread with the lowest priority as the idle running thread, and running the idle operation. The thread is placed in an infinite loop. 如申請專利範圍第2項所述之CPU使用率分析方法,其中,所述空閒運轉線程為新增的空閒線程,或是將現有的一個線程設置成最低優先順序以作為空閒運轉線程。The CPU usage analysis method according to claim 2, wherein the idle running thread is a newly added idle thread, or an existing one thread is set to a lowest priority order as an idle running thread. 如申請專利範圍第1項所述之CPU使用率分析方法,其中,所述線程被掛起的情形包括:該線程執行完畢;當該線程運行時,移動裝置的作業系統發出一個中斷請求;當該線程運行時,有其它更高優先順序的線程需要執行,該線程主動釋放一個訊號量而被掛起。The CPU usage analysis method of claim 1, wherein the thread is suspended: the thread is executed; when the thread is running, the mobile device operating system issues an interrupt request; When the thread is running, there are other higher-priority threads that need to be executed. The thread actively releases a signal and is suspended. 如申請專利範圍第1項所述之CPU使用率分析方法,其中,所述步驟根據該陣列中所有元素的值計算出CPU的使用率包括:加總該陣列中所有元素得到所有線程佔用CPU的時間之和;計算出每個線程佔用CPU的平均時間,所述每個線程佔用CPU的平均時間等於所有線程佔用CPU的時間之和除以本次週期內執行的線程個數;及計算出本次週期內CPU的使用率,所述本次週期內CPU的使用率等於每個線程佔用CPU的平均時間除以每次分析的時間長度。The CPU usage analysis method according to claim 1, wherein the step of calculating a CPU usage rate according to values of all elements in the array includes: summing all elements in the array to obtain CPU usage of all threads. The sum of time; calculate the average time that each thread occupies the CPU, the average time taken by each thread to occupy the CPU is equal to the sum of the time of all threads occupying the CPU divided by the number of threads executed in the current cycle; The usage rate of the CPU in the sub-period, the usage rate of the CPU in the current cycle is equal to the average time occupied by the CPU per thread divided by the length of time for each analysis. 一種CPU使用率分析系統,應用於移動裝置中,其中,該移動裝置配置有硬體計時器,所述系統包括:參數設置模組,用於設置CPU使用率分析週期和每次分析的時間長度;時間讀取模組,用於在每個CPU使用率分析週期內,當一個線程被掛起時,讀取硬體計時器的當前時間,並將該硬體計時器的值重設為最大值,同時,移動裝置作業系統中的任務調度列表決定下一個執行的線程;計算模組,用於根據所讀取的硬體計時器的當前時間計算該被掛起的線程佔用CPU的時間,並將該計算的時間儲存在一個陣列元素中,該被掛起的線程佔用CPU的時間等於硬體計時器的最大值減去硬體計時器的當前時間;及所述計算模組,還用於當每次分析的時間長度到達時,根據該陣列中所有元素的值計算出CPU的使用率。A CPU usage analysis system is applied to a mobile device, wherein the mobile device is configured with a hardware timer, and the system includes: a parameter setting module, configured to set a CPU usage analysis period and a length of each analysis a time reading module for reading the current time of the hardware timer and resetting the value of the hardware timer to the maximum when a thread is suspended during each CPU usage analysis period The value, at the same time, the task scheduling list in the mobile device operating system determines the next executed thread; the computing module is configured to calculate the time taken by the suspended thread to occupy the CPU according to the current time of the read hardware timer, And storing the calculated time in an array element, the time that the suspended thread occupies the CPU is equal to the maximum value of the hardware timer minus the current time of the hardware timer; and the computing module is further used When the length of time for each analysis arrives, the CPU usage is calculated based on the values of all elements in the array. 如申請專利範圍第6項所述之CPU使用率分析系統,其中,所述系統還包括:線程設定模組,用於設定一個優先順序最低的線程作為空閒運轉線程,並將該空閒運轉線程放置於一個無限迴圈中。The CPU usage analysis system of claim 6, wherein the system further comprises: a thread setting module, configured to set a thread with the lowest priority as an idle running thread, and place the idle running thread In an infinite circle. 如申請專利範圍第6項所述之CPU使用率分析系統,其中,所述硬體計時器的最大值為:0XFFFF。The CPU usage analysis system of claim 6, wherein the maximum value of the hardware timer is: 0XFFFF. 如申請專利範圍第6項所述之CPU使用率分析系統,其中,所述線程被掛起的情形包括:該線程執行完畢;當該線程運行時,移動裝置的作業系統發出一個中斷請求;當該線程運行時,有其它更高優先順序的線程需要執行,該線程主動釋放一個訊號量而被掛起。The CPU usage analysis system of claim 6, wherein the thread is suspended: the thread is executed; when the thread is running, the mobile device's operating system issues an interrupt request; When the thread is running, there are other higher-priority threads that need to be executed. The thread actively releases a signal and is suspended. 如申請專利範圍第6項所述之CPU使用率分析系統,其中,所述計算模組根據該陣列中所有元素的值計算出CPU的使用率包括:加總該陣列中所有元素得到所有線程佔用CPU的時間之和;計算出每個線程佔用CPU的平均時間,所述每個線程佔用CPU的平均時間等於所有線程佔用CPU的時間之和除以本次週期內執行的線程個數;及計算出本次週期內CPU的使用率,所述本次週期內CPU的使用率等於每個線程佔用CPU的平均時間除以每次分析的時間長度。The CPU usage analysis system according to claim 6, wherein the calculation module calculates the CPU usage rate according to the values of all the elements in the array, including: summing all the elements in the array to obtain all thread occupations. The sum of the time of the CPU; calculate the average time that each thread occupies the CPU, the average time taken by each thread to occupy the CPU is equal to the sum of the time of all threads occupying the CPU divided by the number of threads executed in the current cycle; The usage rate of the CPU in the current cycle, the usage rate of the CPU in the current cycle is equal to the average time occupied by the CPU per thread divided by the length of time for each analysis.
TW098117036A 2009-05-22 2009-05-22 System and method for analyzing a cpu usage rate TWI447557B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW098117036A TWI447557B (en) 2009-05-22 2009-05-22 System and method for analyzing a cpu usage rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW098117036A TWI447557B (en) 2009-05-22 2009-05-22 System and method for analyzing a cpu usage rate

Publications (2)

Publication Number Publication Date
TW201042419A TW201042419A (en) 2010-12-01
TWI447557B true TWI447557B (en) 2014-08-01

Family

ID=45000529

Family Applications (1)

Application Number Title Priority Date Filing Date
TW098117036A TWI447557B (en) 2009-05-22 2009-05-22 System and method for analyzing a cpu usage rate

Country Status (1)

Country Link
TW (1) TWI447557B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW552547B (en) * 2000-12-29 2003-09-11 Intel Corp Operating system-independent method and system of determining CPU utilization
TW200712873A (en) * 2005-09-28 2007-04-01 Mediatek Inc Profiling systems and methods
US20080176583A1 (en) * 2005-10-28 2008-07-24 Skyhook Wireless, Inc. Method and system for selecting and providing a relevant subset of wi-fi location information to a mobile client device so the client device may estimate its position with efficient utilization of resources
US20080320123A1 (en) * 2007-06-21 2008-12-25 John Richard Houlihan Process and methodology for generic analysis of metrics related to resource utilization and performance

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW552547B (en) * 2000-12-29 2003-09-11 Intel Corp Operating system-independent method and system of determining CPU utilization
TW200712873A (en) * 2005-09-28 2007-04-01 Mediatek Inc Profiling systems and methods
US20080176583A1 (en) * 2005-10-28 2008-07-24 Skyhook Wireless, Inc. Method and system for selecting and providing a relevant subset of wi-fi location information to a mobile client device so the client device may estimate its position with efficient utilization of resources
US20080320123A1 (en) * 2007-06-21 2008-12-25 John Richard Houlihan Process and methodology for generic analysis of metrics related to resource utilization and performance

Also Published As

Publication number Publication date
TW201042419A (en) 2010-12-01

Similar Documents

Publication Publication Date Title
Liu et al. Understanding the characteristics of android wear os
CN101876933A (en) Analysis system and method for CPU utilization rate
US7222030B2 (en) Method and apparatus for profiling power performance of software applications
EP2790106A2 (en) Performance measurement unit, processor core including the same and process profiling method
KR101496077B1 (en) Obtaining power profile information with low overhead
US8104036B2 (en) Measuring processor use in a hardware multithreading processor environment
US20180329565A1 (en) Touch gesture detection assessment
US20070050174A1 (en) Method and apparatus for adaptive tracing with different processor frequencies
CN100338581C (en) Operating system-independent method and system of determining CPU utilization
Han et al. E3: Energy-efficient engine for frame rate adaptation on smartphones
US10820274B2 (en) Systems and methods for testing power consumption of electronic devices
WO2017039892A1 (en) Estimation of application performance variation without a priori knowledge of the application
CN1495585A (en) Method for defining CPU operation factor regardless of operation system and system
Mukhanov et al. Alea: A fine-grained energy profiling tool
US10275007B2 (en) Performance management for a multiple-CPU platform
CN110990243A (en) Caton analysis method and device, storage medium and computing equipment
Inam et al. Bandwidth measurement using performance counters for predictable multicore software
Liu et al. Anatomizing system activities on interactive wearable devices
CN107423206B (en) Method and device for measuring system management interruption time
Mukherjee et al. Energy management of applications with varying resource usage on smartphones
CN107436839B (en) Process load acquisition method, electronic terminal and computer readable storage medium
US20070005860A1 (en) Interrupt control system and method
CN106445698B (en) Method and device for acquiring step counting data
TWI447557B (en) System and method for analyzing a cpu usage rate
CN106648916B (en) Method and device for reporting pedometer message

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees