Backend service scheduling method, device, equipment and medium
By obtaining CPU occupancy rate and background service parameter information in electronic devices, determining the priority and scheduling order of background services, the problem of excessive system resources being occupied by backend services is solved, and more uniform resource occupation and higher front-end service efficiency is achieved.
Patent Information
- Application Number
- CN202411986158.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-08
AI Technical Summary
In the case of low power consumption, the simultaneous scheduling of backend services will occupy more system resources, affecting the operation of front-end services and the display of electronic device interfaces.
By obtaining the current CPU occupancy rate of the electronic device and parameter information of the background service, the priority of each background service is determined, and the number and priority order of the background services that need to be scheduled based on the CPU occupancy rate and priority level are determined, and the corresponding background services are then dispatched.
This method effectively reduces the use of system resources by backend services, avoids the problem of instantaneous increase in system resource load, and improves the operation efficiency of frontend services and the display performance of electronic device interfaces.
Smart Images

Figure CN119781939A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to a background service scheduling method, device, equipment and medium. Background Art
[0002] Background services are used to perform time-consuming operations that do not require user interaction or to provide some functions to other applications.
[0003] In the related art, the power consumption control of electronic devices is increasingly strict with background services. Usually, background services are not allowed to execute under low power consumption conditions. However, when background services are not restricted, a large number of background services will be scheduled at the same time for execution. For example, in a scenario where the screen of an electronic device is turned off and then turned on again after being put into sleep mode, a large number of background services will be scheduled at the same time. However, scheduling a large number of background services at the same time will occupy more system resources, affecting the operation of foreground services and the display of the electronic device interface. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a background service scheduling method, device, equipment and medium, which can solve the problem of occupying too many system resources.
[0005] In a first aspect, an embodiment of the present application provides a background service scheduling method, including:
[0006] Obtaining the current CPU occupancy rate of the electronic device and parameter information of each background service in the plurality of background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range, and the background service delayed execution time range;
[0007] Determine the priority of each background service based on the parameter information;
[0008] Determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate;
[0009] Determine a first background service that needs to be scheduled according to the priority and the first quantity of each background service;
[0010] Schedule the first background service.
[0011] In a second aspect, an embodiment of the present application provides a background service scheduling device, including:
[0012] An acquisition module, used to acquire the current CPU occupancy rate of the electronic device and parameter information of each background service in a plurality of background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range and the background service delayed execution time range;
[0013] A first determination module, used to determine the priority of each background service according to the parameter information;
[0014] A second determining module, used to determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate;
[0015] A third determining module, used to determine the first background service that needs to be scheduled according to the priority and the first quantity of each background service;
[0016] The scheduling module is used to schedule the first background service.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the background service scheduling method provided in the embodiment of the present application are implemented.
[0018] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the background service scheduling method provided in the embodiment of the present application are implemented.
[0019] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the steps of the background service scheduling method provided in the embodiment of the present application.
[0020] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the steps of the background service scheduling method provided in an embodiment of the present application.
[0021] In the embodiment of the present application, the priority of each background service is determined by the parameter information of the background service, and the first number of background services to be scheduled is determined by the current CPU occupancy rate of the electronic device, and then the first background service to be scheduled is determined according to the priority and the first number of each background service, and then the first background service is scheduled. In this way, not all background services are scheduled at the same time, which can reduce the occupation of system resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1It is a flowchart of the background service scheduling method provided in the embodiment of the present application;
[0023] Figure 2 is a priority coordinate diagram provided in an embodiment of the present application;
[0024] Figure 3 It is a process diagram of the scheduling background service provided by the embodiment of the present application;
[0025] Figure 4 It is a structural diagram of a background service scheduling device provided in an embodiment of the present application;
[0026] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0027] Figure 6 It is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0029] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0030] The following, in conjunction with the accompanying drawings, describes in detail the background service scheduling method, device, equipment and medium provided by the embodiments of the present application through specific embodiments and their application scenarios.
[0031] Figure 1 : is a flowchart of a background service scheduling method provided in an embodiment of the present application. The background service scheduling method may include:
[0032] Step 101: obtaining the current CPU occupancy rate of the electronic device and parameter information of each background service in a plurality of background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range, and the background service delayed execution time range;
[0033] In some possible implementations of the embodiments of the present application, the lower the priority value corresponding to the priority of the application process, the higher the priority of the application process.
[0034] Step 102: Determine the priority of each background service according to the parameter information;
[0035] In some possible implementations of the embodiments of the present application, step 102 may include: for the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; and using the priority corresponding to the importance as the priority corresponding to the second service.
[0036] In some possible implementations of the embodiments of the present application, for the second background service, determining the importance of the second background service based on the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range can include: determining a first difference between the priority of the application process corresponding to the second background service and the minimum value of the application process priority range; determining a second difference between the maximum value of the application process priority range and the minimum value of the application process priority range; and determining the ratio of the first difference to the second difference as the importance of the second background service.
[0037] In some possible implementations of the embodiments of the present application, the importance of the background service can be determined by the following formula (1):
[0038]
[0039] In formula (1), P1 is the importance of the background service, Padj is the priority of the application process corresponding to the background service, maxadj is the maximum value of the application process priority range, and minadj is the minimum value of the application process priority range. P1 is a value in the interval [0,1].
[0040] It should be noted that, the smaller the value of the importance P1 of the background service is, the higher its corresponding priority is, and the larger the value of the importance P1 of the background service is, the lower its corresponding priority is.
[0041] In some possible implementations of the embodiments of the present application, step 102 may include: for the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; determining the dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range; and using the priority corresponding to the dimension value as the priority corresponding to the second background service.
[0042] The embodiment of the present application does not elaborate on the process of determining the importance of the second background service, and the specific process can be referred to the description above.
[0043] In some possible implementations of the embodiments of the present application, determining the dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range may include: determining the maximum value of the scheduling interval corresponding to the second background service according to the importance of the second background service and the maximum value of the background service delayed execution time range; determining the minimum value of the scheduling interval corresponding to the second background service according to the importance of the second background service and the minimum value of the background service delayed execution time range; determining the dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the scheduling interval corresponding to the second background service, and the minimum value of the scheduling interval corresponding to the second background service.
[0044] In some possible implementations of the embodiments of the present application, the maximum value of the scheduling interval corresponding to the background service can be determined by the following formula (2):
[0045] Tmax=TC+P1*maxDELAY (2)
[0046] In formula (2), Tmax is the maximum value of the scheduling interval corresponding to the background service, TC is the time for obtaining parameter information of multiple background services, P1 is the importance of the background service, and maxDELAY is the maximum value of the delayed execution time range of the background service.
[0047] In some possible implementations of the embodiments of the present application, the minimum value of the scheduling interval corresponding to the background service can be determined by the following formula (3):
[0048] Tmin=TC+P1*minDELAY (3)
[0049] In formula (3), Tmin is the maximum value of the scheduling interval corresponding to the background service, TC is the time for obtaining parameter information of multiple background services, P1 is the importance of the background service, and minDELAY is the minimum value of the delayed execution time range of the background service.
[0050] In some possible implementations of the embodiments of the present application, the dimension value of the background service in the scheduling interval dimension can be determined by the following formula (4):
[0051]
[0052] In formula (4), P2 is the dimension value of the background service in the scheduling interval dimension, TC is the current time, Tmax is the maximum value of the scheduling interval corresponding to the background service, and Tmin is the minimum value of the scheduling interval corresponding to the background service. P2 is a value in the interval [0,1].
[0053] It should be noted that the smaller the dimension value P2 of the background service in the scheduling interval dimension, the higher its corresponding priority, and the larger the P2, the lower its corresponding priority.
[0054] When the priority corresponding to the dimension value of the second background service in the scheduling interval dimension is used as the priority corresponding to the second background service, the priority of the second background service will become higher and higher as time goes by.
[0055] In some possible implementations of the embodiments of the present application, step 102 may include: for the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; determining the dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range; determining the priority of the first background service according to the importance of the first background service and the dimension value of the first background service in the scheduling interval dimension.
[0056] Among them, the embodiment of the present application does not elaborate on the process of determining the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension. The specific process can be referred to the description above.
[0057] In some possible implementations of the embodiments of the present application, determining the priority of the second background service based on the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension can include: taking the priority corresponding to the product of the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension as the priority of the second background service.
[0058] In some possible implementations of the embodiments of the present application, the priority of the background service may be determined by the following formula (5):
[0059] P3=P1*P2 (5)
[0060] Among them, in formula (5), P3 is the value corresponding to the priority of the background service, P1 is the importance of the background service, and P2 is the dimension value of the background service in the scheduling interval dimension. P3 is a value in the interval [0,1]. The smaller the P3 value, the higher the priority of the background service, and the larger the P3 value, the lower the priority of the background service.
[0061] Exemplarily, it is assumed that there are 8 background services, which are background service A, background service B, background service C, background service D, background service E, background service F, background service G and background service H respectively.
[0062] The above formula (1) shows that the importance of background services A to H are 0.8, 0.7, 0.6, 0.3, 0.4, 0.33, 0.2, 0 respectively; the above formulas (2) to (4) show that the dimension values of background services A to H in the scheduling interval dimension are 0.3, 0.4, 0.5, 0.4, 0, 0.7, 0.8, 1 respectively. Figure 2 As shown, Figure 2 is a priority coordinate diagram provided by an embodiment of the present application, wherein Figure 2 In the figure, the horizontal axis "scheduling interval" indicates the dimension value of the background service in the scheduling interval dimension, and the vertical axis "importance" indicates the importance of the background service. The product of the horizontal axis and the vertical axis of the coordinate point is the value corresponding to the priority of the background service corresponding to the coordinate point. Then the values corresponding to the priorities of background services A to H are: 0.24, 0.28, 0.3, 0.12, 0, 0.231, 0.16, 0. The priorities of background services A to H are, from high to low, background service H, background service E, background service D, background service G, background service F, background service A, background service B, and background service C, among which background service H and background service E have the same priority.
[0063] Step 103: Determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate;
[0064] In some possible implementations of the embodiments of the present application, the correspondence between the CPU occupancy rate and the number of background services that need to be scheduled can be set according to actual needs. Exemplarily, when the CPU occupancy rate is less than or equal to 40%, the number of background services that need to be scheduled is N; when the CPU occupancy rate is greater than 40% and less than or equal to 60%, the number of background services that need to be scheduled is Nb; when the CPU occupancy rate is greater than 60% and less than or equal to 80%, the number of background services that need to be scheduled is N-2b; when the CPU occupancy rate is greater than 80%, the number of background services that need to be scheduled is 0. Wherein, N and b are positive integers, N is greater than 2b, and N and b can be set according to actual needs, for example, N is 3 and b is 1.
[0065] Step 104: Determine a first background service that needs to be scheduled according to the priority and the first quantity of each background service;
[0066] In some possible implementations of the embodiments of the present application, after determining the priority of each background service and the first number of background services that need to be scheduled, the first number of background services with the highest priority can be determined as the background services that need to be scheduled.
[0067] Step 105: Schedule the first background service.
[0068] After the background service that needs to be scheduled is determined, the determined background service that needs to be scheduled can be scheduled.
[0069] In some possible implementations of the embodiments of the present application, background services may be scheduled at fixed time intervals.
[0070] Exemplarily, it is assumed that there are 6 background services, wherein the 6 background services are background service A, background service B, background service C, background service D, background service E and background service F. The fixed time interval is T.
[0071] Through the above step 102, the priorities of the six background services are determined from high to low, namely background service C, background service B, background service E, background service F, background service A and background service D. According to the current CPU occupancy rate of the electronic device, it is determined that the number of background services that need to be scheduled is 2, so background service C and background service B are scheduled.
[0072] After a fixed time interval T, it is determined that the number of background services that need to be scheduled is 3 according to the current CPU occupancy rate of the electronic device, and then background service E, background service F and background service A are scheduled.
[0073] After a fixed time interval T, it is determined that the number of background services that need to be scheduled is 1 according to the current CPU occupancy rate of the electronic device, and the background service D is scheduled.
[0074] In some possible implementations of the embodiments of the present application, the background service can be scheduled according to different time intervals. Based on this, the background service scheduling method provided by the embodiments of the present application can also include: determining a first scheduling time interval corresponding to the current CPU occupancy rate according to the corresponding relationship between the CPU occupancy rate and the background service scheduling time interval; determining the first time for the next scheduling of the background service according to the first scheduling time interval, and continuing to execute step 101 when the first time is reached.
[0075] In some possible implementations of the embodiments of the present application, the correspondence between the CPU occupancy rate and the background service scheduling time interval can be set according to actual needs. Exemplarily, when the CPU occupancy rate is less than or equal to 40%, the background service scheduling time interval is T; when the CPU occupancy rate is greater than 40% and less than or equal to 60%, the background service scheduling time interval is T+C; when the CPU occupancy rate is greater than 60% and less than or equal to 80%, the background service scheduling time interval is T+2C. Among them, T and C can be set according to actual needs, for example, T is 10 milliseconds (ms) and C is 5ms.
[0076] Exemplarily, it is assumed that there are 6 background services, wherein the 6 background services are background service A, background service B, background service C, background service D, background service E and background service F. The fixed time interval is T.
[0077] Through the above step 102, it is determined that the priorities of the six background services are background service C, background service B, background service E, background service F, background service A and background service D from high to low. According to the current CPU occupancy rate of the electronic device, it is determined that the number of background services that need to be scheduled is 2, and the background service scheduling time interval is 10ms, so background service C and background service B are scheduled.
[0078] After 10 ms, the number of background services that need to be scheduled is determined to be 3 according to the current CPU occupancy rate of the electronic device, and the background service scheduling interval is 15 ms, so background service E, background service F and background service A are scheduled.
[0079] After another 15 ms, it is determined that the number of background services that need to be scheduled is 1 according to the current CPU occupancy rate of the electronic device, and the background service scheduling interval is 20 ms, so the background service D is scheduled.
[0080] In the embodiment of the present application, the priority of each background service is determined by the parameter information of the background service, and the first number of background services to be scheduled is determined by the CPU occupancy rate of the electronic device, and then the first background service to be scheduled is determined according to the priority of each background service and the determined first number, and then the first background service is scheduled. In this way, all background services are not scheduled at the same time, so that the background services occupy system resources more evenly, avoiding the phenomenon of sudden surge in system resource load and occupying system resources, and reducing the occupation of system resources.
[0081] Figure 3 Schematic diagram of the process of scheduling background services provided by the embodiment of the present application. The process of scheduling background services includes the following steps:
[0082] Step 301: when multiple background services are started, calculating the importance of each background service in the multiple background services and the dimension value in the scheduling interval dimension;
[0083] Step 302: Calculate the priority of each background service according to the importance of each background service and the dimension value in the scheduling interval dimension;
[0084] Step 303: Obtain the current CPU occupancy rate of the electronic device;
[0085] Step 304: determining the number of background services that need to be scheduled from the multiple background services according to the CPU occupancy rate;
[0086] Step 305: batch scheduling the background services according to the determined quantity and priority of the background services;
[0087] Step 306: Determine whether the scheduling of multiple background services has been completed. If yes, then end. If not, execute step 307;
[0088] Step 307: Determine whether the next scheduling time has arrived. If yes, execute step 302; if no, execute step 307.
[0089] in, Figure 3 The execution process of each step in is referred to the description above, and the embodiments of the present application will not be described in detail here.
[0090] The background service scheduling method provided in the embodiment of the present application can be executed by a background service scheduling device. In the embodiment of the present application, the background service scheduling device provided in the embodiment of the present application is described by taking the background service scheduling device executing the background service scheduling method as an example.
[0091] Figure 4 400 is a schematic diagram of the structure of the background service scheduling device provided in the embodiment of the present application. The background service scheduling device 400 may include:
[0092] The acquisition module 401 is used to obtain the current CPU occupancy rate of the electronic device and parameter information of each background service in the multiple background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range and the background service delay execution time range;
[0093] A first determination module 402 is used to determine the priority of each background service according to the parameter information;
[0094] The second determination module 403 is used to determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate;
[0095] A third determining module 404, configured to determine a first background service that needs to be scheduled according to the priority and the first quantity of each background service;
[0096] The scheduling module 405 is used to schedule the first background service.
[0097] In the embodiment of the present application, the priority of each background service is determined by the parameter information of the background service, and the first number of background services to be scheduled is determined by the CPU occupancy rate of the electronic device, and then the first background service to be scheduled is determined according to the priority of each background service and the determined first number, and then the first background service is scheduled. In this way, all background services are not scheduled at the same time, so that the background services occupy system resources more evenly, avoiding the phenomenon of sudden surge in system resource load and occupying system resources, and reducing the occupation of system resources.
[0098] In some possible implementations of the embodiment of the present application, the first determining module 402 includes:
[0099] A first determination submodule is used to determine the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0100] The second determining submodule is used to use the priority corresponding to the importance as the priority corresponding to the second background service.
[0101] In some possible implementations of the embodiment of the present application, the first determining module 402 includes:
[0102] A first determination submodule is used to determine the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0103] A third determination submodule, configured to determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range;
[0104] The fourth determination submodule is used to use the priority corresponding to the dimension value as the priority corresponding to the second background service.
[0105] In some possible implementations of the embodiment of the present application, the first determining module 402 includes:
[0106] A first determination submodule is used to determine the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0107] A third determination submodule, configured to determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range;
[0108] The fifth determining submodule is used to determine the priority of the second background service according to the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension.
[0109] In some possible implementations of the embodiments of the present application, the first determining submodule is specifically used to:
[0110] Determine a first difference between the priority of the application process corresponding to the second background service and a minimum value of the application process priority range;
[0111] Determine a second difference between a maximum value of the application process priority range and a minimum value of the application process priority range;
[0112] The ratio of the first difference to the second difference is determined as the importance of the second background service.
[0113] In some possible implementations of the embodiments of the present application, the third determining submodule is specifically used to:
[0114] Determine the maximum value of the scheduling interval corresponding to the second background service according to the importance of the second background service and the maximum value of the delayed execution time range of the background service;
[0115] Determine a minimum value of a scheduling interval corresponding to the second background service according to the importance of the second background service and the minimum value of a delayed execution time range of the background service;
[0116] The dimension value of the second background service in the scheduling interval dimension is determined according to the importance of the second background service, the maximum value of the scheduling interval corresponding to the second background service, and the minimum value of the scheduling interval corresponding to the second background service.
[0117] In some possible implementations of the embodiments of the present application, the fifth determining submodule is specifically configured to:
[0118] The priority level corresponding to the product of the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension is used as the priority level of the second background service.
[0119] In some possible implementations of the embodiments of the present application, the background service scheduling device provided by the embodiments of the present application further includes:
[0120] a fourth determining module, configured to determine a first scheduling time interval corresponding to the current CPU occupancy rate according to a correspondence between the CPU occupancy rate and the background service scheduling time interval;
[0121] The fifth determining module is used to determine the first time for scheduling the background service next time according to the first scheduling time interval; when the first time is reached, the obtaining module 401 is triggered.
[0122] The background service scheduling device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0123] The background service scheduling device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0124] The background service scheduling device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the background service scheduling method embodiment are not described here.
[0125] Alternatively, if Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores programs or instructions that can be executed on the processor 501, and when the program or instructions are executed by the processor 501, the various steps of the background service scheduling method embodiment provided in the embodiment of the present application are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.
[0126] Figure 6 It is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
[0127] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, and a processor 610.
[0128] Those skilled in the art will appreciate that the electronic device 600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0129] Among them, processor 610 is used to: obtain the current central processing unit occupancy rate of the electronic device and parameter information of each background service in multiple background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range and the background service delayed execution time range; determine the priority of each background service according to the parameter information; determine the first number of background services that need to be scheduled corresponding to the central processing unit occupancy rate; determine the first background service that needs to be scheduled according to the priority and first number of each background service; and schedule the first background service.
[0130] In the embodiment of the present application, the priority of each background service is determined by the parameter information of the background service, and the first number of background services to be scheduled is determined by the CPU occupancy rate of the electronic device, and then the first background service to be scheduled is determined according to the priority of each background service and the determined first number, and then the first background service is scheduled. In this way, all background services are not scheduled at the same time, so that the background services occupy system resources more evenly, avoiding the phenomenon of sudden surge in system resource load and occupying system resources, and reducing the occupation of system resources.
[0131] In some possible implementations of the embodiments of the present application, the processor 610 is specifically configured to:
[0132] For the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0133] The priority corresponding to the importance is used as the priority corresponding to the second background service.
[0134] In some possible implementations of the embodiments of the present application, the processor 610 is specifically configured to:
[0135] For the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0136] Determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range;
[0137] The priority corresponding to the dimension value is used as the priority corresponding to the second background service.
[0138] In some possible implementations of the embodiments of the present application, the processor 610 is specifically configured to:
[0139] For the second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services;
[0140] Determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the background service delayed execution time range, and the minimum value of the background service delayed execution time range;
[0141] The priority of the second background service is determined according to the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension.
[0142] In some possible implementations of the embodiments of the present application, the processor 610 is specifically configured to:
[0143] Determine a first difference between the priority of the application process corresponding to the second background service and a minimum value of the application process priority range;
[0144] Determine a second difference between a maximum value of the application process priority range and a minimum value of the application process priority range;
[0145] The ratio of the first difference to the second difference is determined as the importance of the second background service.
[0146] In some possible implementations of the embodiments of the present application, the processor 610 is specifically configured to:
[0147] Determine the maximum value of the scheduling interval corresponding to the second background service according to the importance of the second background service and the maximum value of the delayed execution time range of the background service;
[0148] Determine a minimum value of a scheduling interval corresponding to the second background service according to the importance of the second background service and the minimum value of a delayed execution time range of the background service;
[0149] The dimension value of the second background service in the scheduling interval dimension is determined according to the importance of the second background service, the maximum value of the scheduling interval corresponding to the second background service, and the minimum value of the scheduling interval corresponding to the second background service.
[0150] In some possible implementations of the embodiments of the present application, the fifth determining submodule is specifically configured to:
[0151] The priority level corresponding to the product of the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension is used as the priority level of the second background service.
[0152] In some possible implementations of the embodiments of the present application, the processor 610 is further configured to:
[0153] Determine a first scheduling time interval corresponding to the current CPU occupancy rate according to a correspondence between the CPU occupancy rate and the background service scheduling time interval;
[0154] According to the first scheduling time interval, a first time for scheduling the background service next time is determined; when the first time is reached, the background service is continuously scheduled.
[0155] It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0156] The memory 609 can be used to store software programs and various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 609 may include a volatile memory or a non-volatile memory, or the memory 609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0157] The processor 610 may include one or more processing units; optionally, the processor 610 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 610.
[0158] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the background service scheduling method embodiment provided in the embodiment of the present application are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0159] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, and examples of computer-readable storage media include non-transitory computer-readable media, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0160] An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the background service scheduling method embodiment provided in the embodiment of the present application, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0161] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0162] The embodiment of the present application also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the background service scheduling method embodiment provided in the embodiment of the present application, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0163] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0164] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0165] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A background service scheduling method, characterized in that: The method comprises: Obtaining the current CPU occupancy rate of the electronic device and parameter information of each background service in a plurality of background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range, and the background service delayed execution time range; Determine the priority of each background service according to the parameter information; Determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate; Determine a first background service that needs to be scheduled according to the priority of each background service and the first number; The first background service is scheduled.
2. The method according to claim 1, characterized in that Determining the priority of each background service according to the parameter information includes: For a second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; The priority corresponding to the importance is used as the priority corresponding to the second background service.
3. The method according to claim 1, characterized in that Determining the priority of each background service according to the parameter information includes: For a second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; Determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the delayed execution time range of the background service, and the minimum value of the delayed execution time range of the background service; The priority corresponding to the dimension value is used as the priority corresponding to the second background service.
4. The method according to claim 1, characterized in that Determining the priority of each background service according to the parameter information includes: For a second background service, determining the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, wherein the second background service is any one of the multiple background services; Determine a dimension value of the second background service in the scheduling interval dimension according to the importance of the second background service, the maximum value of the delayed execution time range of the background service, and the minimum value of the delayed execution time range of the background service; The priority of the second background service is determined according to the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension.
5. The method according to any one of claims 2 to 4, characterized in that: The determining, for the second background service, the importance of the second background service according to the priority of the application process corresponding to the second background service, the maximum value of the application process priority range, and the minimum value of the application process priority range, includes: Determine a first difference between the priority of the application process corresponding to the second background service and a minimum value of the application process priority range; Determine a second difference between a maximum value of the application process priority range and a minimum value of the application process priority range; The ratio of the first difference to the second difference is determined as the importance of the second background service.
6. The method according to claim 3 or 4, characterized in that: The determining, according to the importance of the second background service, the current time, the maximum value of the delayed execution time range of the background service, and the minimum value of the delayed execution time range of the background service, the dimension value of the second background service in the scheduling interval dimension includes: Determining a maximum value of a scheduling interval corresponding to the second background service according to the importance of the second background service and a maximum value of a delayed execution time range of the background service; Determining a minimum value of a scheduling interval corresponding to the second background service according to the importance of the second background service and a minimum value of a delayed execution time range of the background service; The dimension value of the second background service in the scheduling interval dimension is determined according to the importance of the second background service, the maximum value of the scheduling interval corresponding to the second background service, and the minimum value of the scheduling interval corresponding to the second background service.
7. The method according to claim 4, characterized in that The determining the priority of the second background service according to the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension includes: The priority corresponding to the product of the importance of the second background service and the dimension value of the second background service in the scheduling interval dimension is used as the priority of the second background service.
8. The method according to claim 1, characterized in that The method further comprises: Determine a first scheduling time interval corresponding to the current CPU occupancy rate according to a correspondence between the CPU occupancy rate and the background service scheduling time interval; Determining a first time for next scheduling of a background service according to the first scheduling time interval; When the first time is reached, the step of obtaining the current CPU occupancy rate of the electronic device and parameter information of each background service in the plurality of background services is performed.
9. A background service scheduling device, characterized in that: The device comprises: An acquisition module, used to acquire the current CPU occupancy rate of the electronic device and parameter information of multiple background services, wherein the parameter information includes at least one of the following: the priority of the application process corresponding to each background service, the application process priority range and the background service delay execution time range; A first determination module, used to determine the priority of each background service according to the parameter information; A second determining module, configured to determine a first number of background services that need to be scheduled corresponding to the CPU occupancy rate; A third determining module, configured to determine a first background service that needs to be scheduled according to the priority of each background service and the first quantity; A scheduling module is used to schedule the first background service.
10. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the background service scheduling method as described in any one of claims 1-8 are implemented.
11. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the background service scheduling method according to any one of claims 1 to 8 are implemented.