Frequency adjustment method and device, equipment and storage medium

By determining the first passing time of the task in real time and adjusting the frequency of the processing component, the CPU load monitoring lagging problem in existing technology has been solved, and the timely response of real -time requirements and the optimization of system performance of the task is realized.

CN119336501APending Publication Date: 2025-01-21GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411404278.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

The prior art has lag when monitoring CPU load and cannot respond to the real-time requirements of the current task in a timely manner.

Method used

During the task running process, the first elapsed time elapsed during the task sampling process is determined in real time based on the number of sampled points of the current frame and the preset sampling interval, and the frequency of the processing component is adjusted in real time based on this time.

Benefits of technology

A real -time needs of timely responding to tasks have been realized, systematic lag is reduced, systematic performance and resource use have been optimized, and the efficiency of processing components is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336501A_ABST
    Figure CN119336501A_ABST
Patent Text Reader

Abstract

The invention discloses a frequency adjustment method and device, equipment and a storage medium, and the method comprises the steps: determining first elapsed time elapsed in a task sampling process based on the number of sampled points in a current frame and a preset sampling interval in a task operation process; adjusting a frequency of the processing component based on the first elapsed time; wherein the processing component is a component for processing the task. Therefore, the first elapsed time elapsed by the task in the sampling process is determined in real time based on the sampled point number of the current frame and the preset sampling interval, and then the frequency of the processing component is adjusted in real time according to the first elapsed time, so that the real-time demand of the task can be responded in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to control technology, and in particular to a frequency adjustment method, device, equipment and storage medium. Background Art

[0002] Currently, the CPU load is analyzed within a certain time window (e.g., tens of milliseconds) by monitoring the historical usage data of the central processing unit (CPU). If the load increases, the frequency is increased; if the load decreases, the frequency is decreased. This frequency adjustment method based on historical data has a certain lag and cannot respond to the real-time needs of the current task in a timely manner. Summary of the invention

[0003] The present application provides a frequency adjustment method, apparatus, device and storage medium.

[0004] The technical solution of this application is implemented as follows:

[0005] In a first aspect, a frequency adjustment method is provided, the method comprising:

[0006] During the task execution, based on the number of sampled points in the current frame and the preset sampling interval, determining a first elapsed time during the task sampling process;

[0007] Based on the first elapsed time, the frequency of a processing component is adjusted; wherein the processing component is a component that processes the task.

[0008] In a second aspect, a frequency adjustment device is provided, the device comprising:

[0009] A processing unit, used for determining a first elapsed time during the task sampling process based on the number of sampled points in a current frame and a preset sampling interval during the task running process;

[0010] The processing unit is further configured to adjust the frequency of a processing component based on the first elapsed time; wherein the processing component is a component that processes the task.

[0011] According to a third aspect, an electronic device is provided, comprising: a processor and a memory configured to store a computer program that can be run on the processor, wherein the processor is configured to execute the steps of the method of the first aspect when running the computer program.

[0012] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, wherein the computer program implements the steps of the method according to the first aspect when executed by a processor.

[0013] According to a fifth aspect, a computer program product is provided, comprising a computer program, wherein the computer program implements the steps of the method according to the first aspect when executed by a processor.

[0014] The present application provides a frequency adjustment method, device, equipment and storage medium, the method comprising: during the task running process, based on the number of sampled points in the current frame and the preset sampling interval, determining the first elapsed time during the task sampling process; based on the first elapsed time, adjusting the frequency of the processing component; wherein the processing component is a component for processing the task. In this way, based on the number of sampled points in the current frame and the preset sampling interval, the first elapsed time during the task sampling process is determined in real time, and then the frequency of the processing component is adjusted in real time according to the first elapsed time, so that the real-time needs of the task can be responded to in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 1 ;

[0016] Figure 2 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 2 ;

[0017] Figure 3 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 3 ;

[0018] Figure 4 A schematic diagram of a scenario in which a task can be completed within the current frame as exemplified in an embodiment of the present application;

[0019] Figure 5 A schematic diagram of a scenario in which a task has not been completed in the current frame and needs to be completed in the next frame as exemplified in an embodiment of the present application;

[0020] Figure 6 This is a schematic diagram of the structure of the frequency adjustment device in the embodiment of the present application;

[0021] Figure 7 It is a schematic diagram of the structure of the electronic device in the embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this embodiment and are not intended to limit this application.

[0024] In the following description, references to “some embodiments,” “this embodiment,” “this embodiment,” and examples, etc., describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.

[0025] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the present embodiment described here can be implemented in an order other than that illustrated or described here.

[0026] In this embodiment, the term "and / or" is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, object A and / or object B may represent three situations: object A exists alone, object A and object B exist at the same time, and object B exists alone.

[0027] The present application provides a frequency adjustment method. Figure 1 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 1 ,like Figure 1 As shown, the frequency adjustment method includes the following steps:

[0028] S101: During the task execution, based on the number of sampled points in the current frame and a preset sampling interval, a first elapsed time during the task sampling process is determined.

[0029] In the embodiment of the present application, the type of task is a real-time task. A real-time task can be understood as being able to process the sampled data immediately when the sampled data of the task is obtained, and to generate results within a strict time limit to meet the high requirements for real-time performance.

[0030] Exemplarily, the task may be a task related to user experience, such as a frame drawing task.

[0031] In the embodiment of the present application, in order to ensure that each task has a clear time limit in the corresponding frame, the total number of sampling points in a frame is pre-set to a fixed value, and the sampling interval is set to determine the time limit for the execution of the task in a frame. For example, if the total number of sampling points in a frame is set to 8 and the sampling interval is set to 2ms, the time limit for the execution of the task in a frame is 16ms.

[0032] In the embodiment of the present application, during the task execution, based on the current number of sampled points in the current frame and the preset sampling interval, the first elapsed time that elapsed in the current frame during the task sampling process is determined.

[0033] In some embodiments, determining the first elapsed time during the task sampling process based on the number of sampled points in the current frame and a preset sampling interval includes: subtracting one from the number of sampled points in the current frame, and then multiplying it by the preset sampling interval to obtain the first elapsed time.

[0034] For example, if the number of sampled points in the current frame is 2 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (2-1)*2=2ms. If the number of sampled points in the current frame is 3 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (3-1)*2=4ms. If the number of sampled points in the current frame is 4 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (4-1)*2=6ms. And so on, no further description is given.

[0035] S102: Adjust the frequency of a processing component based on a first elapsed time; wherein the processing component is a component that processes a task.

[0036] In the embodiment of the present application, the processing component is a component that processes tasks. Exemplarily, the processing component may be a central processing unit (CPU), a graphics processing unit (GPU), a neural processing unit (NPU), a memory controller, and a system bus.

[0037] In the embodiment of the present application, as the first elapsed time increases, the frequency of the corresponding processing component will also increase.

[0038] In the embodiment of the present application, a pre-established relationship expression between elapsed time and frequency is obtained, and the first elapsed time is substituted into the relationship expression between elapsed time and frequency to obtain the frequency corresponding to the first elapsed time. Here, the relationship expression can be a linear relationship expression or a non-linear relationship expression.

[0039] In some embodiments, the method further comprises: when it is detected that the task ends running in the current frame, reducing the first elapsed time to zero and reducing the frequency of the processing component to zero.

[0040] In an embodiment of the present application, when it is detected that a task switches from being running to ending running within the current frame, that is, the valid data sampling of the task is ended, the first elapsed time of the task in the sampling immediately drops to zero, and the frequency of the component processing the task immediately drops to zero.

[0041] In some embodiments, the method further comprises: when it is detected that the task has not started to run in the current frame, the first elapsed time is maintained at zero and the frequency of the processing component is maintained at zero.

[0042] In an embodiment of the present application, when it is detected that a task has not started running in the current frame, that is, valid data sampling of the task has not started, the first elapsed time of the task in sampling is maintained at zero, and the frequency of the component processing the task is zero.

[0043] In the embodiment of the present application, based on the number of sampled points in the current frame and the preset sampling interval, the first elapsed time of the task during the sampling process is determined in real time, and then the frequency of the processing component is adjusted in real time (or dynamically) according to the first elapsed time, so that the real-time needs of the task can be responded to in a timely manner and the system lag can be reduced. At the same time, the purpose of optimizing system performance and resource utilization is also achieved.

[0044] In the embodiment of the present application, the frequency adjustment of the dynamic processing component can avoid resource waste and improve the efficiency of the processing component. In addition, while ensuring performance, energy efficiency management is optimized to extend the battery life of the device.

[0045] In the embodiments of the present application, for tasks related to user experience, the disclosed control method of the present application can reduce the jamming or lag caused by task delays and provide a smoother user experience.

[0046] In addition, the frequency adjustment method of the present application also supports frequency adjustment when multiple tasks are executed in parallel, ensuring that the frequency adjustment between tasks works in coordination.

[0047] The present application also provides a frequency adjustment method. Figure 2 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 2 ,like Figure 2 As shown, the frequency adjustment method includes the following steps:

[0048] S201: During the task execution, based on the number of sampled points in the current frame and a preset sampling interval, a first elapsed time during the task sampling process is determined.

[0049] In the embodiment of the present application, the type of task is a real-time task. Exemplarily, the task may be a task related to user experience, such as a frame drawing task.

[0050] In the embodiment of the present application, in order to ensure that each task has a clear time limit in the corresponding frame, the total number of sampling points in a frame is pre-set to a fixed value, and the sampling interval is set to determine the time limit for the execution of the task in a frame. For example, if the total number of sampling points in a frame is set to 8 and the sampling interval is set to 2ms, the time limit for the execution of the task in a frame is 16ms.

[0051] In the embodiment of the present application, during the task execution, based on the current number of sampled points in the current frame and the preset sampling interval, the first elapsed time that elapsed in the current frame during the task sampling process is determined.

[0052] In some embodiments, determining the first elapsed time during the task sampling process based on the number of sampled points in the current frame and a preset sampling interval includes: subtracting one from the number of sampled points in the current frame, and then multiplying it by the preset sampling interval to obtain the first elapsed time.

[0053] For example, if the number of sampled points in the current frame is 2 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (2-1)*2=2ms. If the number of sampled points in the current frame is 3 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (3-1)*2=4ms. If the number of sampled points in the current frame is 4 and the preset sampling interval is 2ms, then during the task sampling process, the first elapsed time in the current frame is (4-1)*2=6ms. And so on, no further description is given.

[0054] S202: Processing the first elapsed time based on a preset control algorithm to determine a corresponding control amount.

[0055] In an embodiment of the present application, the preset control algorithm may be a proportional (P) control algorithm, a proportional integral (PI) control algorithm, a proportional integral differential (PID) control algorithm, a fuzzy control algorithm, and a neural network control algorithm.

[0056] In some embodiments, the processing of the first elapsed time based on a preset control algorithm to determine a corresponding control amount includes at least one of the following:

[0057] determining a first control amount based on a proportionality coefficient and the first elapsed time;

[0058] determining a second control amount based on an integral coefficient and the first elapsed time;

[0059] determining a third control amount based on the differential coefficient and the first elapsed time;

[0060] The control amount includes at least one of the following: the first control amount, the second control amount, and the third control amount.

[0061] Exemplarily, if the preset control algorithm is a P control algorithm, a first control quantity is determined based on a proportional coefficient and the first elapsed time, and the first control quantity is the control quantity corresponding to the P control algorithm. If the preset control algorithm is a PI control algorithm, a first control quantity is determined based on a proportional coefficient and the first elapsed time; and a second control quantity is determined based on an integral coefficient and the first elapsed time; the control quantity corresponding to the PI control algorithm is obtained by adding the first control quantity to the second control quantity. If the preset control algorithm is a PID control algorithm, a first control quantity is determined based on a proportional coefficient and the first elapsed time; and a second control quantity is determined based on an integral coefficient and the first elapsed time; and a third control quantity is determined based on a differential coefficient and the first elapsed time; the control quantity corresponding to the PID control algorithm is obtained by adding the first control quantity, the second control quantity, and the third control quantity.

[0062] S203: Adjust the frequency of the processing component based on the control amount.

[0063] In the embodiment of the present application, a pre-established relational expression between a preset control amount and a preset frequency is obtained, and the control amount is substituted into the relational expression between the preset control amount and the preset frequency to obtain a corresponding frequency. Here, the relational expression can be a linear relational expression or a nonlinear relational expression.

[0064] In some embodiments, the method further comprises: when it is detected that the task ends running in the current frame, reducing the first elapsed time to zero and reducing the frequency of the processing component to zero.

[0065] In an embodiment of the present application, when it is detected that a task switches from being running to ending running within the current frame, that is, the valid data sampling of the task is ended, the first elapsed time of the task in the sampling immediately drops to zero, and the frequency of the component processing the task immediately drops to zero.

[0066] In some embodiments, the method further comprises: when it is detected that the task has not started to run in the current frame, the first elapsed time is maintained at zero and the frequency of the processing component is maintained at zero.

[0067] In an embodiment of the present application, when it is detected that a task has not started running in the current frame, that is, valid data sampling of the task has not started, the first elapsed time of the task in sampling is maintained at zero, and the frequency of the component processing the task is zero.

[0068] In an embodiment of the present application, based on the number of sampled points in the current frame and the preset sampling interval, the first elapsed time of the task during the sampling process is determined in real time. Further, the control amount corresponding to the first elapsed time is determined based on the preset control algorithm. Finally, the frequency of the processing component is adjusted in real time based on the control amount, so that the real-time needs of the task can be responded to in a timely manner.

[0069] The present application also provides a frequency adjustment method. Figure 3 The flow chart of the frequency adjustment method in the embodiment of the present application is as follows Figure 3 ,like Figure 3 As shown, the frequency adjustment method includes the following steps:

[0070] S301: During the task execution, based on the number of sampled points in the current frame and a preset sampling interval, a first elapsed time during the task sampling process is determined.

[0071] In the embodiment of the present application, the type of task is a real-time task. Exemplarily, the task may be a task related to user experience, such as a frame drawing task.

[0072] In the embodiment of the present application, in order to ensure that each task has a clear time limit in the corresponding frame, the total number of sampling points in a frame is pre-set to a fixed value, and the sampling interval is set to determine the time limit for the execution of the task in a frame. For example, if the total number of sampling points in a frame is set to 8 and the sampling interval is set to 2ms, the time limit for the execution of the task in a frame is 16ms.

[0073] In the embodiment of the present application, during the task execution, based on the current number of sampled points in the current frame and the preset sampling interval, the first elapsed time that elapsed in the current frame during the task sampling process is determined.

[0074] In some embodiments, determining the first elapsed time during the task sampling process based on the number of sampled points in the current frame and a preset sampling interval includes: subtracting one from the number of sampled points in the current frame, and then multiplying it by the preset sampling interval to obtain the first elapsed time.

[0075] S302: When the current frame ends and the task is not ended, determine a second elapsed time during the task sampling process based on the number of sampled points in the next frame and a preset sampling interval.

[0076] In the embodiment of the present application, a fixed total number of sampling points is set in one frame. When it is detected that the task has not ended after sampling at the last sampling point of the current frame, sampling is continued in the next frame, and then, based on the number of sampled points of the task in the next frame and the preset sampling interval, the second elapsed time in the task sampling in the next frame is determined.

[0077] In some embodiments, based on the number of sampled points in the next frame and the preset sampling interval, determining the second elapsed time during the task sampling process includes: multiplying the number of sampled points in the next frame by the preset sampling interval to obtain the second elapsed time during the task sampling process.

[0078] For example, if the number of sampled points in the next frame is 1 and the preset sampling interval is 2ms, the second elapsed time in the next frame during the task sampling process is 1*2=2ms. If the number of sampled points in the next frame is 2 and the preset sampling interval is 2ms, the second elapsed time in the next frame during the task sampling process is 2*2=4ms. If the number of sampled points in the next frame is 3 and the preset sampling interval is 2ms, the second elapsed time in the next frame during the task sampling process is 3*2=6ms. And so on, no further description is given.

[0079] S303: Adjust the frequency of the processing component based on the first elapsed time and the second elapsed time; wherein the processing component is a component that processes the task.

[0080] In the embodiment of the present application, a third elapsed time is obtained by adding the first elapsed time to the second elapsed time, and the frequency of the processing component is adjusted based on the third elapsed time.

[0081] In the embodiment of the present application, a pre-established relational expression between the elapsed time and the frequency is obtained, and the third elapsed time is substituted into the relational expression between the elapsed time and the frequency to obtain the frequency corresponding to the third elapsed time. Here, the relational expression can be a linear relational expression or a non-linear relational expression.

[0082] In some embodiments, the method further comprises: when it is detected that the task ends running in the current frame, reducing the first elapsed time to zero and reducing the frequency of the processing component to zero.

[0083] In an embodiment of the present application, when it is detected that a task switches from being running to ending running within the current frame, that is, the valid data sampling of the task is ended, the first elapsed time of the task in the sampling immediately drops to zero, and the frequency of the component processing the task immediately drops to zero.

[0084] In some embodiments, the method further comprises: when it is detected that the task has not started to run in the current frame, the first elapsed time is maintained at zero and the frequency of the processing component is maintained at zero.

[0085] In an embodiment of the present application, when it is detected that a task has not started running in the current frame, that is, valid data sampling of the task has not started, the first elapsed time of the task in sampling is maintained at zero, and the frequency of the component processing the task is zero.

[0086] In the embodiment of the present application, the third elapsed time of the task during its execution is determined in real time, and then the frequency of the processing component is adjusted in real time according to the third elapsed time, so that the real-time needs of the task can be responded to in a timely manner.

[0087] Based on the above embodiments, the embodiments of the present application illustrate a scenario, that is, a scenario in which the task can be completed within the current frame. Figure 4 This is a schematic diagram of a scenario in which a task can be completed within the current frame as exemplified in an embodiment of the present application, such as Figure 4 The figure shows a frame drawing task as an example, and the processing component is explained by taking the CPU as an example. Specifically:

[0088] Vsync0 to Vsync1 is the first frame, Vsync1 to Vsync2 is the second frame, and Vsync2 to Vsync3 is the third frame.

[0089] Draw0 is the first task, which is completed in the first frame; Draw1 is the second task, which is completed in the second frame; and Draw2 is the third task, which is completed in the third frame.

[0090] Sample index: 7 fixed sampling points are set in one frame.

[0091] In the first frame, the Draw0 task starts running at the first sampling point, and the first elapsed time during the sampling process of the first sampling point is set to 0.1ms. The sampling interval is set to 2.6ms. When the Draw0 task runs at the second sampling point, the first elapsed time during the sampling process is 2.6ms. When the Draw0 task runs at the third sampling point, the first elapsed time during the sampling process is 5.2ms. When the Draw0 task runs at the fourth sampling point, the first elapsed time during the sampling process is 7.8ms. When the Draw0 task runs at the fifth sampling point, the first elapsed time during the sampling process is 10.4ms.

[0092] At the sixth sampling point and subsequent sampling points, it is detected that the Draw0 task has finished running, then the first elapsed time corresponding to the sixth sampling point and subsequent sampling points is reduced to 0, and the CPU frequency is reduced to 0.

[0093] Here, the first elapsed time is processed using the P control algorithm to obtain the control amount, which may be represented by the following formula: control amount = first elapsed time * P, where P is a proportionality coefficient.

[0094] Based on the control amount, the frequency of the CPU is determined. The formula may be: frequency = per_map (control amount), where per_map() is a function for converting the control amount into frequency.

[0095] Based on this, when the first elapsed time is 0.1, the control amount is 0.2. When the first elapsed time is 2.6, the control amount is 0.4. When the first elapsed time is 5.2, the control amount is 0.6. When the first elapsed time is 7.8, the control amount is 0.8. When the first elapsed time is 10.4, the control amount is 0.8.

[0096] In the second frame, the Draw1 task starts running at the first sampling point, and the first elapsed time during the sampling process of the first sampling point is set to 0.1ms. The sampling interval is set to 2.6ms. When the Draw1 task runs at the second sampling point, the first elapsed time during the sampling process is 2.6ms.

[0097] At the third sampling point and subsequent sampling points, it is detected that the Draw1 task has finished running, then the first elapsed time corresponding to the third sampling point and subsequent sampling points is reduced to 0, and the CPU frequency is reduced to 0.

[0098] When the first elapsed time is 0.1, the control amount is 0.2. When the first elapsed time is 2.6, the control amount is 0.4.

[0099] In the third frame, at the first sampling point and the second sampling point, the Draw2 task has not started running, and the first elapsed time corresponding to the first sampling point and the second sampling point respectively remains at 0, and the CPU frequency remains at 0. The Draw2 task starts running at the third sampling point, and at this time, the first elapsed time elapsed in sampling in the third frame is 5.2. When the Draw2 task runs at the fourth sampling point, the first elapsed time elapsed in the sampling process is 7.8ms. When the Draw2 task runs at the fifth sampling point, the first elapsed time elapsed in the sampling process is 10.4ms. It should be noted that although the first two sampling points are invalid sampling points for the Draw2 task, they are also elapsed times in sampling in this frame, i.e., the third frame. Therefore, the first elapsed time corresponding to the Draw2 task at the third sampling point is 5.2.

[0100] At the sixth sampling point and subsequent sampling points, it is detected that the Draw1 task has finished running, then the first elapsed time corresponding to the sixth sampling point and subsequent sampling points is reduced to 0, and the CPU frequency is reduced to 0.

[0101] When the first elapsed time is 5.2, the control amount is 0.4. When the first elapsed time is 7.8, the control amount is 0.8. When the first elapsed time is 10.4, the control amount is 0.8.

[0102] Based on the above embodiment, the embodiment of the present application illustrates another scenario, that is, a scenario in which a task has not been completed in the current frame and needs to be completed in the next frame. Figure 5 A schematic diagram of a scenario in which a task has not been completed in the current frame and needs to be completed in the next frame is shown in the example of an embodiment of the present application. Figure 5 The figure shows a frame drawing task as an example, and the processing component is explained by taking the CPU as an example. Specifically:

[0103] Vsync0 to Vsync1 is the first frame, Vsync1 to Vsync2 is the second frame, and Vsync2 to Vsync3 is the third frame.

[0104] Draw0 is the first task, which is completed in the first frame; Draw1 is the second task, which is completed in the second frame; and Draw2 is the third task, which is completed in the third frame.

[0105] Sample index: 7 fixed sampling points are set in one frame.

[0106] In the first frame, the Draw0 task starts running at the first sampling point, and the first elapsed time during the sampling process of the first sampling point is set to 0.1ms. The sampling interval is set to 2.6ms. When the Draw0 task runs at the second sampling point, the first elapsed time during the sampling process is 2.6ms. When the Draw0 task runs at the third sampling point, the first elapsed time during the sampling process is 5.2ms. When the Draw0 task runs at the fourth sampling point, the first elapsed time during the sampling process is 7.8ms. When the Draw0 task runs at the fifth sampling point, the first elapsed time during the sampling process is 10.4ms. When the Draw0 task runs at the sixth sampling point, the first elapsed time during the sampling process is 13ms. When the Draw0 task runs at the seventh sampling point, the first elapsed time during the sampling process is 15.6ms.

[0107] In the second frame, the Draw0 task continues to run. At the first sampling point, the second elapsed time in the second frame is 0. Adding the previous first elapsed time of 15.6 and the sampling interval of 2.6, the total elapsed time, that is, the third elapsed time, is 18.2. When running at the second sampling point, the third elapsed time is 20.8.

[0108] Here, the first elapsed time is processed by the P control algorithm to obtain the control amount. The formula can be: control amount = first elapsed time * P, where P is the proportional coefficient. Based on the control amount, the CPU frequency is determined. The formula can be: frequency = per_map (control amount), where per_map() is a function for converting the control amount into frequency. It should be noted that the frequency adjustment process using the P control algorithm will ensure the smoothness of the frequency change and avoid the impact of frequent frequency fluctuations on system stability.

[0109] Based on this, when the first elapsed time is 0.1, the control amount is 0.2. When the first elapsed time is 2.6, the control amount is 0.4. When the first elapsed time is 5.2, the control amount is 0.6. When the first elapsed time is 7.8, the control amount is 0.8. When the first elapsed time is 10.4, the control amount is 0.8. When the first elapsed time is 13, the control amount is 1.0. When the first elapsed time is 15.6, the control amount is 1.0. When the first elapsed time is 18.2, the control amount is 1.0. When the first elapsed time is 20.8, the control amount is 1.0. Among them, the higher the height of the line of CPU frequency, the higher the frequency.

[0110] Then, in the second frame, the Draw1 task starts running at the third sampling point, and the sampling interval is set to 2.6ms. The first elapsed time during the sampling process is 5.2ms. When the Draw1 task runs at the fourth sampling point, the first elapsed time during the sampling process is 7.8ms. It should be noted that although the first two sampling points are invalid sampling points for the Draw1 task, they are also elapsed time in the sampling in this frame, i.e., the second frame. Therefore, the first elapsed time corresponding to the Draw1 task at the third sampling point is 5.2.

[0111] At the fifth sampling point and subsequent sampling points, it is detected that the Draw1 task has finished running, then the first elapsed time corresponding to the fifth sampling point and subsequent sampling points is reduced to 0, and the CPU frequency is reduced to 0.

[0112] When the first elapsed time is 5.2, the control amount is 0.6. When the first elapsed time is 7.8, the control amount is 0.8.

[0113] In the third frame, at the first sampling point and the second sampling point, the Draw2 task has not started running, and the first elapsed time corresponding to the first sampling point and the second sampling point respectively remains at 0, and the CPU frequency remains at 0. The Draw2 task starts running at the third sampling point, and at this time, the first elapsed time elapsed in sampling in the third frame is 5.2. When the Draw2 task runs at the fourth sampling point, the first elapsed time elapsed in the sampling process is 7.8ms. When the Draw2 task runs at the fifth sampling point, the first elapsed time elapsed in the sampling process is 10.4ms. It should be noted that although the first two sampling points are invalid sampling points for the Draw2 task, they are also elapsed times in sampling in this frame, i.e., the third frame. Therefore, the first elapsed time corresponding to the Draw2 task at the third sampling point is 5.2.

[0114] At the sixth sampling point and subsequent sampling points, it is detected that the Draw1 task has finished running, then the first elapsed time corresponding to the sixth sampling point and subsequent sampling points is reduced to 0, and the CPU frequency is reduced to 0.

[0115] When the first elapsed time is 5.2, the control amount is 0.4. When the first elapsed time is 7.8, the control amount is 0.8. When the first elapsed time is 10.4, the control amount is 0.8.

[0116] In order to implement the method of the embodiment of the present application, based on the same inventive concept, the embodiment of the present application further provides a frequency adjustment device, Figure 6 FIG. 1 is a schematic diagram of the structure of the frequency adjustment device in the embodiment of the present application. Figure 6 As shown, the frequency adjustment device 60 includes:

[0117] The processing unit 601 is used to determine a first elapsed time during the task sampling process based on the number of sampled points in the current frame and a preset sampling interval during the task running process;

[0118] The processing unit 601 is further configured to adjust the frequency of a processing component based on the first elapsed time; wherein the processing component is a component that processes the task.

[0119] In an embodiment of the present application, based on the number of sampled points in the current frame and the preset sampling interval, the first elapsed time of the task during the sampling process is determined in real time, and then the frequency of the processing component is adjusted in real time according to the first elapsed time, so as to respond to the real-time needs of the task in a timely manner.

[0120] In some embodiments, the processing unit 601 is also used to determine the second elapsed time elapsed during the task sampling process based on the number of sampled points in the next frame and the preset sampling interval when the current frame ends and the task has not ended; and determine the frequency of the processing component based on the first elapsed time and the second elapsed time.

[0121] In some embodiments, the processing unit 601 is further configured to reduce the first elapsed time to zero and the frequency of the processing component to zero when detecting that the task has finished running in the current frame.

[0122] In some embodiments, the processing unit 601 is further configured to detect that, when the task has not started to run in the current frame, the first elapsed time is maintained at zero and the frequency of the processing component is maintained at zero.

[0123] In some embodiments, the processing unit 601 is further used to process the first elapsed time based on a preset control algorithm to determine a corresponding control amount; and determine the frequency of the processing component based on the control amount.

[0124] In some embodiments, the processing unit 601 is also used to include at least one of the following: determining a first control quantity based on a proportional coefficient and the first elapsed time; determining a second control quantity based on an integral coefficient and the first elapsed time; determining a third control quantity based on a differential coefficient and the first elapsed time; the control quantity includes at least one of the following: the first control quantity, the second control quantity and the third control quantity.

[0125] In some embodiments, the processing unit 601 is further configured to subtract one from the number of sampled points of the task in the current frame, and then multiply the result by the preset sampling interval to obtain the first elapsed time.

[0126] The present application also provides another electronic device, Figure 7 Schematic diagram of the structure of the electronic device in the embodiment of the present application. Figure 7 As shown, the electronic device 70 includes: a processor 701 and a memory 702 configured to store a computer program that can be run on the processor;

[0127] The processor 701 is configured to execute the method steps in the aforementioned embodiment when running a computer program.

[0128] Of course, in practical applications, Figure 7As shown, the components in the electronic device 70 are coupled together via a bus system 703. It is understood that the bus system 703 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 703 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus system 703.

[0129] In practical applications, the processor may be at least one of an application-specific integrated circuit (ASIC), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a controller, a microcontroller, and a microprocessor. It is understandable that for different devices, the electronic device used to implement the functions of the processor may also be other, and the embodiments of the present application do not specifically limit this.

[0130] The above-mentioned memory can be a volatile memory (volatile memory), such as a random access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD); or a combination of the above-mentioned types of memory, and provide instructions and data to the processor.

[0131] In an exemplary embodiment, the present application also provides a computer-readable storage medium for storing a computer program.

[0132] Optionally, the computer-readable storage medium can be applied to any one of the methods in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the processor in each method in the embodiments of the present application. For the sake of brevity, they are not repeated here.

[0133] Illustratively, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by a processor of an electronic device to complete the steps of any of the aforementioned methods.

[0134] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0135] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0136] In addition, all functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art may understand that all or part of the steps of implementing the above method embodiments may be completed by hardware related to program instructions, and the above program may be stored in a computer-readable storage medium, which, when executed, executes the steps of the above method embodiments; and the above storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.

[0137] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0138] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0139] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.

[0140] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A frequency adjustment method, characterized in that: The method comprises: During the task execution, based on the number of sampled points in the current frame and the preset sampling interval, determining a first elapsed time during the task sampling process; Based on the first elapsed time, the frequency of a processing component is adjusted; wherein the processing component is a component that processes the task.

2. The method according to claim 1, characterized in that The method further comprises: When the current frame ends and the task is not ended, determining a second elapsed time elapsed during the task sampling process based on the number of sampled points in the next frame and the preset sampling interval; The adjusting the frequency of the processing component based on the first elapsed time includes: Based on the first elapsed time and the second elapsed time, a frequency of the processing component is determined.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: When it is detected that the task has finished running in the current frame, the first elapsed time is reduced to zero, and the frequency of the processing component is reduced to zero.

4. The method according to claim 1 or 2, characterized in that: The method further comprises: When it is detected that the task has not started to run in the current frame, the first elapsed time is maintained at zero, and the frequency of the processing component is maintained at zero.

5. The method according to claim 1 or 2, characterized in that: The adjusting the frequency of the processing component based on the first elapsed time includes: Processing the first elapsed time based on a preset control algorithm to determine a corresponding control amount; Based on the control amount, a frequency of the processing component is determined.

6. The method according to claim 5, characterized in that The processing of the first elapsed time based on a preset control algorithm to determine a corresponding control amount includes at least one of the following: determining a first control amount based on a proportionality coefficient and the first elapsed time; determining a second control amount based on an integral coefficient and the first elapsed time; determining a third control amount based on the differential coefficient and the first elapsed time; The control amount includes at least one of the following: the first control amount, the second control amount, and the third control amount.

7. The method according to claim 1 or 2, characterized in that: The determining, based on the number of sampled points in the current frame and a preset sampling interval, a first elapsed time during the task sampling process comprises: The first elapsed time is obtained by subtracting one from the number of sampled points in the current frame and then multiplying the result by the preset sampling interval.

8. A frequency adjustment device, characterized in that: The device comprises: A processing unit, used for determining a first elapsed time during the task sampling process based on the number of sampled points in a current frame and a preset sampling interval during the task running process; The processing unit is further configured to adjust the frequency of a processing component based on the first elapsed time; wherein the processing component is a component that processes the task.

9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory configured to store a computer program capable of running on the processor, Wherein, the processor is configured to execute the steps of the method according to any one of claims 1 to 7 when running the computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.