Resource management method and apparatus, electronic device, and computer-readable storage medium
By monitoring application-layer resource requests at the operating system's framework layer and combining this with the total amount of kernel-layer resources, resource allocation is performed based on application priority and resource request priority. This solves the problem of the single resource management method in embedded operating systems, achieving flexible and targeted resource allocation and improving resource utilization and power consumption management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PRANUS BEIJING TECH CO LTD
- Filing Date
- 2022-12-29
- Publication Date
- 2026-07-21
AI Technical Summary
In existing technologies, the resource management methods of embedded operating systems are too simplistic and lack flexibility, failing to allocate resources flexibly for each application, resulting in low resource utilization.
By monitoring application layer resource requests through the operating system's framework layer and combining the total amount of resources provided by the kernel layer, resources are allocated based on the priority of each application and the priority of resource requests, thus achieving collaborative management of the application layer, framework layer, and kernel layer.
It enhances the flexibility and targeting of resource management, improves the utilization rate of operating system resources, and achieves precise power consumption control.
Smart Images

Figure CN116204306B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of operating system technology, and more specifically, to a resource management method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] With the development of computer technology, embedded operating systems have been integrated into various smart terminals or similar electronic devices. As the number of applications running on the operating system increases daily, resource management of embedded operating systems is becoming increasingly important in order to reduce the power consumption of smart terminals.
[0003] In existing technologies, resource management within the operating system is typically handled by the operating system kernel layer. The kernel layer can provide static or dynamic power management, and the operating system's application layer implements the operating system's sleep and wake-up functions by calling relevant kernel layer interfaces to reduce the power consumption of smart terminals. However, the aforementioned kernel-level resource management methods can only reduce power consumption for the entire operating system, resulting in a limited and inflexible resource management approach. Summary of the Invention
[0004] This application provides a resource management method, apparatus, electronic device, and computer-readable storage medium, which can solve the problem of low flexibility in existing resource management technologies. The technical solution is as follows:
[0005] According to one aspect of the embodiments of this application, a resource management method is provided, applied to the framework layer of an operating system, the method comprising:
[0006] Monitor multiple resource requests from the operating system's application layer at the current moment; each resource request corresponds to an application running in the application layer.
[0007] Get the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system.
[0008] The resources to be allocated are determined based on the total amount of resources and the resource consumption of the framework layer.
[0009] Based on multiple resource requests, the resources to be allocated are distributed to each application.
[0010] In one possible implementation, each of the above resource requests corresponds to at least two different types of resources;
[0011] Based on multiple resource requests, the resources to be allocated are distributed to various applications, including:
[0012] For each type of resource, the resource weight is determined based on the priority of the corresponding application;
[0013] Based on the weight of each resource, the resources to be allocated are distributed to each application.
[0014] In one possible implementation, each type of resource corresponding to the above resource request has a resource priority;
[0015] For each type of resource, the resource weight is determined based on the priority of the corresponding application, including:
[0016] For each type of resource, the resource weight is determined based on the priority of each application and the resource priority of each resource request.
[0017] In another possible implementation, the above allocates resources to various applications based on multiple resource requests, including:
[0018] For each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient;
[0019] The configuration number is updated based on the first correspondence until the application performance coefficient meets the preset conditions, and the first target configuration number of each type of resource is obtained. The preset conditions include the application performance coefficient meeting either the first interval range or the second interval range. The application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range.
[0020] Based on the first target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0021] In another possible implementation, the above allocates resources to various applications based on multiple resource requests, including:
[0022] For each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient, and a second correspondence is determined between the configuration number of each type of resource and the application overhead coefficient. The configuration number is updated based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and then the second target configuration number of each type of resource is obtained.
[0023] Based on the second target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0024] In another possible implementation, the above method also includes:
[0025] When the amount of resources to be allocated is less than the resource requirement corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request.
[0026] Turn off the services for the application to be optimized or reduce the amount of resources allocated to it.
[0027] In another possible implementation, the above method also includes:
[0028] When the change in resource demand for the corresponding resource request in the application layer exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
[0029] According to another aspect of the embodiments of this application, a resource management apparatus is provided, the apparatus comprising:
[0030] The monitoring module is used to monitor multiple resource requests from the application layer of the operating system at the current moment; each resource request corresponds to an application running in the application layer.
[0031] The acquisition module is used to obtain the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system.
[0032] The determination module is used to determine the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer.
[0033] The allocation module is used to allocate resources to various applications based on multiple resource requests.
[0034] In one possible implementation, each of the above resource requests corresponds to at least two types of resources;
[0035] The allocation module described above, when allocating resources to various applications based on multiple resource requests, is used for:
[0036] For each type of resource, the resource weight is determined based on the priority of the corresponding application;
[0037] Based on the weight of each resource, the resources to be allocated are distributed to each application.
[0038] In one possible implementation, each type of resource corresponding to the above resource request has a resource priority;
[0039] The allocation module described above, when determining the resource weight based on the priority of the corresponding application for each type of resource, is used for:
[0040] For each type of resource, the resource weight is determined based on the priority of each application and the resource priority of each resource request.
[0041] In yet another possible implementation, when the allocation module allocates resources to applications based on multiple resource requests, it is used to:
[0042] For each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient;
[0043] The configuration number is updated based on the first correspondence until the application performance coefficient meets the preset conditions, and the first target configuration number of each type of resource is obtained. The preset conditions include the application performance coefficient meeting either the first interval range or the second interval range. The application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range.
[0044] Based on the first target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0045] In yet another possible implementation, when the allocation module allocates resources to applications based on multiple resource requests, it is used to:
[0046] For each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient, and a second correspondence is determined between the configuration number of each type of resource and the application overhead coefficient. The configuration number is updated based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and then the second target configuration number of each type of resource is obtained.
[0047] Based on the second target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0048] In another possible implementation, the above-described apparatus further includes an optimization module for:
[0049] When the amount of resources to be allocated is less than the resource requirement corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request.
[0050] Turn off the services for the application to be optimized or reduce the amount of resources allocated to it.
[0051] In another possible implementation, the above method also includes a change module for:
[0052] When the change in resource demand for the corresponding resource request in the application layer exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
[0053] According to another aspect of the present application, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method shown in the first aspect of the present application.
[0054] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method shown in the first aspect of the embodiments of this application.
[0055] According to one aspect of the present application, a computer program product is provided, which includes a computer program that, when executed by a processor, implements the steps of the method shown in the first aspect of the present application.
[0056] The beneficial effects of the technical solutions provided in this application are:
[0057] In this embodiment, the operating system's framework layer monitors multiple resource requests from the operating system's application layer at the current moment, and the operating system's kernel layer determines the total amount of resources available at the current moment. Then, the operating system's framework layer determines the resources to be allocated based on the total amount of resources and the framework layer's resource consumption, and then allocates the resources to be allocated to each application based on multiple resource requests. This embodiment realizes coordinated resource management and allocation between the operating system's application layer, framework layer, and kernel layer. Compared with the prior art, which relies on the application layer calling the kernel layer's management interface to achieve a single sleep and wake-up function for the entire operating system, this application, through the operating system's framework layer, can complete resource allocation for each application based on the different resource requests corresponding to each application. This effectively improves the flexibility and targeting of resource management, enhances the utilization rate of operating system resources, and achieves precise power consumption control of the operating system. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0059] Figure 1 This is a schematic diagram illustrating an application scenario of a resource management method provided in an embodiment of this application;
[0060] Figure 2 A flowchart illustrating a resource management method provided in an embodiment of this application;
[0061] Figure 3A flowchart illustrating the determination of the weight of each type of resource in a resource management method provided in this application embodiment;
[0062] Figure 4 A schematic diagram illustrating the resource allocation process in a resource management method provided in this application embodiment;
[0063] Figure 5 A flowchart illustrating an example resource management method provided in an embodiment of this application;
[0064] Figure 6 This is a schematic diagram of the structure of a resource management device provided in an embodiment of this application;
[0065] Figure 7 This is a schematic diagram of the structure of a resource management electronic device provided in an embodiment of this application. Detailed Implementation
[0066] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0067] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0068] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0069] Currently, power management technologies for embedded operating systems can be mainly divided into:
[0070] (1) Power management for electronic device hardware, mainly including management of hardware such as SoC (System on Chip), peripherals and sensors;
[0071] (2) Power consumption management for application processes.
[0072] Existing power management functions are mainly provided by the operating system kernel, and can generally be divided into static and dynamic power (power) management. The application layer generally implements simple sleep and wake-up functions of the entire system by calling the power management interface provided by the operating system kernel layer.
[0073] The architecture of embedded operating systems or other operating systems can generally be divided into a kernel layer, a framework layer, and an application layer. The kernel layer typically refers to the operating system kernel, which is the most fundamental part of the operating system. It is the first layer of software extension based on hardware, providing the most basic functions of the operating system, such as process management, memory management, device drivers, file management, and network management. The application layer typically refers to the various applications installed in the operating system (or simply applications). Applications can directly interact with the user, receive user commands, and provide the user with various information. The framework layer usually sits between the kernel layer and the application layer. On the one hand, it provides interfaces to applications in the application layer; on the other hand, it connects with the most basic functions provided by the kernel layer. The existence of the framework layer greatly facilitates application development and maintenance. While the framework layer functions similarly across different operating systems, the specific files it contains may differ.
[0074] The inventors discovered that current operating system power management technologies mainly target the kernel and application layers, without building a collaborative management mechanism across the kernel, framework, and application layers to achieve overall power management of the operating system.
[0075] The resource management methods, apparatus, electronic devices, and computer-readable storage media provided in this application are intended to solve the above-mentioned technical problems of the prior art.
[0076] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0077] like Figure 1 As shown, the resource management method of this application can be applied to... Figure 1In the scenario shown, specifically, the smart terminal runs an operating system, in which multiple applications run on the application layer of the operating system; the framework layer of the operating system monitors multiple resource requests from the application layer at the current moment, the kernel layer of the operating system determines the total amount of resources available at the current moment, and sends the total amount of resources to the framework layer; then, the framework layer determines the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer, and allocates the resources to be allocated to each application based on the multiple resource requests.
[0078] Figure 1 In the scenario shown, the above resource management method can be performed on the terminal; in other scenarios, it can also be performed on the server.
[0079] Those skilled in the art will understand that the “terminal” used herein can be a mobile phone, tablet computer, PDA (Personal Digital Assistant), MID (Mobile Internet Device), etc.; and the “server” can be implemented using a standalone server or a server cluster composed of multiple servers.
[0080] This application provides a resource management method, such as... Figure 2 As shown, this method, which can be applied to the framework layer of an embedded operating system, includes:
[0081] S201 monitors multiple resource requests from the operating system's application layer at the current moment.
[0082] Each resource request corresponds to an application running at the application layer. Each resource request may include at least two different types of resources, which may include CPU (central processing unit), GPU (graphics processing unit), memory, audio devices, network, sensors, GUI (graphical user interface) performance, IO (input / output) performance, operating system system services, etc. The aforementioned system services may include security management, multimedia, input methods, encryption, application frameworks, computing frameworks, etc. The aforementioned applications may include video applications, web applications, chat applications, etc. The method of classifying resource types varies depending on the application scenario; it can be a rough classification based on hardware and software resources, or a detailed classification based on the specific characteristics of each hardware and software resource. This application embodiment does not impose specific limitations.
[0083] Specifically, the framework layer can monitor resource requests from multiple applications running at the application layer at any given time; each resource request can be represented as a resource list RES_LIST, as shown below:
[0084] RES_LIST={res1,res2,res3,…};
[0085] Among them, res1, res2, res3, etc. correspond to different types of resources required for the application to run.
[0086] In this embodiment, the framework layer can monitor each running application. By analyzing the functions / services provided by each application, interaction methods, quality assurance, optimization strategies, and the application's own priority, it can obtain the resources required by the current application layer and the priority of each resource guarantee, thereby determining the resource requests of each application. If the framework layer's own monitoring capabilities are insufficient, it can also request the kernel layer to assist in monitoring.
[0087] S202, Get the total amount of resources available at the current moment.
[0088] The total amount of resources is determined by the kernel layer of the operating system.
[0089] Specifically, the operating system kernel layer can monitor the current operating mode and changes in hardware resources, and update the total amount of resources currently available. For example, the status parameters of CPU, GPU, memory, power, peripherals, network, etc., can be used as the total amount of resources currently available to the system, denoted as SUM_RES.
[0090] S203, determine the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer.
[0091] Specifically, in response to the resource requests from the application layer, the framework layer analyzes the resources it needs to consume and, based on the total amount of resources provided by the kernel layer, ultimately determines the resources available for allocation to the application layer as a resource pool, denoted as RES_POOL.
[0092] S204 allocates the resources to be allocated to each application based on multiple resource requests.
[0093] In some implementations, the framework layer can match appropriate resources to each resource request based on the priority of each application and / or the priority of each resource request (i.e., the guarantee priority of various resources in RES_LIST), according to the resource collaborative management strategy, so as to reasonably allocate the resources to be allocated (i.e., RES_POOL) to each application.
[0094] In other implementations, the framework layer may also set at least one of the performance coefficients and overhead coefficients for each application based on multiple resource requests, and allocate the resources to be allocated to each application based on at least one of the performance coefficients and overhead coefficients.
[0095] In this embodiment, the operating system's framework layer monitors multiple resource requests from the application layer at the current moment, while the kernel layer determines the total amount of available resources. Then, the framework layer determines the resources to be allocated based on the total resource amount and its own resource consumption, and subsequently allocates these resources to various applications based on the multiple resource requests. This embodiment achieves coordinated resource management and allocation across the operating system's application layer, framework layer, and kernel layer. Compared to existing technologies that rely on the application layer calling the kernel layer's management interface to implement a single sleep and wake-up function for the entire operating system, this embodiment, through the operating system's framework layer, can allocate resources to each application based on its specific resource requests. This effectively improves the flexibility and targeting of resource management, enhances the utilization of operating system resources, and achieves precise power consumption control.
[0096] This application provides a possible implementation method in which each of the above resource requests corresponds to at least two different types of resources.
[0097] Based on multiple resource requests, the resources to be allocated are distributed to various applications, including:
[0098] S301 determines the weight of each type of resource based on the priority of the corresponding application.
[0099] Specifically, for each type of resource, the weight of that resource for each application can be determined based on the priority of the corresponding application.
[0100] The priority of an application can be determined based on the number of times the application is used, the current foreground / background state of the application, the working mode (such as real-time or asynchronous), or it can be determined based on the priority command sent by the user. No specific restrictions are imposed in this embodiment.
[0101] S302 allocates the resources to be allocated to each application according to the weight of each resource.
[0102] The higher the priority of the aforementioned application, the greater the weight of the corresponding resource types.
[0103] In this embodiment of the application, for example, if three different applications have all applied for a certain type of resource res1, the weight of res1 corresponding to each application can be determined based on the different priorities of the three applications, and res1 can be allocated to each application according to the weight.
[0104] This application embodiment determines the weight of different types of resources corresponding to different applications by prioritizing the application, thereby realizing resource allocation based on different weights and effectively enhancing the pertinence and accuracy of resource allocation.
[0105] This application provides one possible implementation method, such as... Figure 3 As shown, each type of resource corresponding to the above resource request has a resource priority.
[0106] For each type of resource, its weight is determined based on the priority of the corresponding application, including:
[0107] For each type of resource, the weight of each type of resource is determined based on the priority of the corresponding application and the resource priority of the corresponding resource request.
[0108] The weight of each of the above-mentioned resource types can increase as the application priority or resource priority increases.
[0109] Specifically, the resource requests for each application differ. For example, video applications typically prioritize resources such as CPU, GPU, VPU (Video Processing Unit), and GUI to ensure a good user experience, guaranteeing video resolution, frame rate, and multimedia capabilities (such as hardware and software acceleration, encoding and decoding capabilities). Chat applications, on the other hand, typically prioritize resources such as CPU, memory, network, and I / O performance to ensure real-time chat message transmission.
[0110] Furthermore, users can adjust the priority of the above applications, the priority of each type of resource, or the weight of each type of resource according to their actual needs, so as to ensure the performance of each application and enhance the flexibility of resource allocation.
[0111] In this embodiment, the weight of each type of resource corresponding to each application is determined by combining the application priority and resource priority, which further refines the granularity of resource allocation and improves the utilization rate of operating system resources.
[0112] This application provides one possible implementation method, such as... Figure 4 As shown, the above method allocates resources to various applications based on multiple resource requests, including:
[0113] S401, for each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient.
[0114] The above-mentioned configuration numbers can be the number of processes, power consumption, etc. required for various types of resources, and are not specifically limited in this embodiment.
[0115] In this embodiment of the application, taking the various types of resources corresponding to the resource request, including CPU, GPU, VPU, IO, and GUI, as an example, the configuration number of each type of resource can be x, where,
[0116] x = [x1, x2, x3, x4, x5];
[0117] Where x1 is the number of CPU resource configurations, x2 is the number of GPU resource configurations, x3 is the number of VPU resource configurations, x4 is the number of IO resource configurations, and x5 is the number of GUI resource configurations.
[0118] Therefore, the performance coefficient of this application can be f(x).
[0119]
[0120] Formula (1) above can be used to characterize the first correspondence; where, For CPU performance coefficients, This is the GPU performance coefficient. The VPU performance coefficient. For I / O performance coefficient, This is a GUI performance factor.
[0121] In this embodiment, the application's performance coefficient is related to factors such as the current state, environment, and load of the operating system. The aforementioned first correspondence is usually not a simple linear mapping. In practice, a linear mapping can be used to determine the first correspondence; alternatively, a modeling method can be used to record and statistically analyze the correspondence between the number of resource configurations and the application's performance coefficient under various environmental, load, and state conditions, and then determine the first correspondence based on the specific scenario.
[0122] S402, update the configuration number based on the first correspondence until the application performance coefficient meets the preset conditions, and obtain the first target configuration number of each type of resource; the preset conditions include the application performance coefficient meeting either the first interval range or the second interval range; the application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range.
[0123] The first interval range is the range of application performance coefficients when the application performance is optimal; the second interval range is the range of application performance coefficients when the application power consumption is minimum.
[0124] S403 allocates the resources to be allocated to each application based on the first target configuration number corresponding to each resource request.
[0125] In this embodiment of the application, the overall resource configuration of the application layer can be optimized based on the first correspondence, wherein the optimization includes performance optimization and energy consumption optimization. When the preset condition is that the application performance coefficient meets the first range, each application in the application layer can be in the optimal performance state, thereby achieving high-performance operation of the overall operating system. When the preset condition is that the application performance coefficient meets the second range, each application in the application layer can be in the optimal low-energy state, thereby achieving low-energy operation of the overall operating system.
[0126] This application provides a possible implementation method in which the above-mentioned allocation of resources to be allocated to each application based on multiple resource requests includes:
[0127] S501, for each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient, and determine the second correspondence between the configuration number of each type of resource and the application overhead coefficient; update the configuration number based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and obtain the second target configuration number of each type of resource.
[0128] The resource balance range can be used to indicate that the ratio of the application's performance to its overhead is in a state of supply and demand equilibrium.
[0129] S502 allocates the resources to be allocated to each application based on the second target configuration number corresponding to each resource request.
[0130] In this embodiment of the application, the supply and demand status of each application in the application layer of the operating system can be controlled based on the first correspondence and the second correspondence. According to the preset resource balance range, the performance of the application and the quality of service provided to the user can reach a balance with the resource occupation of the operating system, thereby further improving the utilization rate of the operating system resources.
[0131] This application provides a possible implementation method, and the above method further includes:
[0132] S601, when the amount of resources to be allocated is less than the resource demand corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request.
[0133] S602, shut down the service for the application to be optimized or reduce the amount of resources allocated to the application to be optimized.
[0134] Disabling services for applications to be optimized typically refers to disabling all or some of the operating system services used by the applications to be optimized. If possible, the service quality of the operating system services used by the applications to be optimized can also be reduced.
[0135] Reduce the amount of resources allocated to applications that are not being optimized. For example, when a video application is an application that is not being optimized, the VPU performance can be reduced by lowering the video resolution, so as to ensure the smoothness of the video application while reducing resource consumption.
[0136] In this embodiment of the application, when the power of the electronic device is insufficient or the available processes of the operating system are insufficient to support the current resource requests, measures such as closing the services of the application to be optimized or reducing the amount of resources allocated to the application to be optimized can be taken to reduce the overall resource consumption of the application layer, so as to match the currently available resources and ensure the normal operation of the operating system.
[0137] This application provides a possible implementation method, and the above method further includes:
[0138] When the change in resource demand for the corresponding resource request in the application layer exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
[0139] The aforementioned status change instructions may include enable and disable instructions.
[0140] In this embodiment, the framework layer can monitor the resource requirements of the current application layer in real time. When the application layer is idle, it can send a shutdown command to the kernel layer through a preset interface. For example, it can control peripherals by powering them down, dynamically adjusting their frequency, or putting them into sleep mode, thereby reducing unnecessary overhead on the operating system. When the resource requirements of the application layer suddenly increase within a preset time period, it can send an enable command to the kernel layer through a preset interface, such as controlling peripherals by powering them on, to respond to the resource requirements of the application layer. This embodiment can achieve dynamic adjustment of kernel layer resource supply, realizing resource management aimed at ensuring user experience, high application performance, and low operating system power consumption.
[0141] To better understand the above resource management methods, the following will combine... Figure 5 A detailed example of a resource management method according to this application is provided, which includes the following steps:
[0142] S701, the framework layer of the operating system monitors multiple resource requests from the application layer of the operating system at the current moment.
[0143] Each resource request corresponds to an application running at the application layer; each resource request may include at least two types of resources.
[0144] S702 is an operating system kernel layer that monitors the operating system's current operating mode and changes in hardware resources to determine the total amount of resources available at the current moment.
[0145] S703, the framework layer determines the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer.
[0146] S704, when the framework layer adopts a resource scheduling strategy for applications: for each type of resource, based on the priority of each application and the resource priority of each resource request, the weight of each type of resource for each application is determined; according to the weight of each type of resource, the resources to be allocated are allocated to each application.
[0147] The weight of each of the above-mentioned resource types can increase as the application priority or resource priority increases.
[0148] S705, the framework layer adopts a resource scheduling strategy for the entire operating system: for each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient; the configuration number is updated based on the first correspondence until the application performance coefficient meets the preset conditions, and the first target configuration number of each type of resource is obtained; based on the first target configuration number corresponding to each resource request, the resources to be allocated are allocated to each application.
[0149] The preset conditions include: the application performance coefficient meeting either a first range or a second range; the application performance coefficient meeting the first range is greater than the application performance coefficient meeting the second range; the first range is the range of the application performance coefficient when the application performance is optimal; and the second range is the range of the application performance coefficient when the application power consumption is lowest.
[0150] S706, the framework layer adopts a resource balancing strategy for the entire operating system: For each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient, and a second correspondence is determined between the configuration number of each type of resource and the application overhead coefficient; the configuration number is updated based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and a second target configuration number for each type of resource is obtained; based on the second target configuration number corresponding to each resource request, the resources to be allocated are allocated to each application.
[0151] S707, when the amount of resources to be allocated is less than the resource requirement corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request; the service of the application to be optimized is shut down or the amount of resources allocated to the application to be optimized is reduced.
[0152] S708: When the change in the resource demand of the application layer's corresponding resource request exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
[0153] The aforementioned status change instructions may include enable and disable instructions.
[0154] In this embodiment, the operating system's framework layer monitors multiple resource requests from the application layer at the current moment, while the kernel layer determines the total amount of available resources. Then, the framework layer determines the resources to be allocated based on the total resource amount and its own resource consumption, and subsequently allocates these resources to various applications based on the multiple resource requests. This embodiment achieves coordinated resource management and allocation across the operating system's application layer, framework layer, and kernel layer. Compared to existing technologies that rely on the application layer calling the kernel layer's management interface to implement a single sleep and wake-up function for the entire operating system, this embodiment, through the operating system's framework layer, can allocate resources to each application based on its specific resource requests. This effectively improves the flexibility and targeting of resource management, enhances the utilization of operating system resources, and achieves precise power consumption control.
[0155] This application provides a resource management device, such as... Figure 6 As shown, the resource management device 60 may include: a monitoring module 601, an acquisition module 602, a determination module 603, and an allocation module 604;
[0156] The monitoring module 601 is used to monitor multiple resource requests from the application layer of the operating system at the current moment; each resource request corresponds to an application running in the application layer.
[0157] The acquisition module 602 is used to obtain the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system.
[0158] Module 603 is used to determine the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer.
[0159] The allocation module 604 is used to allocate resources to various applications based on multiple resource requests.
[0160] This application provides a possible implementation method in which each of the above resource requests corresponds to at least two types of resources;
[0161] When allocating resources to various applications based on multiple resource requests, the allocation module 604 described above is used for:
[0162] For each type of resource, the resource weight is determined based on the priority of the corresponding application;
[0163] Based on the weight of each resource, the resources to be allocated are distributed to each application.
[0164] This application provides a possible implementation method in which each type of resource corresponding to the above resource request has a resource priority;
[0165] When determining the weight of a resource based on the priority of the corresponding application for each type of resource, the allocation module 604 described above is used to:
[0166] For each type of resource, the resource weight is determined based on the priority of each application and the resource priority of each resource request.
[0167] This application embodiment provides a possible implementation method in which the allocation module 604, when allocating resources to be allocated to various applications based on multiple resource requests, is used to:
[0168] For each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient;
[0169] The configuration number is updated based on the first correspondence until the application performance coefficient meets the preset conditions, and the first target configuration number of each type of resource is obtained. The preset conditions include the application performance coefficient meeting either the first interval range or the second interval range. The application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range.
[0170] Based on the first target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0171] This application embodiment provides a possible implementation method in which the allocation module 604, when allocating resources to be allocated to various applications based on multiple resource requests, is used to:
[0172] For each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient, and a second correspondence is determined between the configuration number of each type of resource and the application overhead coefficient. The configuration number is updated based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and then the second target configuration number of each type of resource is obtained.
[0173] Based on the second target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
[0174] This application embodiment provides a possible implementation, and the above-described apparatus further includes an optimization module, used for:
[0175] When the amount of resources to be allocated is less than the resource requirement corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request.
[0176] Turn off the services for the application to be optimized or reduce the amount of resources allocated to it.
[0177] This application provides a possible implementation method, which further includes a modification module for:
[0178] When the change in resource demand for the corresponding resource request in the application layer exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
[0179] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0180] This application embodiment monitors multiple resource requests from the application layer of the operating system at the current moment through the operating system's framework layer, while the kernel layer of the operating system determines the total amount of resources available at the current moment. Then, the framework layer determines the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer, and then allocates the resources to each application based on multiple resource requests. This application embodiment realizes resource management and allocation in coordination between the application layer, framework layer, and kernel layer of the operating system. Compared with the prior art, which achieves a single sleep and wake-up function of the entire operating system by calling the kernel layer's management interface from the application layer, this application can complete resource allocation for each application based on the different resource requests corresponding to each application through the operating system's framework layer. This effectively improves the flexibility and targeting of resource management, enhances the utilization rate of operating system resources, and achieves precise power consumption control of the operating system.
[0181] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a resource management method. Compared with related technologies, this application monitors multiple resource requests from the application layer of the operating system at the current moment through the operating system's framework layer, and the kernel layer of the operating system determines the total amount of resources available at the current moment. Then, the framework layer of the operating system determines the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer, and then allocates the resources to be allocated to each application based on multiple resource requests. This application realizes resource management and allocation through the coordinated action of the application layer, framework layer, and kernel layer of the operating system. Compared with the prior art, which implements a single sleep and wake-up function of the entire operating system by calling the kernel layer's management interface from the application layer, this application can complete resource allocation for each application based on the different resource requests corresponding to each application through the operating system's framework layer. This effectively improves the flexibility and targeting of resource management, enhances the utilization rate of operating system resources, and achieves precise power consumption control of the operating system.
[0182] In one alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7 The illustrated electronic device 70 includes a processor 701 and a memory 703. The processor 701 and the memory 703 are connected, for example, via a bus 702. Optionally, the electronic device 70 may further include a transceiver 704, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 704 is not limited to one type, and the structure of this electronic device 70 does not constitute a limitation on the embodiments of this application.
[0183] Processor 701 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 701 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0184] Bus 702 may include a pathway for transmitting information between the aforementioned components. Bus 702 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 702 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0185] The memory 703 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0186] The memory 703 stores computer programs that execute embodiments of this application, and the processor 701 controls their execution. The processor 701 executes the computer programs stored in the memory 703 to implement the steps shown in the foregoing method embodiments.
[0187] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, and tablets, as well as fixed terminals such as digital TVs and desktop computers.
[0188] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0189] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the following actions:
[0190] Monitor multiple resource requests from the operating system's application layer at the current moment; each resource request corresponds to an application running in the application layer.
[0191] Get the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system.
[0192] The resources to be allocated are determined based on the total amount of resources and the resource consumption of the framework layer.
[0193] Based on multiple resource requests, the resources to be allocated are distributed to each application.
[0194] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0195] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0196] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A resource management method applied to the framework layer of an operating system, characterized in that, include: Monitor multiple resource requests from the application layer of the operating system at the current moment; wherein each resource request corresponds to an application running in the application layer; Obtain the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system; The resources to be allocated are determined based on the total amount of resources and the resource consumption of the framework layer; Based on the multiple resource requests, the resources to be allocated are distributed to each application. Each resource request corresponds to at least two different types of resources; The process of allocating the resources to be allocated to each application based on the multiple resource requests includes: For each type of resource, the weight of the resource is determined based on the priority of the corresponding application; Based on the weight of each resource, the resources to be allocated are distributed to each application; each type of resource corresponding to the resource request has a resource priority; wherein, the weight is positively correlated with the priority of the application or the priority of the resource; The process of allocating the resources to be allocated to each application based on the multiple resource requests includes: For each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient; The configuration number is updated based on the first correspondence until the application performance coefficient meets the preset condition, and the first target configuration number of each type of resource is obtained; the preset condition includes the application performance coefficient meeting either the first interval range or the second interval range; the application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range. Based on the first target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
2. The method according to claim 1, characterized in that, For each type of resource, determining the weight of the resource based on the priority of the corresponding application includes: For each type of resource, the weight of the resource is determined based on the priority of each application and the resource priority of each resource request.
3. The method according to claim 1, characterized in that, The process of allocating the resources to be allocated to each application based on the multiple resource requests includes: For each resource request, a first correspondence is determined between the configuration number of each type of resource and the application performance coefficient, and a second correspondence is determined between the configuration number of each type of resource and the application overhead coefficient. The configuration number is updated based on the first and second correspondences until the ratio of the application performance coefficient to the application overhead coefficient meets the preset resource balancing range, and then the second target configuration number of each type of resource is obtained. Based on the second target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
4. The method according to claim 1, characterized in that, The method further includes: When the amount of resources to be allocated is less than the resource requirement corresponding to the resource request, the application to be optimized is selected based on the priority of each application and the resource priority of each type of resource corresponding to each resource request. Shut down the services of the application to be optimized or reduce the amount of resources allocated to the application to be optimized.
5. The method according to claim 1, characterized in that, The method further includes: When the change in the resource demand of the application layer's corresponding resource request exceeds a preset threshold within a preset time period, a state change instruction for the application is sent to the kernel layer through a preset interface.
6. A resource management device, characterized in that, include: The monitoring module is used to monitor multiple resource requests from the application layer of the operating system at the current moment; wherein each resource request corresponds to an application running in the application layer. The acquisition module is used to acquire the total amount of resources available at the current moment; the total amount of resources is determined by the kernel layer of the operating system. The determination module is used to determine the resources to be allocated based on the total amount of resources and the resource consumption of the framework layer; The allocation module is used to allocate the resources to be allocated to each application based on the multiple resource requests; Each resource request corresponds to at least two different types of resources; The allocation module is specifically used for: For each type of resource, the weight of the resource is determined based on the priority of the corresponding application; Based on the weight of each resource, the resources to be allocated are distributed to each application; each type of resource corresponding to the resource request has a resource priority; wherein, the weight is positively correlated with the priority of the application or the priority of the resource; The allocation module can also be used for: For each resource request, determine the first correspondence between the configuration number of each type of resource and the application performance coefficient; The configuration number is updated based on the first correspondence until the application performance coefficient meets the preset condition, and the first target configuration number of each type of resource is obtained; the preset condition includes the application performance coefficient meeting either the first interval range or the second interval range; the application performance coefficient meeting the first interval range is greater than the application performance coefficient meeting the second interval range. Based on the first target configuration number corresponding to each resource request, the resources to be allocated are distributed to each application.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.