Abstract:
A CPU control method and apparatus for improving application processing speed and power consumption are provided. An embodiment of the invention provides a method by which a CPU control apparatus controls a CPU, where the CPU control method includes: (a) measuring a reaction time of a user terminal for a running application; (b) computing a first predictive reaction time by stepwise changing a CPU frequency if the reaction time exceeds a preset threshold; (c) computing a second predictive reaction time by stepwise changing a processing weight of the application if the first predictive reaction time exceeds the preset threshold; and (d) repeating said step (c) if the second predictive reaction time exceeds the preset threshold.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims the benefit of Korean Patent Application No. 10-2014-0127639, filed with the Korean Intellectual Property Office on Sep. 24, 2014, the disclosure of which is incorporated herein by reference in its entirety. 
       BACKGROUND 
       [0002]    1. Technical Field 
         [0003]    The present invention relates to a method and apparatus for controlling a CPU, more particularly to a CPU control technology for improving application processing speed and improving power consumption in an embedded system. 
         [0004]    2. Description of the Related Art 
         [0005]    An important goal of research in mobile systems such as smart phones and tablet computers is to reduce power consumption while maintaining the level of performance of the applications. 
         [0006]    Recently, as applications grow in complexity and require fast processing, the performance of hardware such as CPU&#39;s, GPU&#39;s, and RAM is likewise increasing to support such requirements. However, such requirements may increase power consumption and may result in shorter battery life. 
         [0007]    To improve power consumption, many Android-based smart devices adopt Dynamic Voltage and Frequency Scaling (DVFS) technology. 
         [0008]    DVFS is a technique of reducing power consumption by reducing CPU frequency and voltage. Since the power consumed by a CPU is proportion to the CPU frequency, DVFS can reduce the power consumption of the CPU by reducing the frequency of the CPU. 
         [0009]    However, reducing the CPU frequency also means reducing the processing speed and thus results in slower reaction times for interactive applications. 
         [0010]    Generally, the ‘response time’ refers to the time between a user&#39;s input and the system&#39;s reaction. Many applications that are run on a smart device may employ a user interface (UI) as an interactive application. 
         [0011]    Other examples of interactive applications include games, web browsers, image editors, etc. 
         [0012]    In an interactive application, the reaction time is a very important factor. Although it may be different for each user, there have been research results that indicate that a typical user feels inconvenienced when the reaction time exceeds 150 ms. 
         [0013]    Thus, it is highly important that the reaction time stay within this threshold time. 
         [0014]    Also, since a smart device provides multi-tasking functionality, the interactive application may be run simultaneously with several background applications. 
         [0015]    In such an environment, the interactive application and the background applications have to share a limited amount of CPU resources, which makes it even more difficult for the interactive application to meet the threshold for the reaction time. 
         [0016]    A CPU scheduler serves to distribute the CPU resources to tasks that are running, and as such, has a great impact on the performances of the tasks. 
         [0017]    One example of a CPU scheduler, the Completely Fair Scheduler (CFS), is a default scheduler that has been used since Linux Kernel 2.6.23. The CFS was designed with the goal of ensuring fairness to the tasks that are running and applies the same processing weight on all applications running on an Android-based smart device. 
         [0018]    Thus, when the CFS is used, a problem may occur of the interactive application showing a slow reaction time when the interactive application is running concurrently with background applications. 
         [0019]    Thus, the DVFS technology based on CPU loads as found in the related art can cause in an inefficient increase in CPU frequency when there is a high CPU load on the background applications, resulting in wasteful power consumption, and can provide a slow reaction time when an interactive application is running if the CPU frequency is not quickly increased. 
       SUMMARY OF THE INVENTION 
       [0020]    An aspect of the invention, devised to resolve the problems in the related art described above, is to provide a way to adjust the CPU frequency and the processing weight of an interactive application in order to reduce power consumption while satisfying the threshold for the reaction time of the interactive application. 
         [0021]    To achieve the objective above, an embodiment of the invention provides a method by which a CPU control apparatus controls a CPU, where the CPU control method includes: (a) measuring a reaction time of a user terminal for a running application; (b) computing a first predictive reaction time by stepwise changing a CPU frequency if the reaction time exceeds a preset threshold; (c) computing a second predictive reaction time by stepwise changing a processing weight of the application if the first predictive reaction time exceeds the preset threshold; and (d) repeating said step (c) if the second predictive reaction time exceeds the preset threshold. 
         [0022]    To achieve the objective above, an embodiment of the invention provides a CPU control apparatus for controlling a CPU that includes: a reaction time measurement part configured to measure a reaction time of a user terminal for a running application; a reaction time prediction part configured to compute a first predictive reaction time by stepwise changing a CPU frequency if the reaction time exceeds a preset threshold and configured to compute a second predictive reaction time by stepwise changing a processing weight of the application if the first predictive reaction time exceeds the preset threshold; and a control part configured to control the reaction time prediction part to re-compute the second predictive reaction time if the second predictive reaction time exceeds the preset threshold. 
         [0023]    According to an embodiment of the invention, a technique of adjusting the CPU frequency and the priority of the interactive application simultaneously is applied, to provide superior performance in terms of power consumption and reaction time, compared to the existing method which adjusts the CPU frequency based on the load on the CPU and causes wasteful power consumption and slow reaction time. 
         [0024]    Moreover, whereas existing methods cannot improve both power consumption and reaction time simultaneously, an embodiment of the present invention may concurrently adjust the CPU frequency and the processing weight of the interactive application to simultaneously improve power consumption and the reaction time. 
         [0025]    Additional aspects and advantages of the present invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0026]      FIG. 1  illustrates the composition of a CPU control apparatus for improving application processing speed and power consumption according to an embodiment of the invention. 
           [0027]      FIG. 2  is a flowchart illustrating the procedures of controlling a CPU for improving application processing speed and power consumption according to an embodiment of the invention. 
           [0028]      FIG. 3 ,  FIG. 4 ,  FIG. 5 , and  FIG. 6  are graphs of actual test results that show how the power consumption was improved in a smart device by the control of the CPU for improving application processing speed and power consumption according to an embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0029]    The present invention will be described below with reference to the accompanying drawings. However, the present invention can be implemented in several different forms and is not limited to the embodiments described herein. 
         [0030]    In order to describe embodiments of the present invention with greater clarity, certain parts have been omitted in the drawings, and like reference numerals have been used for like parts throughout the specification. 
         [0031]    In the specification, the description that a part is “connected” to another part refers not only to those cases in which the parts are “connected directly” but also to those cases in which the parts are “connected indirectly” by way of one or more other members interposed therebetween. 
         [0032]    Also, the description that a part “includes” a component means that additional components may further be included and does not preclude the existence of other components unless specifically indicated. 
         [0033]    Certain embodiments of the invention will now be described in more detail with reference to the accompanying drawings. 
         [0034]      FIG. 1  illustrates the composition of a CPU control apparatus for improving application processing speed and power consumption according to an embodiment of the invention. 
         [0035]    The CPU control apparatus  100  for improving application processing speed and power consumption according to an embodiment of the invention can estimate the reaction time of a smart device in real time by using a reaction time prediction model for the user terminal, and thereby calculate the optimal CPU frequency and processing weight of the interactive application that can minimize power consumption while satisfying the threshold for the reaction time, to apply them to the smart device. 
         [0036]    For this, the CPU control apparatus  100  can include a reaction time measurement part  110 , a reaction time prediction part  120 , and a control part  130 . 
         [0037]    Looking at each component in more detail, the reaction time measurement part  110  can measure the service time of the interactive application (hereinafter referred to as the “application”) and the reaction time of the smart device. 
         [0038]    Here, the reaction time measurement part  110  can measure the service time of the application by using Equation 1 shown below. 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       T 
                       S 
                     
                      
                     
                       ( 
                       f 
                       ) 
                     
                   
                   = 
                   
                     
                       α 
                       f 
                     
                     + 
                     β 
                   
                 
               
               
                 
                   [ 
                   
                     Equation 
                      
                     
                         
                     
                      
                     1 
                   
                   ] 
                 
               
             
           
         
       
     
         [0039]    Here, α represents the amount of processing of application tasks that are affected by the CPU frequency, β represents the amount of processing of application tasks that are not affected by the CPU frequency, and f represents the frequency of the currently operating CPU. 
         [0040]    While the processing speed is determined according to the CPU frequency for most tasks, some of the tasks are not affected by CPU frequency and require absolute amounts of time. The model as represented by Equation 1 was thus designed to reflect this. 
         [0041]    Also, the reaction time measurement part  110  can measure the reaction time T R (f CPU , n*) where the CPU frequency is f CPU  and the processing weight for a target application is n*. 
         [0042]    Here, the “target application” can refer to the application that is currently shown to the user from among the several applications running on the smart device, and the “processing weight” can refer to the priority of a task, an example of the processing weight being the nice value used in Linux kernel version 3.4.0. 
         [0043]    Incidentally, the reaction time measurement part  110  can measure the service time of an application by using Equation 1 above or by using a different method. 
         [0044]    For example, the measurement can be performed using utime and stime, which are the fourteenth and fifteenth values of /proc/{PID}/stat that is provided for each application having different process identifiers (PID) in Linux kernel version 3.4.0. 
         [0045]    Here, utime t  and stime t  are the times during which each application received processing by the CPU in the user mode and the kernel mode since the first operation of the application up to a time t. 
         [0046]    Using utime t  and stime t  to express T S (n *), which is the service time during which an application having a nice value of n* received processing by the CPU between t 1  and t 2 : 
         [0000]        T   s ( n *)=[{ u time t     2   ( n *)+ s time t     2   ( n *)}−{ u time t     1   ( n *)+ s time t     1   ( n *)}]/ HZ  
 
         [0047]    where HZ is a constant and has a value of 100 in Linux kernel version 3.4.0. 
         [0048]    The reaction time prediction part  120  can use a reaction time maximum change prediction model to predict the maximum amount of change in reaction time when the current CPU frequency is changed from f CPU  to f x  or when the processing weight of a target application is changed from the current w* to w* y . 
         [0049]    Here, the reaction time maximum change prediction model can be expressed as Equation 2 shown below. 
         [0000]    
       
         
           
             
               
                 
                   
                     Δ 
                     R 
                   
                   = 
                   
                     
                       
                         
                           T 
                           S 
                         
                          
                         
                           ( 
                           
                             f 
                             x 
                           
                           ) 
                         
                       
                        
                       
                         
                           
                             w 
                             y 
                             * 
                           
                           + 
                           
                             
                               ∑ 
                               
                                 ∀ 
                                 
                                   i 
                                   ∈ 
                                   S 
                                 
                               
                             
                              
                             
                               w 
                               i 
                             
                           
                         
                         
                           w 
                           y 
                           * 
                         
                       
                     
                     - 
                     
                       
                         
                           T 
                           S 
                         
                          
                         
                           ( 
                           
                             f 
                             CPU 
                           
                           ) 
                         
                       
                        
                       
                         
                           
                             w 
                             * 
                           
                           + 
                           
                             
                               ∑ 
                               
                                 ∀ 
                                 
                                   i 
                                   ∈ 
                                   S 
                                 
                               
                             
                              
                             
                               w 
                               i 
                             
                           
                         
                         
                           w 
                           * 
                         
                       
                     
                   
                 
               
               
                 
                   [ 
                   
                     Equation 
                      
                     
                         
                     
                      
                     2 
                   
                   ] 
                 
               
             
           
         
       
     
         [0050]    f CPU  is the value of the current CPU frequency, and f x  represents the value to which the CPU frequency will be changed. 
         [0051]    w i  represents the value of the processing weight of application i, w* represents the value of the processing weight of the target application, and w* y  represents the value to which the processing weight of the target application will be changed. 
         [0052]    Also, S represents the set of tasks being processed by the CPU, excluding the target application. 
         [0053]    Incidentally, the “processing weight” is a value that has a one-to-one correspondence relationship with the “priority value’ of the task. 
         [0054]    One example of a value that represents the priority of a task is the nice value used in Linux kernel version 3.4.0. The nice value is an integer between −20 to 19, where a smaller value indicates higher priority. 
         [0055]    If an application having a nice value of n i  has a processing weight of w n     i   , then w n     i   =1.25 −n     i    w 0 . 
         [0056]    Here, w 0  represents the processing weight of an application having a nice value of 0, and with the nice value converted to a processing weight with respect to Linux kernel version 3.4.0, w 0  would have a value of 1024. 
         [0057]    Also, w n * represents the processing weight of the target application and can be expressed as w n *=1.25 −n *w 0 . Substituting these variables in Equation 2, the following can be obtained. 
         [0000]    
       
         
           
             
               Δ 
               R 
             
             = 
             
               
                 
                   
                     T 
                     S 
                   
                    
                   
                     ( 
                     
                       f 
                       x 
                     
                     ) 
                   
                 
                  
                 
                   
                     
                       w 
                       
                         
                           n 
                           * 
                         
                         y 
                       
                     
                     + 
                     
                       
                         ∑ 
                         
                           ∀ 
                           
                             i 
                             ∈ 
                             S 
                           
                         
                       
                        
                       
                         w 
                         
                           n 
                           i 
                         
                       
                     
                   
                   
                     w 
                     
                       
                         n 
                         * 
                       
                       y 
                     
                   
                 
               
               - 
               
                 
                   
                     T 
                     S 
                   
                    
                   
                     ( 
                     
                       f 
                       CPU 
                     
                     ) 
                   
                 
                  
                 
                   
                     
                       w 
                       
                         n 
                         * 
                       
                     
                     + 
                     
                       
                         ∑ 
                         
                           ∀ 
                           
                             i 
                             ∈ 
                             S 
                           
                         
                       
                        
                       
                         w 
                         
                           n 
                           i 
                         
                       
                     
                   
                   
                     w 
                     
                       n 
                       * 
                     
                   
                 
               
             
           
         
       
     
         [0058]    The reaction time maximum change prediction model according to an embodiment of the invention, such as the one above, can be applied to a scheduler in a smart device that determines the duration of processing by the CPU according to the processing weight of each application and has the procedures in the execution queue processed in turn. 
         [0059]    With such a scheduler, it is assumed that those factors that have the most impact on the difference in reaction times when the CPU frequency or the processing weight of an application is changed are occupied in advance by tasks of other applications. 
         [0060]    T S (f x ) and T S (f CPU ) represent the service times of an application obtained by Equation 1, and are incorporated in the model because the amount of change in the reaction time increases in proportion to the service time of the application. 
         [0061]    Also, the reaction time prediction part  120  uses the model for predicting the reaction time of a target application to compute a predictive reaction time according to the changed CPU frequency or nice value of the target application. 
         [0062]    Here, the model for predicting the reaction time of the target application can be expressed as Equation 3 shown below. 
         [0000]        T   R ( f   x   , n*   y )= T   R ( f   CPU   , n *)+Δ R    [Equation 3]
 
         [0063]    Here, T R (f x , n* y ) represents the predictive reaction time, T R (f CPU , n*) represents the reaction time measured by the reaction time measurement part  110  in the currently operating smart device, and Δ R  is the result obtained from Equation 2. 
         [0064]    Also, f x  and n* y  represent the CPU frequency and the nice value of the target application that are to be changed, respectively, while f CPU  and n* represent the CPU frequency and the nice value of the target application currently in operation, respectively. 
         [0065]    The control part  130  can periodically execute the reaction time measurement part  110  and, when the predictive reaction time is computed for the smart device by the reaction time prediction part  120 , can accordingly find the optimal CPU frequency that can minimize power consumption while satisfying the threshold for the reaction time and then adjust the processing weight of the application and apply it to the smart device. 
         [0066]    This is described below in further detail with reference to  FIG. 2 . 
         [0067]      FIG. 2  is a flowchart illustrating the procedures of controlling a CPU for improving application processing speed and power consumption according to an embodiment of the invention. 
         [0068]    The reaction time measurement part  110  may measure the reaction time of the smart device, and the control part  130  may determine whether or not the measured reaction time exceeds the reaction time threshold L R  (S 201 ). 
         [0069]    If the result of the determining is that the threshold is exceeded, then in order to immediately remedy the user&#39;s inconvenience, the control part  130  may change the currently operating CPU frequency f CPU  to f max , the highest frequency the CPU can have, and may set the nice value n* of the target application to an initial value by assigning the default 0 assigned by the CFS (S 202 ). 
         [0070]    Thus, the value f x  to which the CPU frequency will be changed may become f max , and the value to which the nice value of the target application will be changed may become 0. 
         [0071]    After operation S 202 , the control part  130  may check whether or not f CPU  is the lowest CPU frequency f 1  (S 203 ). 
         [0072]    If f CPU  is f 1 , then the CPU frequency cannot be lowered any further, and thus the control part  130  may operate the smart device without changing the CPU frequency and the nice value of the target application. 
         [0073]    Incidentally, the range of the CPU frequency may be set from f 1  to f max , f 1  being the lowest frequency. In operation S 202 , f CPU  was changed to f max  in order to immediately remedy the user&#39;s inconvenience, so that the control part  130  may perform the procedure of operation S 204 . 
         [0074]    After operation S 203 , the control part  130  may set f x  one step lower to f x-1  S 204 ) and may operate the reaction time prediction part  120  to compute the predictive reaction time for the smart device with the one-step lowered CPU frequency (S 205 ). 
         [0075]    After operation S 205 , the control part  130  may check whether or not the predictive reaction time computed in operation S 205  exceeds the reaction time threshold L R  (S 206 ). 
         [0076]    That is, since f CPU  is operating as fmax in order to immediately remedy the current user&#39;s inconvenience, the predictive reaction time may be computed with the frequency at one step lower than f max  and compared with the reaction time threshold L R . 
         [0077]    If, as a result of operation S 206 , the predictive reaction time computed in operation S 205  is found to be smaller than the reaction time threshold L R , then the control part  130  may repeat the procedures of operations S 203  to S 206  so as to set the CPU frequency to a lower value, looking for the optimum frequency by lowering the CPU frequency step by step to a lower frequency until the predictive reaction time of the smart device exceeds the reaction time threshold L R . This is because a lower frequency of the CPU can provide a greater reduction in power consumption. 
         [0078]    If, as a result of operation S 206 , the predictive reaction time computed in operation S 205  is found to be exceed the reaction time threshold L R , then the control part  130  may check whether or not the nice value n* y  of the target application is the lowest value n 1  (S 207 ). 
         [0079]    If, as a result of operation S 207 , n* y  is found to be n 1 , then the nice value of the target application cannot be lowered any further, so that the control part  130  may operate the smart device with the optimum CPU frequency found by the procedures above without changing the nice value of the target application. 
         [0080]    If, as a result of operation S 207 , n* y  is found not to be the lowest nice value, then the control part  130  may set the value n* y , to which the nice value of the target application will be changed, one step lower to n* y-1  (S 208 ) and may operate the reaction time prediction part  120  to compute the predictive reaction time for the smart device with the one-step lowered nice value of the target application applied (S 209 ). 
         [0081]    After operation S 209 , the control part  130  may check whether or not the predictive reaction time computed in operation S 209  exceeds the reaction time threshold L R  (S 210 ). 
         [0082]    If, as a result of operation S 210 , the predictive reaction time computed in operation S 209  is found to exceed the reaction time threshold L R , then the control part  130  may repeat the procedures of operations S 207  to S 210  until the predictive reaction time computed in operation S 209  is smaller than the reaction time threshold L R , so as to find the optimum nice value. 
         [0083]    This is because a lower nice value means an increased amount of tasks that can be processed at once (an increase in the time allotted for processing tasks), and therefore under conditions of the same CPU frequency, a better response time can be expected from a lower nice value. 
         [0084]    If, as a result of operation S 210 , the predictive reaction time computed in operation S 209  is found to be smaller than the reaction time threshold L R , then the control part  130  may perform operation S 203  to further lower f CPU . 
         [0085]      FIG. 3  through  FIG. 6  are graphs of actual test results that show how the power consumption was improved in a smart device by the control of the CPU for improving application processing speed and power consumption according to an embodiment of the invention. 
         [0086]    To analyze the performance of the algorithm for adjusting the CPU frequency and the processing weight of the application as proposed by an embodiment of the invention, the performance was compared with that of the Ondemand Governor, which is one of the most frequently used in smart devices. 
         [0087]    The smart device used for the performance analysis is Samsung&#39;s Galaxy S4 LTE-A smart phone. In the tests, L R  was set to 150 ms. 
         [0088]      FIG. 3  and  FIG. 4  are results comparing the validity of Equation 2 with actual measured values for Samsung&#39;s Galaxy S4 LTE-A smart phone. 
         [0089]    Here, a CPU Stress application which creates various loads for the CPU was run as a background application. It can be seen that the measured values are similar to the results of Equation 2 or the results are within a 95% confidence level of the measured results. 
         [0090]      FIG. 5  shows test results concerning the power consumption of a smart device. 
         [0091]    Compared with the Ondemand Governor, it can be seen that there is always a gain in power consumption regardless of the CPU load applied by the background application. 
         [0092]      FIG. 6  shows test results concerning the reaction time of the application. 
         [0093]    With the Ondemand Governor, it can be seen that the L R  value is not exceeded when there is no background application or when a CPU load of 10% is applied, but when the CPU loads of 20% and 30% are applied, the L R  value was exceeded. 
         [0094]    With the RSC, it can be seen that the L R  value is not exceeded regardless of the CPU load of the background application. 
         [0095]    Although it may seem that the performance is lower compared with the Ondemand Governor when there is no background application or when a 10% CPU load is applied, this difference is not actually perceivable to users. Thus, the reaction time is intentionally increased by a level that is unperceivable to the users, to provide gains in terms of power consumption. 
         [0096]    The embodiments of the present invention set forth above are for illustrative purposes. It would be appreciated by those of ordinary skill in the field of art to which the present invention pertains that the embodiments above can be easily modified to other specific implementations without departing from the technical spirit of the present invention and without changing the essential features of the present invention. 
         [0097]    Thus, the embodiments described above are merely given as examples and do not limit the present invention. 
         [0098]    For example, a component described as an integrated form can be used in a distributed form, while components described as being in a distributed form can be used coupled together. 
         [0099]    The scope of the present invention is to be defined by the scope of claims set forth below, and it is to be appreciated that all variations and modifications which can be derived from the meaning and scope of the claims as well as their equivalents are encompassed by the scope of the present invention.