Resource management method and terminal device

By integrating multiple machine learning models in terminal devices, sorting the application importance in computer operating systems in real time, and scheduling resources based on the importance sorting results, the problem of difficult to effectively manage the resource requirements of important application in the existing technology is solved, and more efficient resource allocation and better user experience are achieved.

CN110879750BActive Publication Date: 2025-05-02HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN201910828844.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2017-10-13
Publication Date
2025-05-02
Estimated Expiration
2037-10-13

AI Technical Summary

Technical Problem

The prior art is difficult to effectively identify and manage resource requirements for important applications in computer operating systems in real-time scenarios, resulting in system lag and user experience decline.

Method used

By integrating multiple machine learning models in terminal devices, combining application timing feature data, system time, current status data and location data, sorting the importance of applications in real time, and scheduling resources based on the importance sorting results, ensuring that important applications obtain sufficient resources.

Benefits of technology

Real-time resource management for important applications is realized, system lag is reduced, user experience is improved, and resource allocation is further optimized by temporarily freezing non-important applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110879750B_ABST
    Figure CN110879750B_ABST
Patent Text Reader

Abstract

The present application provides a method for managing resources in a computer system and a terminal device. The method includes: acquiring data, the data including application timing feature data related to the current foreground application, and the data also including at least one of the following real-time data: the system time of the computer system, the current state data of the computer system, and the current location data of the computer system; selecting a target machine learning model that matches the real-time data from multiple machine learning models according to at least one of the real-time data; inputting the acquired data into the target machine learning model to rank the importance of multiple applications installed on the computer system; and performing resource management according to the result of the importance ranking. The method improves the accuracy of identifying the importance of applications, thereby making the objects of resource allocation / reservation or resource recovery more accurate, thereby improving the effectiveness of resource management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer operating systems, and in particular to a method, device, and system for ranking applications deployed in an operating system by importance and managing resources based on the importance ranking. Background Art

[0002] The primary task of computer operating systems, including smartphone operating systems, is to maintain resource allocation for the various applications running on them. From the perspective of computer operating systems, resources include many types, such as processor (such as central processing unit CPU) computing resources represented by time slices, memory resources represented by memory pages, and input / output (I / O) resources represented by bandwidth. When the resources supporting the user's current operation cannot be supplied in time, the operating system will show lag. Therefore, the core factor that affects whether the operating system is stuck or not is the resource scheduling strategy, and the most important thing for whether the resource scheduling strategy is reasonable is to identify important applications and non-important applications, so as to achieve reasonable resource allocation as much as possible.

[0003] Taking the smartphone operating system Android as an example, applications can be divided into foreground applications, background applications, and unstarted applications. The scenario where users can feel the lag is usually when using the foreground application, so the foreground application is relatively more important. Therefore, from the user's perspective, the main reason for the lag in the Android system is: the disordered execution of applications, resulting in the lack of guarantee of the resources required when the foreground application or service is used. The existing methods can identify the foreground application and the background application, and appropriately allocate more resources to the foreground application, but this allocation is relatively fixed. However, in real-time scenarios, especially when resources are insufficient, how to temporarily provide more resources for the foreground application or important application to ensure the operation of these important applications involves how to release some resources occupied by the current non-important applications. In the process of solving this problem, which applications' resources to release in order to temporarily make way for important applications has become an urgent problem to be solved. Summary of the invention

[0004] The present application provides a resource management method and a terminal device applying the method, etc. The method includes an application importance ranking method and a resource scheduling method, which can identify the importance of applications in the current scenario, and then implement resource scheduling based on this, to ensure resource supply for more important applications, thereby avoiding system freezes to a certain extent and improving user experience.

[0005] In a first aspect, the present application provides a resource management method. The method can be applied to a computer system, such as a terminal device. The terminal device acquires data, which includes application timing feature data related to the current foreground application and at least one of the following real-time data: the system time of the computer system, the current state data of the computer system, and the current location data of the computer system. The terminal device selects a target machine learning model that matches the real-time data from a plurality of machine learning models based on at least one of the real-time data, where the plurality of machine learning models correspond to different application usage patterns. The terminal device inputs all acquired data into the target machine learning model, and uses the target machine learning model to rank the importance of the plurality of applications installed on the computer system. The result of the importance ranking can be used as one of the decision factors for the terminal device to perform resource management. Other data acquired in addition to the above-mentioned real-time data can also be used to determine the target machine learning model.

[0006] Multiple machine learning models are set up, and based on the collected data, the machine learning model that is most relevant to the current scenario of the terminal device is determined among these multiple machine learning models, and the importance ranking of the applications is determined according to the machine learning model, so that the ranking result of the application importance is more in line with the current scenario of the terminal device, that is, the real-time accuracy of the importance ranking is higher.

[0007] In addition, compared with the prior art that collects a single or small amount of data, the application ranking provided by the present application is based on the collection of a variety of data related to the use of the terminal device, and the diversification of data can also improve the accuracy of application ranking.

[0008] In some embodiments, the application timing feature data is used to characterize the time sequence of multiple applications being used. Specifically, the application timing feature data may include the k1 most recently used applications, the k2 most possible predecessor applications of the foreground application, and the k3 most possible subsequent applications, where k1, k2, and k3 are all positive integers.

[0009] In some embodiments, the terminal device determines the time period in which the computer system is currently located based on the system time of the computer system; and determines the target machine learning model corresponding to the time period in which the computer system is currently located from the corresponding relationship based on the time period in which the computer system is currently located, wherein the corresponding relationship includes multiple time periods and multiple machine learning models corresponding to the multiple time periods respectively.

[0010] In some embodiments, the terminal device determines the current semantic position of the computer system based on the current position data of the computer system, and then determines the target machine learning model corresponding to the current semantic position of the computer system from the corresponding relationship based on the current semantic position of the computer system, and the corresponding relationship includes multiple semantic positions and multiple machine learning models corresponding to the multiple semantic positions respectively.

[0011] The above are two ways to determine the target machine learning model. Multiple target machine learning models correspond to various usage patterns of users using applications. The division of multiple usage patterns can be based on one dimension, such as system time or current location data, or can be based on multiple dimensions.

[0012] In some embodiments, the terminal device determines the target machine learning model based on at least two of the real-time data. Different from the first two implementations, in these embodiments, the usage pattern corresponding to the target machine learning model is the result of multi-dimensional division. For example, the user's usage pattern is divided into four types from the two dimensions of time and geographic location: working hours and the location is the company, working hours and the location is a business trip (non-company), non-working hours and the location is home, and non-working hours and the location is an entertainment venue (non-home). These four usage patterns have different characteristics, so they correspond to a machine learning model respectively. The terminal device determines a machine learning model that best matches the current situation based on the real-time data.

[0013] This application does not limit the measurement method of "usage rules". The so-called different usage rules means that different usage rules show different characteristics when viewed by the current measurement method.

[0014] In some embodiments, the terminal device can also predict the number of applications N that the user frequently uses in the current scenario based on the application usage history, and then determine the top N applications based on the importance ranking. In this way, the terminal device can treat these N applications as important applications when performing resource management, and in some cases, reserve resources for these N applications, or take some measures to protect these N applications.

[0015] Although there are ranking results of the importance of all applications, it is difficult to select some applications when the terminal device performs resource management. By predicting the number of applications N that users often use, the terminal device can perform resource management with greater purpose and clarity. Moreover, these N applications are indeed very important applications, which makes resource management more reasonable.

[0016] In some embodiments, the terminal device determines N applications (or fewer or more) ranked at the top in importance, reserves resources for the determined applications, or temporarily freezes the remaining other applications, or creates a vip queue for each CPU, wherein the vip queue includes the tasks (processes or threads) of the determined applications, and the execution of each character in the vip queue takes precedence over other execution queues of the CPU.

[0017] To sort applications using the method provided in this application, it is necessary to collect historical data on application usage. However, for newly installed applications, they may be ranked low due to too little historical data on application usage, but this does not accurately represent the true importance of the newly installed application.

[0018] On the second aspect, the present application also provides a method for ranking the importance of newly installed applications, which is equivalent to compensating the importance of newly installed applications. The terminal device ranks the newly installed applications in importance according to the weights of the newly installed applications, and selects N2 newly installed applications that are ranked first, wherein the time when the newly installed applications are installed on the computer system is less than a preset second threshold. Accordingly, the terminal device may also consider the ranking of newly installed applications when performing resource management. For example, when performing resource reservation, when the number of applications is limited, consider some of the applications ranked first in the aforementioned importance ranking results, and also consider the newly installed applications ranked first in the newly installed application ranking results. Other types of resource management are similar.

[0019] This avoids neglecting applications that are important to users among newly installed applications during resource management, further improving the effectiveness of resource management.

[0020] In some embodiments, the terminal device calculates the score of each newly installed application based on the usage probability weight and the time decay weight, and the importance of a newly installed application with a high score is higher than that of a newly installed application with a low score. The usage probability weight is used to reflect whether the newly installed application has been used recently; and the time decay weight is used to reflect the time difference between the current time and the application installation time.

[0021] On the third aspect, the present application also provides a data collection method and a method for performing model training based on the collected data, which can be used to support application sorting and resource management provided in other embodiments.

[0022] The terminal device collects and stores application data and relevant data of the computer system, wherein the application data includes an identification of the application and the time when the application is used, and the relevant data of the computer system includes at least one of the following data: the time, status data and location data of the computer system when the application is used.

[0023] Furthermore, the terminal device calculates application timing feature data of multiple applications based on the application data collected and stored in the past period of time; inputs the application data, or the application data and relevant data of the computer system into a classification model, such as an entropy increase model, to obtain multiple classifications related to the rules of application use, wherein the two rules corresponding to any two classifications are different; and trains a machine learning model for each of the multiple classifications, the machine learning model being used to implement application importance ranking, the training input including the time the application is used, the application timing feature data, and at least one of the relevant data of the computer system.

[0024] In some embodiments, the model training process can also be performed on the server side. The terminal device sends the collected data to the server, and the server performs model training. The trained model can be stored locally or returned to the terminal device. If the model is stored on the server side, the terminal device can request the model from the server when performing importance sorting. Furthermore, importance sorting can also be performed on the server side, and the terminal device only needs to store the sorting results or request the sorting results from the server when using it.

[0025] In a fourth aspect, the present application also provides a resource management method that can be applied to a computer system, such as a terminal device. When the terminal device detects a specific event, it temporarily freezes some applications until a specific time period ends, and then unfreezes all or part of the frozen applications. The specific event is an event indicating an increase in resource demand, such as an application startup event, a photo taking event, a gallery zoom event, a sliding event, and a screen on / off event.

[0026] The end of a specific time period is only one of the conditions for unfreezing, and another condition may be the detection of the end of the specific event.

[0027] Furthermore, some emergency events may occur, which occur before the end of the specific time period and before the end of the specific event. Once this type of emergency event occurs, it is necessary to unfreeze the applications related to the emergency event in advance.

[0028] When the instantaneous resource demand is high, by temporarily freezing some applications that are not so important and releasing some resources, the resource supply of applications that are perceived by users and have a large resource demand can be guaranteed, thereby avoiding the phenomenon of freezing in these applications and improving the user experience. Temporary freezing only freezes the application for a short period of time and then releases it, while in the prior art, applications that are not used for a long time are usually frozen for a long time and then unfrozen when the application is requested. Although both are freezing, there are at least differences in the usage scenarios and specific ways of freezing.

[0029] In some embodiments, the terminal device implements temporary freezing by setting a timer, and the duration of the timer is set to the specific time period. This method requires less code changes.

[0030] In some embodiments, the temporarily frozen portion of applications includes all background applications, or all applications that are in the background and are not perceived by the user. In other embodiments, the temporarily frozen portion of applications includes applications of low importance, where the importance of the application is obtained based on the historical usage of the application, the machine learning algorithm, and the current scenario data of the system. Specifically, the importance of the application can be obtained according to the importance ranking method provided above, and the application with the lower importance ranking is selected for temporary freezing.

[0031] In a fifth aspect, the present application also provides another resource management method, which can be applied to a computer system, such as a terminal device. The terminal device includes multiple physical cores, each physical core corresponds to a first queue and a second queue, and the first queue and the second queue respectively include one or more tasks to be executed by the physical core. At least one physical core executes the following method: obtain and execute tasks in the first queue until all tasks in the first queue are executed, and then obtain and execute tasks in the second queue.

[0032] Important tasks are placed in an additional queue with a higher execution priority, and the physical cores execute these important tasks first, thereby ensuring the resource supply for important tasks.

[0033] In some embodiments, the first queue is monitored for whether there is a task whose waiting time exceeds a specific threshold. If so, the task is moved to the first queue corresponding to another physical core.

[0034] Due to the limitation of Linux operating system, real-time tasks are generally not allowed to be moved from one physical core to another. Here, important tasks refer to non-real-time tasks. When important tasks waiting for timeout are detected, they are moved to the first queue of another idle physical core, so as to avoid the jamming phenomenon caused by the long waiting time of important tasks.

[0035] In some embodiments, the tasks in the first queue include important tasks (or critical tasks) and tasks on which the important tasks depend. The important tasks are tasks that affect the user experience, or tasks that are perceptible to the user, or tasks of applications with high importance, where the importance of the application is obtained based on the historical usage of the application, the machine learning algorithm, and the current scenario data of the system. The dependency relationship between tasks is, for example, data dependency, lock dependency, or binder service dependency.

[0036] Because the execution of an important task depends on the execution of the tasks it depends on, placing the important task and its dependent tasks in the first queue with a higher execution priority can further improve the execution speed of the important task.

[0037] In a sixth aspect, for each method provided in the present application, the present application also provides a corresponding device, which includes a module for implementing each step of the method. The module can be implemented by software, a combination of software and hardware, or hardware.

[0038] In the seventh aspect, the present application also provides a terminal device, including a processor and a memory, wherein the memory is used to store computer-readable instructions, and the processor is used to read the computer-readable instructions stored in the memory to implement any one or more methods provided in the present application.

[0039] In an eighth aspect, the present application also provides a storage medium, which may be a non-volatile storage medium for storing computer-readable instructions. When one or more processors execute the computer-readable instructions, any one or more methods provided in the present application are implemented.

[0040] In a ninth aspect, the present application also provides a computer program product, which includes computer-readable instructions, and when one or more processors execute the computer-readable instructions, any one or more methods provided in the present application are implemented.

[0041] In some embodiments, this application does not limit how high or low the importance is, because those skilled in the art can understand that there are different needs in different situations. For the sorting method provided in this application, the "importance" of an application is the possibility that the application will be used by the user. The greater the possibility, the higher the importance. However, in some other embodiments, such as application resource management, the "importance" of the application can be determined based on the current resource management status. For example, the importance of the application can be related to whether the user perceives the application, and so on. In addition, the two resource management methods provided in this application may rely on the sorting method provided in this application, or they may not rely on it.

[0042] The key to solving the problem of disordered resource scheduling in computer operating systems is to ensure that the system can perceive the importance of applications in real time and accurately, and implement the best resource management strategy according to the importance of applications to ensure that system resources are used to the fullest. In short, the operating system should stand from the user's perspective, fully identify the user's usage needs and supply resources on demand. For example, for what the user is currently using, it should be fully guaranteed, for what the user is about to use, it should be prepared in advance, and for what the user is least concerned about, such as invalid self-starting or associated startup applications, it should be fully recycled.

[0043] The application ranking method provided in the present application collects various information of computer devices (such as smart terminals) in real time, and trains multiple machine learning models under different categories related to application usage patterns. When ranking by importance, the machine learning model that best matches the user's usage patterns is selected to make real-time predictions on the importance of the application, thereby improving the accuracy of identifying the importance of the application.

[0044] Furthermore, based on the identification of the importance of applications, reasonable and effective resource management is carried out, thereby ensuring the resource supply of important applications, improving the smoothness of computer equipment use, and further improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solution provided by the present application, the following is a brief introduction to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present application.

[0046] Figure 1 A schematic diagram of the logical structure of a terminal device;

[0047] Figure 2 A schematic diagram of the logical structure of an operating system deployed in a terminal device;

[0048] Figure 3 A schematic diagram of the logical structure of some modules of the perception management device;

[0049] Figure 4 It is a schematic diagram of the resource management method;

[0050] Figure 5 It is a flowchart of the data collection method in the resource management method;

[0051] Figure 6 It is a flowchart of the model training method in the resource management method;

[0052] Figure 7 A schematic diagram of the principles and effects of application usage patterns divided according to one or more dimensions;

[0053] Figure 8 A flowchart of applying the real-time sorting method in the resource management method is provided;

[0054] Fig. 9 It is a flowchart of the temporary freezing method in the resource management method;

[0055] Fig.10 This is an example diagram of the first state of the ready queue;

[0056] Fig.11 This is an example diagram of the second state of the ready queue;

[0057] Fig.12 An example diagram of two queues for each CPU;

[0058] Fig.13 A flowchart of the task movement method is provided;

[0059] Fig.14 An example diagram of the queue changes involved in moving a task. DETAILED DESCRIPTION

[0060] In order to facilitate understanding of the embodiments of the present application, several elements that will be introduced in the description of the embodiments of the present application are first introduced here.

[0061] Operating system: It is a computer program that manages computer hardware and software resources. It is also the core and cornerstone of the computer system. The operating system needs to handle basic tasks such as managing and configuring memory, determining the priority of system resource supply and demand, controlling input and output devices, operating networks and managing file systems. The operating system also provides an operating interface for users to interact with the system. The types of operating systems are very diverse. The operating systems installed on different machines can range from simple to complex, from embedded systems in mobile phones to large operating systems in supercomputers. Many operating system manufacturers have different definitions of the scope of its coverage. For example, some operating systems integrate a graphical user interface (GUI), while others only use a command line interface and regard the GUI as a non-essential application. Terminal operating systems are generally considered to be operating systems running on terminals such as mobile phones, tablets, and point of sale terminals, such as the current mainstream Android or iOS.

[0062] Application: Also called application software or application program, it is a computer program designed to implement a set of related functions, tasks or activities for users. Applications are deployed on the operating system. Specifically, they can be deployed in conjunction with the system software of the operating system (such as the operating system), such as system-level applications (or system services), or they can be deployed independently, such as the common word processing applications (such as Word applications), web browser applications, multimedia playback applications, game applications, etc.

[0063] System resources: In this application, it refers to the resources within the computer system, including but not limited to any one or more of memory resources, processing resources and I / O resources. Resource management includes many implementations, such as resource recovery by closing, freezing or compressing some applications, or resource retention by refusing to start applications, or resource reservation for applications by preloading applications.

[0064] Foreground application, background application and the switching between the foreground and background of the application: the foreground application is the abbreviation of the application running in the foreground. The background application is the abbreviation of the application running in the background. For example, the Word application and the web browser application are currently started, but the current user is writing an email. Some operating systems manage these two applications separately through two lists. In the Linux system, when an application switches from the foreground to the background or from the background to the foreground, a foreground and background switching event is triggered. The system can perceive the switching between the foreground and background of the application by monitoring the foreground and background switching events. In some embodiments, the background application is divided into background imperceptible applications and background perceptible applications. Background perceptible applications refer to certain applications that can be perceived by the user even if they are running in the background, such as music playback applications or navigation applications. Even if the two are running in the background, the user can still hear the music or navigation sounds.

[0065] Predecessor application and successor application: The predecessor application of an application is the application used before the application is used (which can be understood as being switched to the foreground), and the successor application of an application is the application used after the application is used. The application being used means that the application is launched or the application is switched from the background to the foreground. The application launch can also be understood as the application switching to the foreground (from being closed).

[0066] Application timing feature data: data used to characterize the time sequence in which multiple applications are used, such as which applications have been used recently, which application may be the predecessor application of an application, or which application may be the successor application of an application, etc.

[0067] System status data: or simply referred to as status data, is information used to represent the status of a computer device or operating system itself. More specifically, it can be understood as the status data of built-in components or external components in the device, such as the network connection status, or the connection status of external devices such as headphones and charging cables.

[0068] Location data and semantic location data: Location data is a broad concept. Any information that represents a location can be considered location data, such as longitude and latitude. Giving practical meaning to relatively precise location data such as longitude and latitude, such as "home", "company", or "entertainment venue", is semantic location data. Semantic location data is also a type of location data.

[0069] Position data and system status data can also be uniformly understood as device scenario data.

[0070] Application importance: the probability of application being used, or the possibility of application being switched to the foreground. The ranking of application importance in this application is the ranking of application usage probability, which is based on the prediction of application usage probability based on application usage history and some other information.

[0071] Unless otherwise specified, "multiple" in this application means two or more. The "data" or "information" mentioned in this application does not limit the storage method or format.

[0072] The method provided in the present application is mainly applied to terminal equipment, and the terminal equipment (usually a mobile terminal) can also be referred to as user equipment (UE), mobile station (MS), mobile terminal (mobile terminal), etc. Optionally, the terminal can have the ability to communicate with one or more core networks via a radio access network (RAN), for example, the terminal can be a mobile phone (or called a "cellular" phone), or a computer with a mobile nature, etc. For example, the terminal can also be a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device. For example, the terminal device can be a cellular phone, a smart phone, a laptop computer, a digital broadcast terminal, a personal digital assistant, a portable multimedia player, a navigation system, etc. It should be understood that in addition to mobile terminals, the method provided in any embodiment of the present application can also be applied to fixed terminals, such as personal computers, point of sale terminals (POS), or automatic teller machines, etc.; or it can also be applied to non-terminal computer systems such as servers.

[0073] The terminal device related to the present application will be described in more detail below with reference to the accompanying drawings. It should be noted that the suffixes "unit" and "module" are only for the convenience of description, and these suffixes do not have mutually distinguishable meanings or functions.

[0074] See also Figure 1 , is a schematic diagram of the structure of a terminal device used in this embodiment. Figure 1 As shown, the terminal device 100 includes a wireless communication module 110 , a sensor 120 , a user input module 130 , an output module 140 , a processor 150 , an audio and video input module 160 , an interface module 170 , a memory 180 and a power supply 190 .

[0075] The wireless communication module 110 may include at least one module that enables wireless communication between the terminal device 100 and a wireless communication system or between the terminal device 100 and a network where the terminal device 100 is located. For example, the wireless communication module 110 may include a broadcast receiving module 115, a mobile communication module 111, a wireless Internet module 112, a local area communication module 113, and a position (or positioning) information module 114.

[0076] The broadcast receiving module 115 can receive broadcast signals and / or broadcast related information from an external broadcast management server via a broadcast channel. The broadcast channel may include a satellite channel and a terrestrial channel. The broadcast management server may be a server that generates and sends broadcast signals and / or broadcast related information, or may be a server that receives pre-generated broadcast signals and / or broadcast related information and sends them to the terminal device 100. The broadcast signal may include not only a television broadcast signal, a radio broadcast signal, and a data broadcast signal, but may also include a signal in the form of a combination of a television broadcast signal and a radio broadcast signal. The broadcast related information may be information about a broadcast channel, a broadcast program, or a broadcast service provider, and may even be provided through a mobile communication network. In the case where the broadcast related information is provided through a mobile communication network, the broadcast related information may be received by the mobile communication module 111. The broadcast related information may exist in a variety of forms. For example, the broadcast related information may exist in the form of an electronic program guide (EPG) of a digital multimedia broadcasting (DMB) system, or in the form of an electronic service guide (ESG) of a handheld digital video broadcast (DVB-H) system. The broadcast receiving module 115 can use various broadcasting systems to receive broadcast signals. More specifically, the broadcast receiving module 115 can use digital broadcasting systems such as terrestrial digital multimedia broadcasting (DMB-T), satellite digital multimedia broadcasting (DMB-S), media forward link only (MediaFLO), DVB-H and integrated services digital broadcasting (ISDB-T) to receive broadcast signals. The broadcast receiving module 115 can receive signals from broadcasting systems that provide broadcast signals other than the above-mentioned digital broadcasting systems. The broadcast signals and / or broadcast-related information received by the broadcast receiving module 115 can be stored in the memory 180.

[0077] The mobile communication module 111 can transmit or receive radio signals to or from at least one of a base station, an external terminal, and a server on a mobile communication network. The signals may include voice call signals, video call signals, and data in various formats according to the reception and transmission of text / multimedia messages.

[0078] The wireless Internet module 112 may correspond to a module for wireless access, and may be included in the terminal device 100 or externally connected to the terminal device 100. Wireless LAN (WLAN or Wi-Fi), world interoperability for microwave access (WiMAX), high speed downlink packet access (HSDPA), etc. may be used as wireless Internet technology.

[0079] The local area communication module 113 may correspond to a module for local area communication. In addition, Bluetooth, radio frequency identification (RFID), infrared data association (IrDA), ultra wide band (UWB) and / or ZigBee may be used as local area communication technology.

[0080] The location information module 114 can confirm or obtain the location of the mobile terminal 100. The location information module 114 can obtain the location information by using a global navigation satellite system (GNSS). GNSS is a radio navigation satellite system that revolves around the earth and sends reference signals to predetermined types of wireless navigation receivers so that the radio navigation receivers can determine their positions on the earth's surface or near the earth's surface. GNSS can include the United States' Global Positioning System (GPS), Europe's Galileo system, Russia's Global Orbiting Navigation Satellite System, China's Compass System, and Japan's Quasi-Zenith Satellite System, etc.

[0081] The GPS module is a representative example of the position information module 114. The GPS module 114 can calculate information about the distance between a point or object and at least three satellites and information about the time when the distance information is measured, and can apply triangulation to the obtained distance information to obtain three-dimensional position information about a point or object according to longitude, latitude and altitude at a predetermined time. A method of calculating position and time information using three satellites and correcting the calculated position and time information using another satellite can also be used. In addition, the GPS module 114 can continuously calculate the current position in real time and calculate speed information using positioning or position information.

[0082] The sensor 120 can sense the current state of the terminal device 100, such as the open / closed state of the terminal device 100, the position of the terminal device 100, whether the user is in contact with the terminal device 100, the direction of the terminal device 100, and the acceleration / deceleration of the terminal device 100, and the sensor 120 can generate a sensing signal for controlling the operation of the terminal device 100. For example, in the case of a slide phone, the sensor 120 can sense whether the slide phone is open or closed. In addition, the sensor 120 can sense whether the power supply 190 is powered and / or whether the interface unit 170 is connected to an external device. The sensor 120 can specifically include a posture detection sensor, a proximity sensor, etc.

[0083] The user input module 130 is used to receive input digital information, character information or contact touch operation / contactless gesture, and receive signal input related to user settings and function control of the terminal device 100. The touch panel 131, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 131 or on the touch panel 131 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 131 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact point coordinates, and then sends it to the processor 150, and can receive and execute commands sent by the processor 150. For example, when a user clicks an application icon on the touch panel 131 with his finger, the touch detection device detects the signal caused by the click and then transmits the signal to the touch controller. The touch controller then converts the signal into coordinates and sends them to the processor 150. The processor 150 executes the opening operation of the application according to the coordinates and the type of the signal (single click or double click).

[0084] The touch panel 131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 131, the input device 130 can also include other input devices 132, which can include but are not limited to one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, a dome switch, a jog wheel, and a jog switch.

[0085] The output module 140 includes a display panel 141 for displaying information input by the user, information provided to the user, or various menu interfaces of the terminal device 100. Optionally, the display panel 141 may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED). In some other embodiments, the touch panel 131 may cover the display panel 141 to form a touch display screen.

[0086] In addition, the output module 140 may further include an audio output module 142 , an alarm 143 , a haptic module 144 and the like.

[0087] The audio output module 142 can output the audio data received from the wireless communication single module 110 in the call signal receiving mode, the phone call mode or the recording mode, the voice recognition mode and the broadcast receiving mode, or output the audio data stored in the memory 180. The audio output module 142 can output the audio signal related to the function executed in the terminal device 100, such as the call signal receiving tone and the message receiving tone. The audio output module 142 may include a receiver, a speaker, a buzzer, etc. The audio output module 142 can output the sound through the headphone jack. The user can listen to the sound by connecting the headphone to the headphone jack.

[0088] The alarm 143 may output a signal for indicating the occurrence of an event of the terminal device 100. For example, an alarm may be generated when a call signal is received, a message is received, a key signal is input, or a touch is input. The alarm 143 may also output a signal in a form different from a video signal or an audio signal. For example, a signal indicating the occurrence of an event by vibration.

[0089] The tactile module 144 can generate various tactile effects that the user can feel. An example of a tactile effect is vibration. The intensity and / or pattern of the vibration generated by the tactile module 144 can also be controlled. For example, different vibrations can be output in combination or sequentially. The tactile module 144 can generate a variety of tactile effects, in addition to vibration, it can also be a stimulation effect of a needle array moving vertically relative to the skin surface, an air jet effect or air suction effect formed by a spray hole or a suction hole, a stimulation effect of rubbing the skin, a stimulation effect of electrode contact, a stimulation effect using electrostatic force, and a plurality of effects such as the effect of reproducing heat or cold using an element capable of absorbing or releasing heat. The tactile module 144 can not only send a tactile effect by direct contact, but also allow the user to feel the tactile effect through the muscle sense of the user's fingers or arms. The terminal device 100 may include multiple tactile modules 144.

[0090] The processor 150 may include one or more processors. For example, the processor 150 may include one or more central processing units, or include a central processing unit and a graphics processing unit. When the processor 150 includes multiple processors, the multiple processors may be integrated on the same chip, or each may be an independent chip. A processor may include one or more physical cores, where a physical core is the smallest processing module.

[0091] The audio and video input module 160 is used to input an audio signal or a video signal. The audio and video input module 160 may include a camera 161 and a microphone 162. The camera 161 may process image frames of still images or moving images obtained by the image sensor in a video phone mode or a shooting mode. The processed image frames may be displayed on the display panel 141.

[0092] The image frames processed by the camera 161 may be stored in the memory 180 or may be transmitted to an external device through the wireless communication module 110. The terminal device 100 may further include a plurality of cameras 161.

[0093] The microphone 162 can receive an external audio signal in a call mode, a recording mode, or a voice recognition mode, and process the received audio signal into electronic audio data. The audio data can then be transformed into a form that can be transmitted to a mobile communication base station through the mobile communication module 111 and output in the call mode. The microphone 162 can adopt various noise elimination algorithms (or noise cancellation algorithms) to eliminate or reduce noise generated when receiving an external audio signal.

[0094] The interface module 170 may be used as a passage for an external device connected to the terminal device 100. The interface module 170 may receive data or power from the external device and send the data or power to the internal components of the terminal device 100, or send data of the terminal device 100 to the external device. For example, the interface module 170 may include a wired / wireless headset port, an external charger port, a wired / wireless data port, a memory card port, a port for connecting a device with a user identification module, an audio I / O port, a video I / O port, and / or a headphone port.

[0095] The interface module 170 may also be connected to a user identification module, which is a chip that stores information for verifying the right to use the terminal device 100. An identification device including a user identification module may be manufactured in the form of a smart card. Thus, the identification device may be connected to the terminal device 100 via the interface module 170.

[0096] The interface module 170 may also be a path for supplying power from an external cradle to the terminal device 100 when the terminal device 100 is connected to the external cradle, or a path for sending various command signals input by a user through the cradle to the terminal device 100. The various command signals or power input from the cradle may be used as a signal to confirm whether the terminal device 100 is correctly installed in the cradle.

[0097] The memory 180 stores computer programs, including operating system programs 182 and application programs 181. Typical operating systems include Microsoft's Windows, Apple's MacOS, and other systems for desktops or laptops, and Linux-based Android systems developed by Google and other systems for mobile terminals. The processor 150 is used to read the computer program in the memory 180 and then execute the method defined by the computer program, for example, the processor 150 reads the operating system program 182 to run the operating system on the terminal device 100 and implement various functions of the operating system, or reads one or more application programs 181 to run applications on the terminal device.

[0098] The operating system program 182 includes a computer program that can implement the method provided in any embodiment of the present application, so that after the processor 150 reads the operating system program 182 and runs the operating system, the operating system can have the real-time application sorting function and / or resource management function provided by the present application.

[0099] The memory 180 also stores other data 183 besides computer programs, such as application information collected by the present application, trained models, and real-time sorting results, as well as temporary storage of input / output data (e.g., phone book data, messages, static images and / or moving images), data related to various modes of vibration and sound output when touch input is applied to the touch screen, etc.

[0100] The memory 180 may be one or more of the following types: flash memory, hard disk type memory, micro multimedia card type memory, card memory (such as SD or XD memory), random access memory (RAM), static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable ROM (PROM), magnetic memory, disk or optical disk.

[0101] In some other embodiments, the memory 180 may also be a network storage device on the Internet, and the terminal device 100 may perform operations such as updating or reading on the memory 180 on the Internet.

[0102] The power supply 190 may receive external power and internal power under the control of the processor 150 , and provide power required for operations of various components of the terminal device 100 .

[0103] The connection relationship between the modules is only an example. The method provided in any embodiment of the present application can also be applied to terminal devices with other connection methods, for example, all modules are connected through a bus.

[0104] The method provided in the present application can be implemented by hardware or software. In a hardware implementation, at least one of an electronic unit such as an application specific integrated circuit (ASIC), a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a processor, a controller, a microcontroller and / or a microprocessor can be used to implement the implementation of the present application. In a software implementation, implementations such as processes and functions can be implemented using a software module that performs at least one function and operation. The software module can be implemented in a software program written in any appropriate software language. The software program can be stored in the memory 180 and read and executed by the processor 150.

[0105] Figure 2 Taking the Android system as an example, an implementation of the method provided by the present application is introduced. As shown in the figure, a typical Android system 200 includes an application 210, an application framework 220, a system runtime library and an Android runtime environment 230 and a kernel 240. Android is developed based on Linux, so this kernel 240 is a Linux kernel.

[0106] Applications 210 include browsers, media players, game applications, word processing applications, and other applications. Some are built-in applications of the system, and some are installed by users as needed. This application focuses on the use of these applications by users, so as to ensure resource supply for the applications that users are most likely to use and avoid application freezes from the user's perspective.

[0107] The application framework 220 includes Android services 224, which include various system services provided by the Android system for other modules to call and use, such as power manager 224-a, notification manager 224-b, connection manager 224-c, package manager 224-d, location manager 224-e, wired access manager 224-g, Bluetooth device 224-h, view system 224-i, etc. These managers can all be implemented by referring to the modules provided by the Android system in the prior art, and will not be described in detail in this application.

[0108] The system runtime and Android runtime environment 230 include a system runtime 231 and an Android runtime environment 232. The system runtime 231, also called a program library, includes some C / C++ libraries that can be used by different components in the Android system.

[0109] The Android runtime environment 232 includes a core library and a Dalvik virtual machine. The core library provides most of the functions of the Java programming language core library. Each Android application runs in its own process and has an independent Dalvik virtual machine instance. Dalvik is designed to be a device that can efficiently run multiple virtual systems at the same time. The Dalvik virtual machine relies on some functions of the Linux kernel 240, such as thread mechanism and underlying memory management mechanism.

[0110] Android's core system services rely on the Linux kernel 240, such as security, memory management, process management, network protocol stack, and various driver models. The Linux kernel 240 also serves as an abstraction layer between hardware and software. In addition, Android has made some modifications to the Linux kernel, mainly involving two parts of modifications:

[0111] Binder (IPC) driver: provides effective inter-process communication. Although the Linux kernel itself already provides these functions, many services in the Android system need to use this function, and for some reason they have implemented their own set.

[0112] Power management: mainly used to save power. Because the Android system is designed for mobile terminals, such as smartphones, low power consumption is an important goal.

[0113] The Android system is stored in the memory 180 in the form of software code, and the processor 150 reads and executes the software code to implement various functions provided by the system on the terminal device 100, including the functions provided in this embodiment.

[0114] The improvement involved in this embodiment is mainly in the application framework 220. As shown in the figure, in addition to the original Android system services, the application framework 220 of this embodiment also includes a perception management device, which includes a data collection module 221, an application sorting module 222, and a decision execution module 223.

[0115] It should be understood that the perception management device can also be provided as an Android system service to other components. The modules 221-223 can be used as three system services respectively, or can be appropriately combined or further subdivided.

[0116] The data acquisition module 221 acquires scene data of the terminal device 100, which includes the location data of the device (e.g., GPS location data), the status data of the built-in components or external components in the device, etc. The status data may be, for example, the layout status of the display panel, the network connection status, the connection status of the earphone or charging cable, the status of the camera / audio and video components / sensors, etc. Figure 1 Understand the various components of the terminal device 100. The "components" here include both hardware and software.

[0117] The data collection module 221 also collects application data related to the use of the application, such as application type, application name, time when the application is used, etc. The collected data is directly or after processing stored in the memory 180 or sent to other modules.

[0118] The application ranking module 222 determines the importance ranking results of all applications in the real-time scenario based on the data and machine learning model collected in real time by the data collection module 221. Before implementing real-time importance ranking, the application ranking module 222 also trains the historical data collected by the data collection module 221 to obtain the above-mentioned machine learning model.

[0119] Decision execution module 223: Makes decisions on how to manage system resources based on the real-time importance ranking of applications output by the application ranking module 222, and directly executes or calls other modules to execute corresponding resource management measures. It should be understood that in a specific implementation, the decision execution module 223 does not need the real-time importance ranking of applications when making all resource management decisions.

[0120] It should be noted that when the above modules need to store intermediate data or final data, storage functions are required. These storage functions can be implemented by independent storage modules or integrated into the three modules and implemented separately.

[0121] In some other embodiments, the above modules 221-223 may also be implemented in the system runtime library and the Android runtime environment 230 or the kernel 240, or may be partially implemented in the application framework 220 and partially implemented in other levels.

[0122] like Figure 3 As shown, the application sorting module 222 includes two major sub-modules: a model training module 310 and a real-time sorting module 320 .

[0123] The model training module 310 trains a model for real-time application sorting based on the historical data collected by the data acquisition module 221, and stores it in the memory 180 for the real-time sorting module 320 to call when performing real-time application sorting. Specifically, the model training module 310 mainly trains three models: a dimensionality partitioning model, a sorting model, and an N-value prediction model. The "model" in this application is a broad concept, and parameters, formulas, algorithms, or corresponding relationships can all be considered models.

[0124] The dimension partitioning model is used to classify the usage rules of applications, which can be one-dimensional or multi-dimensional. "Dimension" is the basis for the classification of usage rules, such as time, space, etc. Taking time as an example, the 24 hours of a day are used as the basis for the division, and the application usage rules are divided into two categories: working time period and non-working time period. Specifically, according to the current system time, the dimension partitioning model obtained by training determines whether the terminal currently belongs to the working time period or the non-working time period. What is actually reflected here is whether the user is currently in a working state or a non-working state. In these two states, the user's usage rules of the application show different characteristics. Furthermore, the dimension can also be multi-dimensional, such as the time dimension and the location dimension. For example, the working time period is divided into office work and business trip office; the non-working time period is divided into home and travel, etc. For the convenience of understanding, the examples here use semantic descriptions, such as "office" and "travel", etc., and it should be understood that this is not limited to the specific implementation.

[0125] The N-value prediction model is used to determine the number of applications frequently used by users in a specific category. The value of N is a positive integer. Taking the time dimension classification as an example, the N-value reflects the number of applications frequently used by users in a specific time period.

[0126] The real-time sorting module 320 is a real-time processing module that can determine the real-time importance sorting of applications based on the data collected in real time by the data collection module 221 and the model trained by the model training module 310. The real-time sorting module 320 uses the functions provided by the model training module 310 to complete three functions: dimension partition prediction 321, application sorting prediction 322, and N value acquisition 323.

[0127] It should be understood that each function within the model training module 310 and the real-time sorting module 320 can be regarded as a functional module or unit.

[0128] like Figure 3 As shown, the data collection module 221 may clean / process all or part of the collected data, and then store them in the memory 180 or provide them to the real-time sorting module 320.

[0129] It should be noted that the above modules or functions are not necessarily applied in all embodiments. In some embodiments of the present application, only some of the functions may be selected for implementation.

[0130] The following introduces the application sorting method and resource management method provided by this embodiment, that is, the specific implementation of the aforementioned modules or units.

[0131] like Figure 4 As shown, it is a schematic diagram of the global solution of the application sorting method and resource management method provided in this embodiment. The figure shows four main method processes, including the first stage of data collection, the second stage of model training, the third stage of application sorting, and the fourth stage of resource management. In the description process, in order to give a global overview of the solution, it will be described in the above order, but it should be understood that in the specific implementation of the solution, these four stages are not all executed in series.

[0132] After the terminal device is running, it first goes through the first stage, which is the data collection process. The collected data mainly includes the user's application usage data and the terminal device's system status data, location data and other information. This information can reflect the user's application usage pattern and is used to predict the user's application usage probability in the future. Some of the collected data will be stored directly, and some may need to be processed before storage (①). The executor of the first stage is the data collection module 221.

[0133] After a period of data collection, the second stage of model training is carried out. This application adopts a machine learning training method for the sorting model, which generally requires a certain amount of historical data input (②), but this application does not limit how long it takes to start the first training. The training process of the machine learning model is the model building process, which is essentially a parameter learning and tuning process. Training the model is the learning and updating of the model parameters. The trained machine learning model or model parameters will be stored for use in the third stage of sorting.

[0134] Before the sorting model is trained, the collected historical data is divided into multiple categories from one dimension or multiple dimensions based on a machine learning algorithm or other algorithms. The application usage patterns in multiple categories show different characteristics, and respective sorting models are trained for these multiple categories. Therefore, an important output of the second stage is multiple classifications and multiple machine learning models (or model parameters) (③) corresponding to the multiple classifications. The executor of the second stage is the model training module 310. Furthermore, the model training module 310 also calculates the number NB of applications frequently used by users under a specific category according to the N value prediction algorithm and stores it for subsequent resource management. The N value prediction process can also be placed in the third or fourth stage.

[0135] The terminal device may start the training process periodically, or start the training process at a specified time point, or start the training process according to the principle of simple mismatch of collected data, etc.

[0136] After the second stage model training is completed, the third stage application sorting can be carried out. The third stage sorts the applications according to the real-time data (④) and the machine learning model (⑤) output by the second stage. In addition to these two items, some historical data (⑤) is also needed to assist. Real-time data includes one or more of the current application collected in real time and the usage time of the current application, the current time of the terminal device (i.e. the current system time), the current status data of the terminal device and the current location data of the terminal device, while some data, such as the time sequence of multiple applications being used, also requires the usage time of multiple applications recorded in the historical data to be calculated. The executor of the third stage is the real-time sorting module 320, which outputs the sorting results of all applications installed on the terminal device (⑥).

[0137] The start of the third stage of application sorting can be periodic or event-triggered. The triggering event can be application switching, application installation, application uninstallation, terminal device status change, etc., which may cause changes in the importance of applications to users. In this case, the sorted results can be stored for use when needed by the fourth stage resource management. In addition, the triggering event can also be a request event triggered by the fourth stage resource management, that is, the application sorting is performed under the call of resource management.

[0138] The fourth stage of resource management can access and use the latest sorting results stored in the memory (⑦), or call the third stage of application sorting in real time (⑧) to obtain the sorting results according to the needs. Then, the resources are managed according to the importance of the application.

[0139] The detailed implementation methods of these four stages are respectively introduced as examples below.

[0140] Please refer to Figure 5 The diagram is a schematic diagram of the first stage data collection process. First, the data collection module 221 sets an event monitoring mechanism (S501) to monitor whether a key event occurs. If a key event is detected (S502), the data collection process is triggered (S503). The collected data can be directly stored (S505) or stored after cleaning / processing (S504).

[0141] Data cleaning refers to the process of re-examining and verifying data by computers, with the aim of removing duplicate information, correcting existing errors, and providing data consistency. Data processing refers to the process of changing the type and format of data by computers, or performing mathematical transformations on data.

[0142] On the one hand, the data acquisition module 221 collects the scene data of the terminal device 100 and the historical data of the application data related to the application usage. The collected data is stored in the memory 180 after cleaning / processing, and is used as historical data for the model training module 310 to train and generate various models. Specifically, the data acquisition module 221 monitors the status of the terminal device, application usage, etc. in real time, and collects and stores data when the conditions are met. For example, the data acquisition module 221 monitors and caches changes in user behavior status (which can also be understood as terminal device behavior status, such as motion or stillness), application usage status, system status, and location status in real time. When an application foreground and background switching or other types of key events occur, the information such as the application package name that is switched to the foreground, the current time, and the latest data of the above status will be recorded in a persistent storage medium.

[0143] On the other hand, the data collection module 221 also collects data in real time when sorting is required, and the collected data becomes the input of the real-time sorting module 320 as real-time data, so that the real-time sorting module 320 can sort the application in real time.

[0144] For example, the data collected by the data collection module 221 and the collection method are shown in the following table. It should be understood that in some embodiments, some data can be reduced or increased as needed, and this embodiment is only an example and is not intended to be limited to the data in this table.

[0145] Table 1

[0146]

[0147]

[0148] The Android system provides a function interface to obtain some data. Table 1 describes the modules (such as PackageManager) or functions (such as getActiveNotifications) involved in a method of obtaining these data. Figure 2 , those skilled in the art can use other acquisition methods as needed, and this application does not limit it. In addition to the Android system, the modules and functions called in other systems may be different, and this application is not limited to the Android system.

[0149] The foreground application in Table 1 refers to the application currently running in the foreground. This type of application is considered to be the application currently being used by the user and is relatively important to the user. Some applications running in the background are also used by users, such as music playback references. The collection time for this type of application can be put at the time when such application is started, that is, the moment it is switched to the foreground for the first time.

[0150] The above data collection process is triggered when a key event is monitored. The key event here may include one or more of the following events: foreground and background switching events, application installation events, application uninstallation events, notification events caused by changes in system status, or notification events caused by changes in geographic location information. Among them, the change in geographic location information can also be to first identify whether the semantic geographic location has changed, such as whether it has changed from home to the office, and then start data collection if the semantic geographic location has changed. Key events are not limited to the above examples. In general, key events mainly depend on the information that needs to be collected. If it is monitored that the information that needs to be collected may change, it may be necessary to start the above data collection process.

[0151] The time when the application switches to the foreground in the collected data may be the current system time. For example, if data collection is performed when a foreground-background switching event is detected, the collected current system time can be considered as the time when the current foreground application switches. If data collection is performed under the trigger of other events, the time when the application switches to the foreground can be obtained through a timestamp recorded by the current foreground application when switching to indicate the switching time. This timestamp is recorded using the system time at the time when the application is switched to the foreground.

[0152] In this application, "the time when the application switches to the foreground" is sometimes also referred to as "the time when the application is used".

[0153] The collected data can be divided into two categories based on how they are finally used: 1) Data that can be used directly, such as the Bluetooth / network / headphone / charging cable connection status, notification list status, and application type data in Table 1. These data can be directly used as input parameters for training models through feature extraction. 2) Data that needs to be processed, mainly in two categories: information related to application timing features and GPS location information, which need to be further processed and converted into other forms as parameter inputs. The following mainly introduces the second category in detail.

[0154] GPS location information needs to be clustered for semantic locations, such as home and office. Once a switch between these two geographic locations occurs, the system will push a broadcast that the semantic location information has changed. In some other embodiments, GPS location information can also be used directly.

[0155] It should be understood that the data processing process can occur before storage, and can also be processed before the data is used in model training.

[0156] The information related to application timing characteristics mainly includes the package name of the foreground application and the time when the application switched to the foreground. By collecting the historical records of these two types of information (which can be considered as the track record of users using applications), the following three types of information can be further statistically obtained: a) the k1 most recently used applications, b) the k2 most likely predecessor applications of the current foreground application, and c) the k3 most likely successor applications of the current foreground application. The values ​​of k1, k2, and k3 can be equal or unequal. The three types of information a), b), and c) are collectively referred to as application timing characteristic data.

[0157] a) is the k1 applications that the user used most recently before the current foreground application was used, which can be directly obtained based on the applications and the usage time of each application in the stored historical data. For example, assuming k1=2, the current application usage time is 18:00, and the time of the most recent application usage before the current application usage time is determined to be 15:45 and 15:30 respectively based on the usage time of each application, then the k1 applications are the two applications used at 15:45 and 15:30. In some other embodiments, k1 may also include the current foreground application.

[0158] b) and c) require using mathematical methods to calculate the multi-order associations of applications from the historical trajectory of users using applications. The statistical model of multi-order associations is described below.

[0159] In this embodiment, the matrix U[M*M] is used to represent the association relationship of the M applications installed on the terminal device 100. U[i*j] represents the number of times application i is directly switched to application j, where i and j are both positive integers less than or equal to M. For example, if application i switches to application j at a certain moment, the record U[i*j] is incremented by 1.

[0160] It should be noted that what is targeted here is the foreground application, that is, the application currently in the foreground changes directly from application i to application j. In other words, the user uses application i and then uses application j, which means that application i directly switches to application j.

[0161] Furthermore, the number of jumps between applications can also be taken into account. Application i directly switches to application j, indicating that the two may be strongly correlated, but application i switches to application j after several jumps, which also reflects a certain possibility of correlation between the two. Based on this implementation, a jump count parameter can be added. For example, if application i switches to application j after d jumps, then the record U[i,j][d] is incremented by 1. Too many jumps indicate that the correlation between applications is weak and can be ignored, so a maximum of D jumps can be set (for example, D is 5).

[0162] Then, each element U'[i,j] in the association matrix between application i and application j can be defined as:

[0163] U'[i,j]=αU[i,j][0]+βU[i,j][1]+...+γU[i,j][D] (1)

[0164] Based on the above description method: U'[,j] (the jth column of the matrix) can represent the possibility of jumping from other applications to application j; U'[i,] (representing the i-th row of the matrix) can represent the possibility of other applications jumping from application i. From this matrix, we can obtain the maximum possible k2 predecessor applications and the maximum possible k3 subsequent applications of an application. For example, if the current foreground application is application v, we can select the maximum k2 values ​​from M′[,v] in turn, and the row value corresponding to this k2 value is the maximum possible k2 predecessor application of application v; select the maximum k3 values ​​from U'[v,] in turn, and the column value corresponding to this k3 value is the maximum possible k3 subsequent applications of application v.

[0165] The application time series feature data and other collected data are stored in the memory 180 for use in the next stage of model training. The above method is also used to obtain the application time series feature data corresponding to the foreground application during the real-time sorting of applications.

[0166] Please refer to Figure 6 This is a schematic diagram of the process of model training in the second stage. After a period of data collection, some data has been stored in the memory 180, and these data reflect the rules of application usage. This rule needs to form a reusable model through machine learning. The model training process does this. As shown in the figure, data is read from the memory 180 (S601), feature extraction (S602) and other operations are performed on the data, and then the dimension division model is trained, that is, the user's application usage habits are classified according to one or more dimensions (S603). After classification, the sorting model is trained for different classifications (S604), and the training results are stored in the memory for use in the third stage of application sorting. Furthermore, this stage can also predict the number N of applications frequently used by users (S605). The three model algorithms involved are introduced below.

[0167] a) Training Dimension Partition Model (S603)

[0168] There may be gaps in the user's habits of using applications in certain dimensions. For example, in the time dimension, the user's habits of using applications during working hours and non-working hours (also known as rest time) will be very different. In this case, if a ranking model is constructed in general to sort applications, there may be a huge deviation. Training the dimension division model is to explore a more detailed division of user habits in certain dimensions, eliminate the errors caused by such gaps, and further improve the accuracy of the sorting.

[0169] For different classifications of one or more dimensions, a partitioning result can be obtained by applying some partitioning algorithms to the original data. Figure 7 As shown, the original data is divided into three categories on dimension X. Furthermore, each category can be further divided into more categories on dimension Y, which will not be described in detail. This is also the basic principle of the entropy increase algorithm to be introduced below.

[0170] This embodiment will take the time dimension as an example and divide the time into two categories: working time and non-working time. Taking one day as the standard, the method is to find one or two time points that can distinguish the user's working and non-working time. The specific implementation can be divided into: 1) single-line division, in the form of [0:00~x], [x~24:00]. There is only one variable x; 2) double-line division, in the form of [0:00~x 1 ]、[x 1 ~x 2 ]、[x 2 ~24:00] form of division, two variables x are required 1 and x 2 The following takes double-line division as an example.

[0171] First, data is read from the memory 180. The data used here mainly include the application package name and the time when the application is used.

[0172] A day is divided into 24 time periods, each of which is 1 hour. The usage of applications by users in each time period is counted based on the read data. In this embodiment, a two-dimensional matrix S is used to count the usage of applications in any time period. For example, S[h][i] represents the total number of times application i is used in time period h. Thus, a period of time [h 1 ,h 2 ], the total number of times application i was used And the time [h 1 ,h 2 ]The proportion of the number of times the application i is used in the total number of times the application is used It can be calculated by the following formulas (2) and (3) respectively:

[0173]

[0174]

[0175] It can also be called that application i at this time [h 1 ,h 2 ] is used within the frequency.

[0176] Therefore, the period of time [h 1 ,h 2 ]Information entropy of users using applications The definition is as follows:

[0177]

[0178] So, x 1 and x 2 The entropy generated by a two-line partition is calculated as follows:

[0179]

[0180] Where f(x 1 ,x 2 ) is [x 1 ,x 2 ]The proportion of all application usage times during this period to all application usage times throughout the day is calculated as follows:

[0181]

[0182] Therefore, the solution to the problem is finally transformed into finding two partitioning times x 1 and x 2 , so that the entropy value under this division is the smallest, that is:

[0183] arg min E(x 1 ,x 2 ) (7)

[0184] For example, the final result may be x 1 and x 2 The three periods are [0:00~9:00] non-working, [9:00~18:00] working, and [18:00~24:00] non-working, which can be expressed in Table 2 as follows:

[0185] Table 2

[0186] [0:00~9:00] Non-working [9:00~18:00] Work [18:00~24:00] Non-working

[0187] In this embodiment, [0:00-9:00] and [18:00-24:00] are both considered as non-working time periods, and a sorting model is trained for the non-working time periods. In some other embodiments, a sorting model can also be trained for [0:00-9:00] and [18:00-24:00] respectively. In addition, it should be noted that the semantics of "work" and "non-work" are given according to the current living habits of most people. In fact, the significance of this method is to reflect that the history of application use presents two different rules. This application is not limited to the use of the semantic division of "work" and "non-work".

[0188] b) Training the sorting model (S604)

[0189] The importance of applications on terminal devices is related to the probability of application use. The higher the probability of use, the greater the importance. The probability of application use may be different in different states of the system. For example, the probability of use of each application when the network is connected is different from the probability of use of each application when the network is disconnected. This leads to different ranking of application importance when the network is connected and disconnected. Therefore, the current system state needs to be considered when ranking applications.

[0190] It should be noted that the network connection or disconnection status is only an example, and other states related to the terminal device may also be considered, such as whether the headset is connected, whether Bluetooth is connected, whether the charging cable is connected, or the current location of the terminal device.

[0191] In summary, training a ranking model mainly includes the following steps.

[0192] Read data. Read data from memory 180. The data needed for training here mainly include: the time when the application is used, application timing feature information, system status information and semantic location information. The content and acquisition process of the application timing feature information have been detailed above. The system status information mainly includes: the connection status of the headset / charging cable / network. The semantic location information can include, for example, home and office.

[0193] Feature extraction. Through statistics, recognition and / or vectorization, the read data is converted into feature vectors / feature matrices that can be processed by machine learning algorithms. Specifically, it includes: s1) Application usage time and application timing feature information: Use vectorization, time slices and working day / non-working day identification methods to convert the application usage time and application timing feature information into vectors. For example, the application usage time is divided into two parts, date and time period. Monday, Tuesday, ... Sunday are mapped to 0, 1, ..., 6 respectively, and the time period is segmented. For example, [9:00-18:00] is a segment, and all the time in this period is mapped to the same number. s2) System status information: Extract features from the read system status information, and use discrete / enumeration methods to convert the system status information into vectors. s3) Semantic location information: Encode the read semantic location information and convert it into a vector. s4) Normalization processing: Use the maximum / minimum value method to normalize the value to [0,1], and use the whitening method to normalize the variance of the value. s6) Feature matrix combination: merge the data of each dimension into a feature matrix and provide it to the algorithm training module.

[0194] Model training and storage. Divide the data into multiple groups, and perform model training on each group to obtain multiple models. Data division can also occur before feature extraction, and feature extraction is performed on the data after division. For example, according to the division on the time dimension provided in the aforementioned embodiment of the present application, two models are trained respectively with the data from Monday to Friday [9:00~18:00] and the data from Monday to Friday [0:00~9:00][18:00~24:00], and the generated sorting model (machine learning model parameter information) and the corresponding time period are stored in the database. The data for the whole day on Saturday and Sunday can be used as non-working time periods for training.

[0195] An example of storing results is as follows:

[0196] Table 3

[0197]

[0198] The following is a detailed introduction to the training process using the machine learning algorithm Softmax as an example. The reason for choosing the Softmax algorithm is that it is an incremental learning algorithm. The incremental learning algorithm means that the training process can ensure that the characteristic data of the new training samples are integrated on the basis of the previously learned model parameters, and the parameters are further tuned. That is, there is no need to retain the original sample data, which can reduce the amount of data storage and save storage space.

[0199] By means of statistics, identification and / or vectorization, the acquired application timing feature information, system status information and other data are converted into feature vectors s = (s1, s2, ..... sW) that can be processed by the softmax algorithm, where W is the number (or length) of feature vectors. The application set is represented by a vector a = (a1, a2, ..... aM), where aj represents the i-th application and M represents the number of applications installed on the mobile phone. The purpose is to find the ranking function (i.e., ranking model) h θ (s), of course, the premise of finding the ranking function is to find the parameter θ.

[0200] Therefore, according to the softmax algorithm, the ranking function is defined as

[0201]

[0202] The cost function of this model is

[0203]

[0204] Where k represents the number of samples of training input, M represents the number of categories, that is, the number of applications, and W represents the length of the feature vector s. λ represents the weight (λ>0). 1{.} is the indicative function, and its value rule is:

[0205] 1{expression is true}=1

[0206] 1{expression is false}=0

[0207] y (i) = j indicates that the identifier of the application package name in the i-th sample in vector a is j. Therefore, if the identifier of the application package name in the i-th sample in vector a is j, it is true, 1{y (i) =j}=1, otherwise, 1{y (i) =j}=0.

[0208] Model training uses the gradient descent method or Newton method to minimize J(θ) and find θ. The gradient descent method is as follows:

[0209]

[0210]

[0211] α is a fixed parameter and j represents the number of iterations.

[0212] This embodiment performs training once every 24 hours and continuously updates the recognition model, making it closer and closer to the user's actual usage habits.

[0213] After obtaining the parameter θ through the above model training, we know the ranking function h θ(s), that is, the sorting function used in real-time sorting. The obtained information is stored in the memory 180 in the form of Table 3 for use in real-time sorting.

[0214] c) N value prediction algorithm (S605)

[0215] The value of N is a positive integer, which reflects the number of applications frequently used by users in a certain category, such as the number of applications frequently used by users in a certain time period (such as working time period). The N value prediction algorithm is used to determine the value of N. The N value can be used for resource management, because these N applications are frequently used by users, so the resources of these N applications can be appropriately protected during resource management.

[0216] According to the above, this embodiment classifies the user usage rules into two categories based on time, as shown in Table 3. Then, the calculation of the N value can also be classified in the same way based on time. The output result is shown in Table 4: an N value is calculated for each of the working time period and the non-working time period. In this way, the prediction of the N value is more accurate.

[0217] In some other embodiments, only one N value may be calculated for all categories, or the classification method for calculating the N value may be different from the classification method in Table 3. In some other embodiments, non-time dimensions may be used to calculate the N value, such as the location dimension. For example, one N value is calculated for data related to home, and one N value is calculated for dimensions related to office location.

[0218] The N value may be pre-calculated and stored, for example, as stored in Table 4, or the N value prediction algorithm may be called in real time to obtain the N value when the resource management needs the N value.

[0219] Table 4

[0220]

[0221] One implementation method of the N value prediction algorithm is: obtain the usage records of applications in the same time period of the previous day or multiple days, count the number of times each application is used, and then sort them from large to small according to the number of times used, and find the largest V applications in turn. If the sum of the number of times the V applications are used can reach 90% of the sum of the number of times all applications are used in the time period, then N=V.

[0222] Another implementation of the N value prediction algorithm: second-order moving average. The number of applications N that need to be protected in a specific time period (or some classification in other dimensions) on day t t It is the average value of the number of applications that need to be protected in the same time period on days t-1 and t-2 plus the weighted variance, as shown in formula (12):

[0223]

[0224] α is the weight coefficient, σ is the total number of N in the data i The variance value of α is, for example, 0.005. The N values ​​on the first day and the second day can be calculated using the previous implementation method.

[0225] According to formula (12), each time a value of N is calculated, all historical N i The variance value σ, so it is necessary to store all the history N i In order to reduce the storage amount of historical Ni in this embodiment, an incremental calculation method is used to evaluate the variance values ​​of all Ni:

[0226]

[0227] in, is the average of all data, is the historical data variance, is the average value of historical data, P is the number of historical data, is the variance of the new data, is the average value of the newly added data, and Q is the number of newly added data.

[0228] Please refer to Figure 8 Schematic diagram of the process for applying the real-time sorting process for the third stage.

[0229] The real-time sorting module 320 sets an event monitoring mechanism to detect key events that trigger real-time sorting (S801). After the key events are detected (S802), the data collection module 221 is triggered to collect real-time data (S803), which may include the system time of the terminal device, the current state data of the terminal device, and the current location data of the terminal device.

[0230] Key events mainly include the following: 1) switching between the foreground and background; 2) installation and uninstallation of applications; 3) changes in the system status: that is, changes in the connection status of the headset / network; 4) receipt of situational intelligent broadcast notifications, that is, notifications of changes in the semantic geographic location (company / home), etc.

[0231] According to the collected system time of the terminal device and the training results of the aforementioned dimension division model (Table 2), the classification of the time dimension in which the terminal device is currently located is determined, that is, the working or non-working time period (S804). According to the training results of the sorting model (Table 3), the sorting model of the relevant classification is selected or only the model parameters are obtained, and then the importance ranking of all applications in the real-time scenario is predicted based on the historical data and the real-time collected data (S805). The historical data here refers to the historically collected and stored data, and can be specifically referred to Table 1.

[0232] It should be understood that the data to be input into the sorting model may need to be preprocessed. For example, the time series feature data related to the current foreground application needs to be obtained by collecting real-time data and some historical data. If the model needs to input semantic location data, it is also necessary to convert the real-time collected terminal device location information into semantic location data through clustering or obtain the corresponding semantic location data based on the correspondence between the preset GPS location interval and the semantic location. Whether preprocessing is required and what kind of preprocessing is done can be matched when the root model is trained. This application does not make specific restrictions on this.

[0233] It should be noted that Table 2 and Table 3 are only examples for easy understanding. In the specific implementation process, the two can be combined into one table, that is, a corresponding relationship, and the sorting model or model parameters can be determined at one time according to the current time of the system.

[0234] It should be noted that the present embodiment uses the real-time collected system time for classification in S804. In other embodiments, if the classification dimensions are different, other real-time collected data and / or historical data may be used for classification as needed.

[0235] Finally, the real-time sorting module 320 stores the sorting result (S806) for querying and using in the fourth stage resource management. In some other embodiments, the sorting in the third stage may also occur when the fourth stage is called in real time, and then the sorting result is returned in real time.

[0236] Furthermore, Figure 8 Not shown, after sorting, the number N of applications frequently used by users in the time period can be obtained through an N value prediction algorithm or through a pre-stored correspondence (such as Table 4). This step is not necessary, and the N value can be calculated in real time when resource management really needs it.

[0237] For new applications that users have recently installed on their mobile phones, when using the above method to rank applications, the importance of the applications may be too low due to too little data collected. Therefore, this application further proposes a supplementary mechanism for newly installed applications, which ranks newly installed applications by calculating a score Score.

[0238] There are two main factors to consider when sorting newly installed applications: 1) Usage probability weight, which can also be called LRU weight in this embodiment: check whether the newly installed application appears in the LRU (last recently used) list to determine whether the newly installed application has been used recently. If it appears, the LRU is 1, and if it does not appear, the LRU is 0; 2) Time decay weight: calculate the time difference decay weight between the current time and the installation time of the newly installed application. The LRU list stores the identifiers of multiple recently used applications. For example, if the list length is 8, the 8 most recently used applications are stored in chronological order. Every time a new application is inserted, the application used the longest time ago is deleted.

[0239] Based on these two factors, the score of newly installed applications is defined as follows:

[0240] Score = α 1 ×LRU+α 2 ×e -1 (14)

[0241] Among them, α 1 is the weight coefficient of LRU, α 2 is the weight coefficient of time decay, and t is the discrete value of the time difference between the current time and the application installation time. Calculate the score of all newly installed applications and sort them.

[0242] In some other embodiments, other forms may be used to determine whether the newly installed application has been used recently. For example, the last time the newly installed application was used is recorded, and then it is determined whether the time difference between the last time of use and the current time is less than a certain threshold.

[0243] When it is necessary to recommend N applications that are frequently used by users, the top Nx applications are recommended based on the sorting results of the aforementioned softmax algorithm, and x applications are recommended based on the sorting results of newly installed applications. A total of N applications are recommended by the two recommendation methods as the most important applications of the current system for subsequent resource management.

[0244] Among them, the x newly installed applications can be selected in sequence from the x applications with the largest scores, and the value of x can be set as needed, for example, 2. Or a condition is set: the score of the recommended newly installed application must be greater than a certain threshold (for example, 0.5) and / or the number of recommendations is at most 2. This application does not limit how to set the specific conditions.

[0245] The following is an implementation example of the fourth stage system resource management. The method described below can be partially or completely implemented by the decision execution module 223.

[0246] The main purpose of system resource management is to ensure the resource supply of foreground applications or applications of high importance. This embodiment provides a method for temporarily freezing an application process (also known as instant freezing), which is used to temporarily freeze some unimportant processes when the resource demand is large, so as to provide more sufficient resources for the use of important processes and avoid application freezes due to insufficient resources, which affects the user experience.

[0247] Process freezing generally refers to the process of putting a process into an uninterruptible sleep state or a stopped state and placing it in a waiting queue. A "process" can be understood as an instance of a running application. In some descriptions, the two can be understood as equivalent.

[0248] In traditional desktop computer operating systems, freezing technology is mainly used to put all processes in the process list into a sleeping or stopped state when the system is hibernating or suspended, and save the context of all processes to the hard disk. In this way, when resuming from hibernation or suspension, the system can restore itself to its previous running state by unfreezing all frozen processes.

[0249] Different terminal operating systems use freezing technology differently. Some terminal operating systems use pseudo-background technology, that is, after the application process is switched to the background and runs in the background for a period of time, the process is frozen until the user switches the application to the foreground again, and then the process is unfrozen to continue running. When the Android operating system is short of memory, the OOM (out of memory) or LMK (low memory killer) module will trigger memory recovery by killing the process to reclaim memory, but this will cause the time to reopen the killed application to be longer, and the user's original state cannot be saved, which reduces the user experience. In order to solve this problem, the freezing technology is introduced. Specifically, when the system is short of memory (for example, the remaining memory is lower than a certain threshold), the process is first frozen, the context of the process is swapped to the ROM, and the memory is released. In this way, when the application is reopened next time, it will continue to run by unfreezing the process, which not only avoids the loss of the original state of the application after being killed, but also reduces the time for application restart, improving the user experience.

[0250] In short, the existing freezing technology is mainly used to deal with processes that have not been used for a long time, or to release resources for a long time, until a user has a demand for the process, and then unfreeze it.

[0251] This embodiment proposes an instantaneous freezing technology, which temporarily freezes other application processes and uses a temporary way out to ensure that the resources required for important applications or important scenarios are provided in a timely manner, and automatically restores and unfreezes these frozen application processes after the resource demand is reduced. While improving the processing and response speed of the application, it avoids the degradation of experience caused by other applications being frozen for a long time (for example, after a download is frozen for a long time, it cannot be downloaded anymore), thereby improving the user experience.

[0252] When certain specific events with a large instantaneous demand for resources (such as application startup, activity switching, taking pictures, sliding, turning the screen on / off, gallery zooming, etc.) are triggered, in order to prevent the execution of non-important applications from affecting these specific events, it is mandatory to temporarily freeze non-important applications. After the key events are completed, the operation of some temporarily frozen applications is restored according to the importance of the applications.

[0253] The "specific events" here are generally related to important applications, such as foreground applications or background perceptible applications, and background perceptible applications are, for example, music playback applications running in the background. The non-important applications to be temporarily frozen can be selected as needed, for example, all applications except the first N applications are selected for temporary freezing according to the importance ranking results of the applications provided in the aforementioned embodiment (where N is the number of applications frequently used by the user calculated in the aforementioned embodiment), or all background applications are selected for temporary freezing, or other applications that are currently determined to be non-important or predicted to be non-important for a period of time are selected as needed.

[0254] like Fig. 9 As shown, the detection function monitors specific events (S901), reports specific events through the dot reporting function of the Activity Manager Service (AMS) (S902), and temporarily freezes part of the application (S903). When calling the temporarily frozen function, set the freezing time, for example, 1.5s. This freezing time can be pre-set and cannot be changed, or it can be user-configurable. The freezing time is implemented by a timer, and when the timer expires (S904), the application is unfrozen (S907).

[0255] On the other hand, the execution of a specific event can also be monitored, and after detecting the end of the specific event (S905), the application is unfrozen. The detection of the end of the specific event here can also be realized by reporting the dot reporting function of the activity manager service. Steps S904 and S905 can be understood as two normal unfreezing conditions, and any one or both of them can be realized.

[0256] You can unfreeze all apps or only some apps. You can select apps to be unfrozen based on their importance and select apps with relatively high importance for unfreezing. Other apps can remain frozen because they are of low importance and may not be used by users for a long time.

[0257] Before a specific event is completed and the specified timing duration has not expired, but an event indicating a change in the operating environment of the frozen application occurs (S906), such as the frozen application switches to the foreground, the frozen application exits, the frozen application receives a binder asynchronous message, the notification message of the frozen application is clicked by the user, etc., then the frozen application can be unfrozen in advance (S907). Here, the "event indicating a change in the operating environment of the frozen application" is generally related to a frozen application. The occurrence of this event usually causes the importance of the frozen application to suddenly increase, and it needs to be unfrozen in time. Similarly, the monitoring of events indicating changes in the operating environment of the frozen application can also be achieved by the aforementioned activity manager service's dot reporting function. The event indicating the change of the running environment of the frozen application may be any one of the following events: 1) the application is placed in the foreground; 2) the application is exited; 3) the application is reinstalled or updated; 4) the dynamic wallpaper application is set as the dynamic wallpaper; 5) the application widget is added to the desktop; 6) the network data packet arrives for the instant messaging (IM) / short message service (SMS) / email application; 7) the IM / SMS / Email application goes from no network to network connection; 8) when other applications access the provider (provider) or service (service) of the frozen application; 9) the system or other applications synchronously call the frozen process through the binder; 10) after unlocking, an application with a widget on the desktop is detected; 11) the movement starts, the application using GPS and Sensor that was previously frozen; 12) the frozen application processes the headphone button; 13) the temporarily frozen application receives the binder asynchronous message; 14) click the notification bar to enter the frozen application; 15) enter the screen off state, etc.

[0258] It should be noted that some of the above events 1)-15) involve specific applications, which means that the application needs to be unfrozen (if the application is in a frozen state); some do not involve specific applications, then some or all of the frozen applications are selected to be unfrozen. For example, when entering 15) and detecting that the system enters the screen-off state, it means that there may be no user-visible foreground applications that need to be protected, so all frozen applications can be unfrozen so that they can continue to run as soon as possible.

[0259] It can be seen that in addition to the two normal thawing methods, this embodiment also proposes an emergency or early thawing method. Before a specific event is completed and before the specified timer duration expires, if an event occurs that changes the running environment of the frozen application, the frozen application can be thawed in advance to avoid affecting the normal use of the application due to freezing.

[0260] Continuous user operations (such as swiping or continuously starting an application, etc.) will continuously trigger temporary freezing. To ensure that some background applications have the opportunity to run under continuous instantaneous freezing operations, this embodiment also proposes a periodic freezing method. Before performing a freezing operation on an application, the running time of the application after being thawed will be detected first. For an application whose cumulative running duration after thawing has reached t1 seconds (t1 is a pre-set time length value, for example, 10s), temporary freezing can be continuously implemented. For an application whose cumulative running duration after thawing is less than t1, periodic temporary freezing can be implemented. This application is first frozen for t2 seconds and then thawed for t3 seconds until the continuous freezing condition is met. Here, t2 and t3 are both pre-set time length values (t2 < t1, t3 < t1), for example: t2 = 1.5s, t3 = 3s. Through such a periodic thawing method, it can well ensure that some background applications can get some running opportunities during long-term foreground interaction operations, and there will be no situation where some important background applications cannot run for a long time, or even abnormal situations occur after some applications are continuously frozen (for example, after downloading is frozen for a long time, it cannot continue to download). After detecting an event indicating a change in the running environment of the frozen application, regardless of whether the application has been thawed or not, the cumulative running duration of the application after thawing will be cleared to 0, so as to ensure that each background application can run for a period of time after receiving the event of the change in the running environment. In addition to giving priority to meeting the instantaneous high resource requirements of the foreground application, the running and experience of the background application are also guaranteed.

[0261] Another embodiment of this application provides a scheduling method for important tasks, where the tasks can be processes or threads.

[0262] Ideally, each task can get the same time slice from the CPU and run on the CPU at the same time, but in reality, a CPU can only run one task at the same time. In other words, when a task occupies the CPU, other tasks must wait. The completely fair scheduler (CFS) scheduling algorithm is a relatively common scheduling algorithm in existing Linux systems. In order to achieve fairness, the CFS scheduling algorithm must punish the currently running tasks so that those waiting processes can be scheduled next time. In specific implementation, CFS measures which task is most worthy of scheduling by the virtual run time (vruntime) of each task. The ready queue in CFS is a red-black tree with vruntime as the key value. The smaller the vruntime, the closer the process is to the leftmost end of the entire red-black tree. Therefore, the scheduler selects the task at the leftmost end of the red-black tree each time, and the task has the smallest vruntime.

[0263] It should be noted that the "CPU" mentioned in this embodiment refers to the smallest processing unit in a computer device, which can also be called a processing core, or simply a core.

[0264] like Fig.10 As shown, for the binary tree and tasks T1 to T6 on the binary tree, the CPU executes tasks in the order of T1-T3-T5-T2-T4-T6. Assume that task T1 is an important task.

[0265] vruntime is calculated by the actual running time of the task and the weight of the task, and is a cumulative value. In the CFS scheduler, the concept of task priority is weakened, and the weight of the task is emphasized. The greater the weight of a task, the more it needs to run, so its virtual running time is smaller, and the greater the chance of being scheduled.

[0266] Due to the fairness of the CFS scheduling algorithm, even if the weight of important tasks is set very high, there will be a situation where an important task is executed once and then waits for at least one other task to run. After task T1 is executed once, the vruntime value of task T1 becomes larger. After CFS schedules task T3, task T1 is inserted to the end of the queue because of the larger vruntime value. Fig.11 As shown. Then task T1 can only be executed again after tasks T3-T5-T2-T4-T6 are all executed. Fig.11For example, after task T1 is executed once, it may be requeued to another position. However, in order to achieve fairness, CFS will always make task T1 wait. Because task T1 is an important task for users, such waiting may cause system lag.

[0267] This embodiment proposes a scheduling method for important tasks, in addition to the aforementioned ready queue, a new running queue (hereinafter referred to as VIP queue) is created for each CPU, and its structure is similar to the aforementioned ready queue. The important tasks are placed in the VIP queue.

[0268] Important tasks refer to tasks that have a greater impact on user experience, and may include all threads (or processes) of the N applications ranked first in importance in the aforementioned embodiments; or important tasks include key threads among the threads of these N applications, such as UI threads and rendering threads; or important tasks include key threads such as the UI thread and rendering thread of the current foreground application.

[0269] Important tasks are divided into two types: static and dynamic. The identification of static important tasks usually occurs in user mode, such as the user interface (UI) thread and rendering thread of the foreground application. Static important tasks are usually de-emphasized when the importance of the application changes. Dynamic important tasks are important tasks that static important tasks depend on. Their identification usually occurs in kernel mode. Once the dependency is removed, their importance is de-emphasized. Dynamic important tasks include tasks that static important tasks directly depend on, and may also include tasks that are indirectly dependent.

[0270] The dependency here can be data dependency, lock dependency, binder service dependency or control flow dependency, etc. Data dependency means that the execution of task B must depend on the output of task A; lock dependency means that the execution of task B requires a certain lock released by task A; control flow dependency means that task B must wait for task A to be executed before it can be executed in terms of execution logic; binder service dependency means that task A calls a binder function (similar to a remote procedure call) and requires task B to complete a certain function and return the running result. In this way, task A generates a binder service dependency on task B, which is a specific instance of control flow dependency.

[0271] Taking the Linux system as an example, a specific implementation process of dependency detection relationship is introduced. Two fields are added to the task control block task_struct: static_vip and dynamic_vip, which are used to indicate the static and dynamic important task flag values ​​respectively. static_vip = 1, indicating that the task is a static important task; dynamic_vip is not equal to 0, indicating that the task is a dynamic important task. For dynamic important tasks, since a task may be simultaneously dependent on multiple other tasks, and the reasons for the dependence can be the same or different, such as mutex mutex, rwsem read-write semaphore, binder service dependency, etc., we divide the dynamic_vip field into 3 or more types, indicating mutex, rwsem and binder dependencies respectively. More types are not described in detail, and several types can also be reserved for future expansion. Each type uses 8 bits for storage. In this way, each time the corresponding dependent function is called, the block value corresponding to the field is increased by 1, and after each dependent function is completed, the value is reduced by 1 accordingly, until all fields are equal to 0, and then the important attributes of the task are cancelled and put back into the ready queue for execution.

[0272] The following takes mutex lock and binder dependency as an example to explain the steps in detail:

[0273] Important Task A calls the mutex_lock function to acquire a mutex lock. In this function, the lock status is checked. If the acquisition fails, it means that the lock has been acquired by other tasks. The current Task A is suspended and enters the sleep state. We add code to it to obtain the current holder of the lock (Task B), and add 1 to the corresponding bit of the value of the dynamic_vip field of the task structure, and then move Task B to the vip queue for scheduling. When Task B releases the lock mutex_unlock, the corresponding value of dynamic_vip in its task_struct is determined and subtracted by 1. If it is 0, the task is removed from the vip queue. The operation process of other locks is similar.

[0274] When important task A calls the binder function of ordinary task B, the binder_thread_write function in the kernel's binder driver will first find the task structure task_struct of task B and set its dynamic_vip value. Then the corresponding function id and parameters will be passed to task B, and task B will be awakened to start running. Then important task A waits for it to return the running result. When task B completes the corresponding function through the binder_thread_read function, before returning the running result to task A, it checks the value of dynamic_vip. If it is 0, the task will be removed from the vip queue.

[0275] After identifying multiple important tasks in the above manner, these tasks are inserted into the vip queue. The insertion principle can be the same as the ready queue mentioned above, that is, inserting according to the vruntime value of each task. Fig.12 For example, the vip queue includes two important tasks T1 and T7, and the current vruntime of T7 is less than the vruntime of T1.

[0276] Each time the next task to be run is obtained, the CPU first checks whether there is a task in the vip queue to be run. If there is, the task in the queue is selected to run. If the queue is empty, the task in the ready queue is selected to run. This ensures that important tasks can be run before other non-important tasks, and implements a queue-jumping function for important tasks.

[0277] Furthermore, when there are many tasks in the VIP queue, in order to avoid the tasks in the VIP queue from waiting in line, it is possible to timely check whether there are any delayed tasks in the VIP queue of each CPU. If there are delayed tasks, it is determined whether the task can be moved. If it can be moved, the task is moved to the VIP queue of another idle CPU. In this way, the migration (or relocation) of important tasks is achieved, which ensures the timely operation of important tasks, avoids jamming, and further improves the user experience.

[0278] Specifically, refer to Fig.13 , when the clock interrupt arrives (S1301), the kernel checks whether there is a task waiting time exceeding a threshold value (for example, 10ms) in the vip queue corresponding to the current cpu, that is, determines whether there is a delayed task (S1302). If the waiting time of a task exceeds the threshold, check whether the data and / or instructions of the task are still in the cache, that is, determine whether the task is movable (S1303). If the data and / or instructions of the task are not all or partially in the cache (whether the cache is hot), select a destination cpu in the cpu cluster where the current cpu is located that has no task waiting in the vip queue and no real-time task (S1304), and migrate the task to the destination cpu (S1305). Task migration can be achieved by calling the migration function provided by the kernel. Detecting whether the cache is hot can be achieved by calling the task_hot function provided by the kernel.

[0279] In the specific implementation, all the tasks that can be migrated can be identified at one time, and then the migration can be performed; or the tasks in the VIP queue can be processed sequentially.

[0280] The waiting time of a task is the time difference between the current time of the task and the time it was queued, provided that the task has never been run in the meantime; or the waiting time of a task is the time difference between the current time and the time it was last run.

[0281] To detect whether the waiting time of a task in a queue exceeds a threshold, it is usually necessary to first acquire the lock of the queue. Implementing the above method when the clock interrupt arrives can avoid deadlock to a certain extent.

[0282] When moving a task, you can move it to a CPU with higher processing efficiency than the original CPU. This way, you can further improve the processing efficiency of important tasks. For example, the current terminal device has 8 cores (cpu0-cpu7) that are generally divided into two levels, 4 small cores and 4 large cores. If the original CPU is a small core, you can choose a large core as the destination CPU and migrate the important task to it. Fig.14 shown.

[0283] By creating a VIP queue for each CPU and putting important tasks into the queue, important tasks are executed before other tasks in the ready queue, thereby ensuring the execution efficiency of important tasks. Since important tasks are related to the system's lag experience, user-perceivable system lag can be avoided to a certain extent, thereby improving the user experience of terminal devices.

[0284] It should be noted that the modules or module divisions proposed in the above embodiments are only shown as an example, and the functions of the modules described are only illustrative, and the present application is not limited thereto. The programmer can merge the functions of two or more modules according to the needs, or split the functions of a module to obtain more and finer-grained modules, as well as other variations.

[0285] The same or similar parts between the various embodiments described above may be referenced to each other.

[0286] The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the device embodiment drawings provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. Those of ordinary skill in the art can understand and implement it without paying creative labor.

[0287] The above descriptions are only some specific implementations of the present application, but the protection scope of the present application is not limited thereto.

Claims

1. A method for temporarily freezing an application, characterized in that: Applies to mobile operating systems running multiple applications, including: When a specific event is detected, some of the multiple applications are temporarily frozen, wherein the part of the applications is at least one application other than the top N applications ranked among the multiple applications, the top N applications are applications frequently used in a specific time period determined according to the importance ranking result, and the specific event includes at least one of the following events occurring in the top N applications: an application startup event, a photo taking event, a gallery zooming event, a sliding event, and a screen lighting event; the temporarily frozen part of the applications includes applications of low importance, wherein the importance of the applications is obtained according to a machine learning algorithm, as well as according to the historical usage of the applications and the current scenario data of the system; When a specific time period ends or a specific event of the first N applications is monitored to end, all or part of the frozen applications are unfrozen.

2. The method according to claim 1, characterized in that The specific event is an event indicating an increase in resource demand.

3. The method according to claim 1, characterized in that The temporary freezing is achieved by setting a timer, and the duration of the timer is set to the specific time period.

4. The method according to any one of claims 1 to 3, characterized in that: Also includes: When a change in the operating environment of one or more frozen applications is detected, unfreezing the one or more frozen applications; Detecting that the operating environment of one or more frozen applications has changed includes detecting any one or more of the following events: the frozen application is switched to the foreground, the frozen application is exited, the frozen application receives an asynchronous message, and the notification message of the frozen application is clicked by the user.

5. A terminal device, characterized in that: The terminal device includes a processor and a memory, the memory is used to store computer-readable instructions, and the processor is used to read the computer-readable instructions stored in the memory to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for implementing assist nuclear task dynamic PRI scheduling with hardware assistant

    CN101414270A

  • Computer system energy-saving method and computer system

    CN101923382A

  • Task management method and equipment

    CN104699218A

  • Application program control method and terminal

    CN106055399A

  • Application program freezing method and mobile terminal

    CN106125896A