CN116774809A - Method and device for adjusting frequency, electronic equipment and readable storage medium - Google Patents

Method and device for adjusting frequency, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN116774809A
CN116774809A CN202310358482.7A CN202310358482A CN116774809A CN 116774809 A CN116774809 A CN 116774809A CN 202310358482 A CN202310358482 A CN 202310358482A CN 116774809 A CN116774809 A CN 116774809A
Authority
CN
China
Prior art keywords
frame
thread
frequency value
rendering
processor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310358482.7A
Other languages
Chinese (zh)
Inventor
姜仕双
刘文方
李耀宗
梁绪庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Publication of CN116774809A publication Critical patent/CN116774809A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power
    • G06F1/3203Power management, i.e. event-based initiation of a power-saving mode
    • G06F1/3234Power saving characterised by the action undertaken
    • G06F1/329Power saving characterised by the action undertaken by task scheduling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/16Constructional details or arrangements
    • G06F1/20Cooling means
    • G06F1/206Cooling means comprising thermal management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Power Sources (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

The application discloses a method and a device for adjusting frequency, electronic equipment and a readable storage medium, and belongs to the technical field of terminals. Comprising the following steps: and drawing the first image frame, wherein the operating frequency of the processor of the electronic device is a first frequency value when the first image frame is drawn. If the first image frame is a blank frame, determining a second frequency value, wherein the second frequency value is smaller than the first frequency value, and the blank frame is an image frame without outputting image data. The operating frequency of the processor is adjusted to a second frequency value. The application can better balance performance and power consumption by identifying the blank frame and adjusting the operating frequency of the processor to a lower frequency point, thereby avoiding the problems of excessive performance and power consumption waste of the electronic equipment.

Description

Method and device for adjusting frequency, electronic equipment and readable storage medium
The present application claims priority from chinese patent application filed at month 17 of 2022 to the national intellectual property agency, application number 202210267048.3, application name "method, apparatus, electronic device, and readable storage medium for frequency prediction", the entire contents of which are incorporated herein by reference.
Technical Field
The present application relates to the field of terminal technologies, and in particular, to a method and apparatus for adjusting frequency, an electronic device, and a readable storage medium.
Background
Electronic devices such as cell phones, tablet computers, etc. present significant challenges in terms of how to balance performance and power consumption, particularly in terms of running video, navigation, electronic books, music, shopping, and gaming applications.
In the related art, in order to balance performance and power consumption, a frequency limiting strategy oriented to an application program or a scene level is generally adopted to solve the problem of resource allocation, however, the problems of excessive performance and waste of power consumption are often encountered, so that heat generation and endurance of the electronic device are reduced due to high energy consumption.
Disclosure of Invention
The application provides a method and a device for adjusting frequency, electronic equipment and a readable storage medium, which can solve the problems of heat generation and endurance degradation of the electronic equipment caused by high energy consumption due to incapacity of balancing performance and power consumption in related technologies. The technical scheme is as follows:
in a first aspect, a method for adjusting a frequency is provided, and the method is applied to an electronic device, and includes:
Drawing a first image frame, wherein the operating frequency of a processor of the electronic device is a first frequency value when the first image frame is drawn;
if the first image frame is a blank frame, determining a second frequency value, wherein the second frequency value is smaller than the first frequency value, and the blank frame is an image frame without outputting image data;
and adjusting the operating frequency of the processor to the second frequency value.
Therefore, in the frame drawing process, the running frequency value of the processor is adjusted to a lower frequency point by identifying the blank frame, so that the performance and the power consumption can be better balanced, and the problems of excessive performance and power consumption waste caused by unnecessary frequency lifting of a user interaction scene are solved.
As an example of the present application, the determining the second frequency value if the first image frame is a blank frame includes:
if the first image frame is the blank frame, acquiring a target frequency value, wherein the target frequency value is smaller than the maximum frequency value of the processor in a frame drawing task of the last non-blank frame;
adjusting a maximum frequency value of the processor to the target frequency value;
and determining the second frequency value according to the adjusted maximum frequency value of the processor.
Therefore, by identifying the blank frame and adjusting the maximum frequency value of the processor to a lower frequency point so as to limit the running frequency of the processor, the performance and the power consumption can be balanced well, and the problems of excessive performance and power consumption waste caused by unnecessary frequency boosting of a user interaction scene are solved.
As an example of the present application, if the first image frame is a blank frame, before determining the second frequency value, the method further includes:
and in the process of drawing the first image frame, determining whether the first image frame is the blank frame according to the running conditions of a plurality of key threads, wherein each key thread in the plurality of key threads is used for executing a frame drawing task.
In this way, by monitoring the running conditions of the plurality of key threads, whether the first image frame is a blank frame can be effectively identified, so that whether the maximum frequency value of the processor is to be adjusted or not is conveniently determined.
As one example of the present application, the plurality of critical threads includes a main thread and a rendering thread; in the process of drawing the first image frame, determining whether the first image frame is the blank frame according to the running conditions of a plurality of key threads comprises the following steps:
In the process of drawing the first image frame, if the main thread does not call the rendering thread, determining that the first image frame is the blank frame; or alternatively, the process may be performed,
and in the process of drawing the first image frame, if the rendering thread does not draw the rendering data after the main thread calls the rendering thread, determining that the first image frame is the blank frame.
Therefore, through monitoring results of the running conditions of the main thread and the rendering thread, whether the first image frame is a blank frame or not is judged, and the effectiveness of identification can be ensured.
As one example of the present application, the electronic device includes a first frame module and a message center processing module; the method further comprises the steps of:
in the process of drawing the first image frame, if a first plug-in code in the first frame module is called in the operation process of the main thread, the first frame module sends first pile point information to the message center processing module, wherein the first pile point information is used for indicating the plug-in position of the first plug-in code in the first frame module;
and after the message center processing module receives the first pile point information, determining that the rendering thread is not called by the main thread.
In this way, by inserting the stub point in the first frame module, the electronic device can identify the blank frame with the UI read no RENDER THREAD by using the first plug-in code, thereby implementing the identification of the blank frame.
As one example of the present application, the electronic device includes a second frame module and a message center processing module; the method further comprises the steps of:
in the process of drawing the first image frame, if a second plug-in code in the second frame module is called in the running process of the rendering thread after the rendering thread is called by the main thread, the second frame module sends second stake point information to the message center processing module, wherein the second stake point information is used for indicating the plug-in position of the second plug-in code in the second frame module;
and after the message center processing module receives the second pile point information, determining that the rendering thread does not draw the rendering data.
Therefore, by inserting the stub point in the second frame module, the electronic device can identify the blank frame with the UI THREAD and RENDER THREAD and without the queue buffer by using the second plug-in code, so that the identification of the blank frame is realized.
As one example of the application, the processor includes a plurality of cores, each core of the plurality of cores having a different target frequency value;
And if the first image frame is the blank frame, acquiring a target frequency value, including:
if the first image frame is the blank frame, respectively acquiring a target frequency value corresponding to each target core in the plurality of cores, wherein the target core is a core running a key thread for executing a frame drawing task in the plurality of cores;
the adjusting the maximum frequency value of the processor to the target frequency value includes:
and respectively adjusting the maximum frequency value of each target core to be the target frequency value corresponding to each target core.
In this way, when the processor includes a plurality of cores, the maximum frequency value of each target core running the critical thread is limited, so that the running power consumption of each core is reduced, and the problems of excessive performance and power consumption waste are effectively solved.
As an example of the present application, the method further comprises:
and under the condition that the first image frame is the blank frame, if the previous frame of the first image frame is a non-blank frame, canceling a timer timing function, wherein the timer timing function is used for increasing the maximum frequency value of the processor under the condition that the timing reaches the preset duration after the frame drawing task of the previous frame is ended.
Therefore, by canceling the timer BOOST mechanism, the judgment result of overtime of the drawing frame in the drawing time window corresponding to the blank frame is not generated, and the problem of automatic frequency raising is not caused.
As an example of the present application, the method further comprises:
and reducing the operation priority of at least one key thread in the plurality of key threads in the case that the first image frame is the blank frame.
In this way, the execution priority of some or all of the plurality of critical threads is reduced, so that other threads can use resources preferentially, and the completion efficiency of other functions can be improved.
In a second aspect, an apparatus for adjusting a frequency is provided, configured in an electronic device, and the apparatus includes:
the device comprises a drawing module, a first image frame generation module and a second image frame generation module, wherein the drawing module is used for drawing a first image frame, and the running frequency of a processor of the electronic equipment is a first frequency value when the first image frame is drawn;
the resource control module is used for determining a second frequency value if the first image frame is a blank frame, wherein the second frequency value is smaller than the first frequency value, and the blank frame refers to an image frame which does not output image data;
The resource control module is further configured to adjust an operating frequency of the processor to the second frequency value.
As an example of the present application, the resource control module is configured to:
if the first image frame is the blank frame, acquiring a target frequency value, wherein the target frequency value is smaller than the maximum frequency value of the processor in a frame drawing task of the last non-blank frame;
adjusting a maximum frequency value of the processor to the target frequency value;
and determining the second frequency value according to the adjusted maximum frequency value of the processor.
As an example of the present application, the apparatus further comprises a frame model for:
and in the process of drawing the first image frame, determining whether the first image frame is the blank frame according to the running conditions of a plurality of key threads, wherein each key thread in the plurality of key threads is used for executing a frame drawing task.
As one example of the present application, the plurality of critical threads includes a main thread and a rendering thread; the frame model is used for:
in the process of drawing the first image frame, if the main thread does not call the rendering thread, determining that the first image frame is the blank frame; or alternatively, the process may be performed,
And in the process of drawing the first image frame, if the rendering thread does not draw the rendering data after the main thread calls the rendering thread, determining that the first image frame is the blank frame.
As one example of the present application, the electronic device includes a first frame module and a message center processing module;
in the process of drawing the first image frame, if a first plug-in code in the first frame module is called in the operation process of the main thread, the first frame module sends first pile point information to the message center processing module, wherein the first pile point information is used for indicating the plug-in position of the first plug-in code in the first frame module;
and after the message center processing module receives the first pile point information, determining that the rendering thread is not called by the main thread.
As one example of the present application, the electronic device includes a second frame module and a message center processing module;
in the process of drawing the first image frame, if a second plug-in code in the second frame module is called in the running process of the rendering thread after the rendering thread is called by the main thread, the second frame module sends second stake point information to the message center processing module, wherein the second stake point information is used for indicating the plug-in position of the second plug-in code in the second frame module;
And after the message center processing module receives the second pile point information, determining that the rendering thread does not draw the rendering data.
As one example of the application, the processor includes a plurality of cores, each core of the plurality of cores having a different target frequency value; the resource control module is used for:
if the first image frame is the blank frame, respectively acquiring a target frequency value corresponding to each target core in the plurality of cores, wherein the target core is a core running a key thread for executing a frame drawing task in the plurality of cores;
the adjusting the maximum frequency value of the processor to the target frequency value includes:
and respectively adjusting the maximum frequency value of each target core to be the target frequency value corresponding to each target core.
As an example of the present application, the resource control module is further configured to:
and under the condition that the first image frame is the blank frame, if the previous frame of the first image frame is a non-blank frame, canceling a timer timing function, wherein the timer timing function is used for increasing the maximum frequency value of the processor under the condition that the timing reaches the preset duration after the frame drawing task of the previous frame is ended.
As an example of the present application, the resource control module is further configured to:
and reducing the operation priority of at least one key thread in the plurality of key threads in the case that the first image frame is the blank frame.
In a third aspect, an electronic device is provided, where the electronic device includes a processor and a memory, where the memory is configured to store a program for supporting the electronic device to perform the method provided in the first aspect, and store data related to implementing the method in the first aspect. The processor is configured to execute a program stored in the memory. The electronic device may further comprise a communication bus for establishing a connection between the processor and the memory.
In a fourth aspect, there is provided a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the method of the first aspect described above.
In a fifth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of the first aspect described above.
The technical effects obtained by the second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and are not described in detail herein.
Drawings
FIG. 1 is a diagram illustrating a thread distribution involved in a frame drawing task according to an exemplary embodiment;
FIG. 2 is a schematic diagram illustrating a frame timeout in a frame-drawing task, according to an example embodiment;
FIG. 3 is a schematic diagram of one frame type shown in accordance with an exemplary embodiment;
FIG. 4 is a schematic diagram illustrating a mechanism for starting a timer within a drawing time window of a blank frame, according to an example embodiment;
FIG. 5 is a schematic diagram of an electronic device, according to an example embodiment;
FIG. 6 is a schematic diagram of a software architecture of an electronic device, according to an example embodiment;
FIG. 7 is a schematic diagram of an application scenario illustrated in accordance with an exemplary embodiment;
FIG. 8 is a flow chart of a method for adjusting frequency according to an exemplary embodiment;
FIG. 9 is a schematic diagram illustrating a drawing cycle according to an example embodiment;
FIG. 10 is a schematic diagram illustrating a status of a painting frame, according to an example embodiment;
FIG. 11 is a schematic diagram of a blank frame shown in accordance with an exemplary embodiment;
FIG. 12 is a schematic diagram of a blank frame shown according to another exemplary embodiment;
FIG. 13 is a schematic diagram illustrating a comparison of a blank frame before and after processing according to an example embodiment;
FIG. 14 is a flow chart of a method of adjusting frequency according to another exemplary embodiment;
FIG. 15 is a flow chart of a method of adjusting frequency according to another exemplary embodiment;
FIG. 16 is a flow chart of a method of adjusting frequency according to another exemplary embodiment;
fig. 17 is a schematic diagram showing a structure of an apparatus for adjusting a frequency according to an exemplary embodiment.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
It should be understood that references to "a plurality" in this disclosure refer to two or more. In the description of the present application, "/" means or, unless otherwise indicated, for example, A/B may represent A or B; "and/or" herein is merely an association relationship describing an association object, and means that three relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist together, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of the present application, the words "first", "second", etc. are used to distinguish the same item or similar items having substantially the same function and function. It will be appreciated by those of skill in the art that the words "first," "second," and the like do not limit the amount and order of execution, and that the words "first," "second," and the like do not necessarily differ.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
Applications typically implement multiple key threads in conjunction when rendering an image frame. Illustratively, the plurality of critical THREADs primarily includes a main THREAD (e.g., UI THREAD) and a rendering THREAD (RENDER THREAD). Further, the plurality of critical threads may also include one or more other threads that cooperate with the main thread and the rendering thread for frame drawing.
In one example, a main thread is first run during frame drawing, and the main thread is mainly responsible for processing events related to User graphics (UI). The main line Cheng Laqi is a rendering thread, which is responsible for performing frame drawing operations to obtain rendering data, for example, referring to fig. 1, after each frame of data, an application program performs frame drawing on the rendering data through the main thread, the rendering thread and other auxiliary threads. After the rendering data is obtained, the rendering thread stores the obtained rendering data into a buffer area queue (BufferQueue) through the queue buffer, and notifies SF (surfaceflinger) processes to read the rendering data from the BufferQueue so as to conveniently display the rendering data on a display screen, thereby completing the display of the image frames. Wherein, queue buffer is a function for filling rendering data into the buffer queue; the SF process is used to display rendering data on a display screen in coordination with hardware, including, by way of example and not limitation, a graphics processor (graphics processing unit, GPU).
The frame drawing process described above generally refers to drawing of non-blank frames. In some cases, the image frame to be drawn may be a blank frame, which refers to an image frame without drawing a picture or an image frame without outputting image data. According to the running conditions of a plurality of key threads in the frame drawing process, blank frames can be divided into two types: one is that the main THREAD runs but does not pull up the rendering THREAD, i.e., there is a UI read none RENDER THREAD during frame drawing; the other is that the main THREAD runs and pulls up the rendering THREAD, but the rendering THREAD does not execute frame drawing operation after running, namely, in the frame drawing process, the UI THREAD and RENDER THREAD exist, but no queue buffer exists. In a soft-brushing scheme, the application may draw blank frames at intervals, i.e., every other non-blank frame there is a blank frame; it is also possible to continuously draw a plurality of blank frames, for example, after continuously drawing a plurality of non-blank frames, and continuously drawing a plurality of blank frames, for example, referring to fig. 2, a plurality of image frames after the third image frame are blank frames, where the image frame of the last picture is displayed after the screen is refreshed.
The reason for the existence of a blank frame is that, in general, the electronic device itself has a screen refresh rate. By way of example, a screen refresh rate may refer to the number of times a screen refreshes a display image per second, such as 120 frames/second, i.e., the screen may be refreshed 120 times in 1 second. When the screen is refreshed, a signal is generally sent to the system, and after receiving the signal, the system sends a synchronization signal (such as a Vsync signal) to an application running in the foreground to trigger the application to perform a frame drawing operation once, where it is easy to understand that the frame drawing frequency (abbreviated as frame rate) of the application is the same as the screen refresh rate of the electronic device. However, in some scenarios, in order to avoid high power consumption, the frame rate of the application program may be adjusted to a low frame rate, and in order to keep the frame drawing operation consistent with the screen refreshing operation so as to avoid the phenomenon of tearing the screen, the application program may not draw some image frames, which are blank frames.
In one possible scenario, the low frame rate of the application may be adjusted by the system, such as 120 frames/second screen refresh rate, and the system may adjust the frame rate of the application to 60 frames/second (i.e., software refresh rate of about 16.6 milliseconds). In one example, after the screen generates a Vsync signal, the system sends an image frame to display, and the application draws an image frame based on the Vsync signal and stores it in a BufferQueue. After the screen generates the next Vsync signal, the system sends the next image frame to display, but the application does not draw the image frame. After the screen generates the Vsync signal, the system displays the next image frame and stores it in the BufferQueue, and the application draws an image frame based on the Vsync signal. That is, the application may draw at intervals, such as drawing a frame, then blanking a frame, then drawing a frame, and then blanking a frame, i.e., the blanking frames occur at intervals.
In another possible scenario, the low frame rate of the application may also be optimized by the application itself, i.e. the application itself is provided with a scheme for frame drawing, e.g. it may be pre-configured in the application by the developer of the application, in one example the application may draw a plurality of non-blank frames continuously over a period of time and a plurality of blank frames continuously over a subsequent period of time.
In some scenarios, the drawing time may exceed the expected (e.g., exceed 16.6 ms) due to some sudden load such as input/output (IO) operation, complex drawing logic, etc., such as shown in fig. 3, fig. 3 is a schematic diagram illustrating a frame timeout phenomenon according to an exemplary embodiment. As an example, for this scenario, in order to ensure timely drawing of an image frame, avoid frame loss, and the like, it is desirable to increase the frequency of the processor before the next frame data arrives, so as to increase the task execution speed of the processor, and thus it is desirable to complete the frame drawing task of the current image frame before the frame drawing task of the next image frame begins. For this purpose, an automatic frequency boosting function may be provided in the electronic device. Specifically, referring to fig. 4, a BOOST mechanism (for example, a timer BOOST mechanism) may be set in the electronic device, after detecting the end-of-drawing identifier of an image frame, if the next end-of-drawing identifier is not detected after a certain period of time (for example, 16.6 ms) passes, it is considered that the next end-of-drawing identifier may be caused by timeout of the drawing task, and at this time, an automatic frequency boosting operation may be performed, that is, the frequency of the processor may be increased.
In one possible case, if the incoming image frame is a blank frame, the blank frame does not need to be drawn, so that the blank frame has no drawing end identifier, and the electronic device automatically performs the frequency raising operation after a certain period of time (for example, 16.6 milliseconds) passes due to the existence of the BOOST mechanism, that is, the frequency of the processor is raised in a drawing time window after the blank frame arrives, which can cause a problem of wasting power consumption. For example, if the first frame is a non-blank frame, the second frame is a blank frame, and the third frame is a non-blank frame, then after the drawing end identifier of the first frame is detected, the second frame is a blank frame, so that the drawing end identifier is not detected, the electronic device can confirm that the drawing is overtime, and frequency boosting is automatically performed, thereby further causing resource waste.
For this case, the type of each image frame may be identified during the frame drawing process, so that the frequency supply policy of the processor is set according to the resources required for each image frame to achieve a balance of performance and power consumption.
The method provided by the embodiment of the application can be executed by the electronic equipment, and the electronic equipment can be provided with application programs such as video, navigation, electronic book, music, shopping and games. By way of example and not limitation, the electronic device may be, but is not limited to, a mobile motion camera (GoPro), a digital camera, a tablet, a desktop, a laptop, a handheld computer, a notebook, an in-vehicle device, an ultra-mobile personal computer (UMPC), a netbook, a cellular telephone, a personal digital assistant (personal digital assistant, PDA), an augmented reality (augmented reality, AR), a Virtual Reality (VR) device, a cell phone, and the like, as embodiments of the application are not limited in this respect.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the application. Referring to fig. 5, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, a user identification module (subscriber identification module, SIM) card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the application, electronic device 100 may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a GPU, an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller may be a neural hub and a command center of the electronic device 100, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces, such as may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a universal serial bus (universal serial bus, USB) interface, among others.
It should be understood that the interfacing relationship between the modules illustrated in the embodiments of the present application is only illustrative, and is not meant to limit the structure of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also employ different interfacing manners in the above embodiments, or a combination of multiple interfacing manners.
The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel. The display panel may employ a liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (flex), a mini, a Micro-OLED, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), or the like. In some embodiments, the electronic device 100 may include 1 or N display screens 194, N being an integer greater than 1.
The electronic device 100 may implement photographing functions through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
The ISP is used to process data fed back by the camera 193. For example, when photographing, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electric signal, and the camera photosensitive element transmits the electric signal to the ISP for processing and is converted into an image visible to naked eyes. ISP can also optimize the noise, brightness and skin color of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in the camera 193.
The camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device, CCD) or a Complementary Metal Oxide Semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then transferred to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, or the like format. In some embodiments, electronic device 100 may include 1 or N cameras 193, N being an integer greater than 1.
The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. For example, when the electronic device 100 selects a frequency bin, the digital signal processor is used to fourier transform the frequency bin energy, and so on.
Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record video in a variety of encoding formats, such as: dynamic picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
The NPU is a neural-network (NN) computing processor, and can rapidly process input information by referencing a biological neural network structure, such as referencing a transmission mode between human brain neurons, and can also continuously perform self-learning. Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, for example: image recognition, face recognition, speech recognition, text understanding, etc.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. Such as storing files of music, video, etc. in an external memory card.
The internal memory 121 may be used to store computer-executable program code that includes instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data (e.g., audio data, phonebook, etc.) created by the electronic device 100 during use, and so forth. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The electronic device 100 may implement audio functions such as music playing, recording, etc. through the audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, and application processor, etc.
The software system of the electronic device 100 will be described next.
The software system of the electronic device 100 may employ a layered architecture, an event driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the application, an Android (Android) system with a layered architecture is taken as an example, and a software system of the electronic device 100 is illustrated.
Fig. 6 is a block diagram of a software system of the electronic device 100 according to an embodiment of the present application. Referring to fig. 6, the hierarchical architecture divides the software into several layers, each with a clear role and division of work. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into five layers, from top to bottom, an Application (APP) layer, an application FrameWork layer (AFW), a An Zhuoyun row (Android run) and system layer, a kernel layer and a hardware layer, respectively.
The application layer may include a series of application packages. As shown in fig. 6, the application package may include an application such as an electronic book, navigation, video, online shopping, game, instant messaging, camera, gallery, call, etc.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions. As shown in FIG. 6, the application framework layer may include a frame model, a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
The frame model is used for being called by an application program to draw and display the image frames. As an example of the present application, the frame model includes a first frame module, a second frame module, a third frame module, and an SF module. As an example of the present application, the electronic device may add a frame type monitoring function to the first frame module and the second frame module, respectively, so that a blank frame is identified through the function. In the case where the image frame is identified as a blank frame, the frame model notifies the underlying message center processing module for further processing by the message center processing module. In one example, the first frame module may also be referred to as a chord module and the second frame module may also be referred to as an Hwui module. The third frame module is a module for performing operations related to frame drawing, and the number of the third frame module may be one or more, and for example, in a case where an image frame to be drawn is not a blank frame, the application program may call the third frame module to implement frame drawing. The SF module is operated in the SF process, and the SF module is used for coordinating with hardware (such as GPU) to display rendering data drawn by the application program on the display screen.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like. The content provider is used to store and retrieve data, which may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc., and make such data accessible to the application. The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to construct a display interface for an application, which may be comprised of one or more views, such as a view that includes displaying a text notification icon, a view that includes displaying text, and a view that includes displaying a picture. The telephony manager is used to provide communication functions of the electronic device 100, such as management of call status (including on, off, etc.). The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like. The notification manager allows the application to display notification information in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. For example, a notification manager is used to inform that the download is complete, a message alert, etc. The notification manager may also be a notification that appears in the system top status bar in the form of a chart or a scroll bar text, such as a notification of a background running application. The notification manager may also be a notification that appears on the screen in the form of a dialog window, such as a text message being prompted in a status bar, a notification sound being emitted, the electronic device vibrating, a flashing indicator light, etc.
Android run time includes a core library and virtual machines. Android run time is responsible for scheduling and management of the Android system. The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android. The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The system library may include a plurality of functional modules, such as: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (e.g., openGL ES), 2D graphics engine (e.g., SGL), proxy module, etc. The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications. Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio and video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc. The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like. The 2D graphics engine is a drawing engine for 2D drawing. The proxy module is used for receiving the message (such as the first message) issued by the frame model and transmitting the received message to the underlying message center processing module for processing, and it is easy to understand that the proxy module is a bridge for interaction between the frame model and the underlying layer, and plays a role in transparent transmission of the message.
The kernel layer is a layer between hardware and software. As an example of the present application, the kernel layer at least includes a frame rate adjustment module, a key thread identification module, a message center processing module, a load calculation module, and a resource control module. The frame rate adjustment module may be used to calculate the frame rate at which the application is running, or may adjust the frame rate to be synchronized with the screen refresh rate. The key thread identification module is used for identifying the key thread. The message center processing module is used for determining that the current image frame is a blank frame under the condition that a first message sent by the frame model of the application program framework layer is received, wherein the first message is used for indicating that the current image frame is the blank frame, and the message center processing module is used for notifying the load calculating module under the condition that the current image frame is determined to be the blank frame. The load calculation module is used for calculating the load condition of a plurality of key threads in the processor in one frame drawing task, determining the frequency maximum value (freq max) of the processor in the next frame drawing task to be proper according to the calculated load, and sending the calculated information to the resource control module. The resource control module is used for adjusting the operating frequency of the processor according to the information (namely the frequency maximum value) determined by the load calculation module, namely the resource control module has the frequency modulation function. Optionally, the resource control module may also be used to adjust the priority of multiple critical threads, cancel a timer BOOST mechanism, and so on. Further, the resource control module may be further configured to select a core, for example, to which core each critical thread is scheduled to run according to the running condition of each critical thread.
As an example of the present application, the hardware layer includes, but is not limited to, a central processing unit (Central Processing Unit, CPU), GPU, double rate synchronous dynamic random access memory (DDR SDRAM, double Data Rate Synchronous Dynamic Random Access Memory).
Before introducing the method for adjusting the frequency provided by the embodiment of the application, the application scene related to the embodiment of the application is briefly introduced. Referring to fig. 7, fig. 7 is a schematic diagram of an application scenario according to an exemplary embodiment, assuming that the electronic device is a mobile phone. The application scene specifically comprises the following steps:
the mobile phone runs an instant messaging application, which is marked as APP1. User a chat with user B through APP1 in the handset. In one example, referring to fig. 7 (a), after receiving the message a of the user B, the mobile phone displays the message a in the chat interface of APP1, and after reading the message a, the user a inputs a message B, which is a message to say to the user B, in the message input box 71 of the chat interface. In response to the user's operation, the handset inputs a message b in a message input box 71. After the user a inputs, the sending option 72 is triggered, and in response to the triggering operation of the sending option 72 by the user a, the mobile phone sends the message B input by the user a to the user B, and displays the message B in the chat interface of the mobile phone, as shown in (B) of fig. 7.
It should be noted that the above application scenario is only exemplary, and in addition, the method provided in the embodiment of the present application may also be applied to other scenarios of operation of the electronic device, for example, other scenarios include, but are not limited to, shopping, video, live broadcast, electronic book, and sliding list.
Next, a method for adjusting a frequency provided by the embodiment of the present application will be described. Referring to fig. 8, fig. 8 is a flowchart illustrating a method for adjusting a frequency according to an exemplary embodiment. By way of example and not limitation, the method may be applied to the electronic device shown in fig. 5, and the method may include some or all of the following:
step 801: the load of a plurality of critical threads on the processor during one painting period in the historical painting task is determined.
The plurality of critical threads refers to threads for performing a framing task among a plurality of threads on which an application depends. As previously described, the plurality of critical THREADs may include a main THREAD (UI THREAD), a rendering THREAD (RENDER THREAD), and one or more other THREADs that cooperate with the main THREAD and the rendering THREAD for frame drawing. For ease of description and understanding, in some examples, other threads may be denoted as thread a.
The painting frame period may be a duration between a rendering thread end time of the first painting frame task and a rendering thread end time of the second painting frame task. Wherein the first and second frame drawing tasks are any two adjacent frame drawing tasks for drawing non-blank frames. For example, referring to fig. 9, assuming that the first frame drawing task is in the period of the Vsync1 signal and the second frame drawing task is in the period of the Vsync3 signal, the frame drawing periods are as noted in fig. 9.
It should be noted that, there may be a blank frame between two non-blank frames, that is, there may be a blank frame rendering thread between the rendering thread of the first drawing frame task and the rendering thread of the second drawing frame task, but since the processing time for the blank frame is very short, the processing time for the blank frame is almost negligible when determining the drawing frame period.
In one example, after a user clicks on a video application, the electronic device launches the video application, which plays a short video after it is launched. In this process, the video application performs frame drawing through multiple key threads. From the foregoing, it will be appreciated that the video application first runs a main thread, rendering the thread through main thread Cheng Laqi to perform frame drawing, and that the main thread may pull up the rendering thread by executing the TRAVERSAL event, i.e., the TRAVERSAL event, for invoking the rendering thread, by way of example and not limitation.
Wherein, the drawing of each image frame corresponds to a one-time frame drawing task, the historical drawing task refers to a one-time frame drawing task before the current moment, and in one example, the historical drawing task may refer to a frame drawing task of a last non-blank frame.
In a drawing frame period, drawing of a non-blank frame is mainly completed by cooperation of a main thread and a rendering thread after the non-blank frame arrives. In the implementation, the application program runs the main thread first, and after the main thread runs for a period of time, the rendering thread is pulled up, and applies for a buffer, for example, the buffer may be BufferQueue, and performs drawing operation on an image frame to obtain rendering data. The rendering thread stores the rendering data into the BufferQueue for the SF process to read the relevant information. It follows that the drawing of one non-blank frame, as shown in fig. 1, mainly involves the main thread and the rendering thread. When drawing of an image frame is completed, an end mark is stored in the queue buffer, that is, a queue buffer end point exists.
Because the logic point relatively close to the user interaction is the rendering thread in the process of drawing the frame, after the rendering thread is finished executing, the SF process can be informed to read the rendering data corresponding to the current image frame and then displayed on the interface, so that the drawing frame period can be set from the end point of the rendering thread of the previous drawing frame task to the end point of the rendering thread of the current drawing frame task. Alternatively, referring to fig. 9, the rendering thread has a queue buffer, and the drawing frame period may be from one queue buffer end point to the next adjacent queue buffer end point.
In one example, the execution timing of step 801 is the detection of the queue buffer end point of the last image frame. That is, in order to be able to determine the resources required for the drawing task for the next image frame, when the electronic device detects the queue buffer end point for the last image frame, the load of multiple key threads on the processor during the drawing frame period of the last drawing task is calculated.
The load of the plurality of critical threads on the processor may refer to a sum of loads of each of the plurality of critical threads on the processor. In one example, the load of each critical thread on the processor may include the run length of each critical thread on the processor, in which case the load of the plurality of critical threads on the processor includes the sum of the run lengths of each critical thread on the processor.
For example, assuming that the plurality of critical threads includes a main thread, a rendering thread, and a thread a, the electronic device determines that the running duration of the main thread on the processor is t1, the running duration of the rendering thread on the processor is t2, and the running duration of the thread a on the processor is t3, the loads of the plurality of critical threads on the processor are t, where t=t1+t2+t3.
It should be noted that the foregoing description only uses the load of each critical thread on the processor as an example, and includes the running time of each critical thread on the processor. In another embodiment, the load may also include other resource information, which is not specifically limited by the embodiments of the present application.
In addition, as an example of the present application, the electronic device includes a plurality of cores, such as a plurality of cores including a small core (such as core 0), a middle core (such as core 1), and a large core (such as core 2). At this time, the scheduling situations of the plurality of critical threads on the processor may include the following situations:
in one possible scenario, multiple critical threads all run on the same core. At this point, the load of the plurality of critical threads on the processor may be determined in the manner described above, i.e., the sum of the loads of the respective critical threads on the processor may be determined.
In another possible scenario, different ones of the plurality of critical threads run on different cores, such as the main thread running on the large core (i.e., core 2), the rendering thread running on the middle core (i.e., core 1), and thread a running on the small core (i.e., core 0). At this time, when the loads of the plurality of critical threads on the processor are calculated, the loads of the respective critical threads of the plurality of critical threads on the cores on which the respective cores are located may be calculated, respectively. Illustratively, the load of the main thread on the big core, the load of the rendering thread on the middle core, and the load of thread a on the little core are calculated.
In one example, when K (K is greater than 1) critical threads are running on a core, then the load of the K critical threads on the core is the sum of the loads of the individual critical threads of the K critical threads on the core. For example, assuming that both the main thread and the rendering thread are scheduled onto the big core, the load of the main thread and the rendering thread on the big core is the sum of the load of the main thread on the big core and the load of the rendering thread on the big core.
In some embodiments, after detecting the end point of the last drawing task, a timer BOOST mechanism may also be started to solve the problem of the time-out of the drawing frame caused by sudden loads such as IO operations, complex drawing logic, etc. through the timer BOOST mechanism.
It should be noted that, the description is merely given by taking the timer BOOST mechanism to solve the problem of frame timeout, and in another embodiment, other BOOST mechanisms may be used to solve the problem of frame timeout, which is not limited in the embodiments of the present application.
Step 802: based on the determined load, a maximum frequency value of the processor in a frame-drawing task of the current image frame is determined.
In one example, the frame drawing task for the current image frame refers to one frame drawing task after the opportunity to count the load.
The frequency value of a processor refers to the frequency size of the processor when a plurality of critical threads are running on the processor. The maximum frequency value refers to an upper limit of the frequency values that the processor can reach when a plurality of critical threads run on the processor, that is, the operating frequency of the processor cannot exceed the maximum frequency value if the maximum frequency value is set.
In one example, a maximum frequency value of a processor in a frame-drawing task for a current image frame may be determined by querying a target relationship table based on the determined load. The target relation table is used for recording the corresponding relation between the load and the maximum frequency value. Illustratively, the target relationship table may be as shown in Table 1:
TABLE 1
Load(s) Maximum frequency value
Load 1 Freq max a
Load 2 Freq max b
Load 3 Freq max c
... ....
The electronic device includes a core, and determines that the load of the plurality of key threads running on the processor is load1 through the above process, and determines that the corresponding relationship value of load1 is Freq max a by querying the target relationship table, so that the maximum frequency value of the processor in the frame drawing task of the current image frame is Freq max a.
It should be noted that, the maximum frequency value of the processor in the frame drawing task of the current image frame may be greater than the maximum frequency value of the processor in the history frame drawing task, may be less than the maximum frequency value of the processor in the history frame drawing task, and may be equal to the maximum frequency value of the processor in the history frame drawing task.
In one example, if a plurality of cores are included in the electronic device, if a plurality of critical threads are respectively scheduled on the plurality of cores, a maximum frequency value corresponding to each core is determined according to a load of each critical thread running on the core on which the critical thread is located. Illustratively, assuming that the main thread runs on core 2 and the rendering thread runs on core 1, the load of the critical thread on core 2 is determined to be load2 by calculation and the load of the rendering thread on core 1 is load3. The electronic device determines that the relationship value corresponding to the load2 is Freq max b and the relationship value corresponding to the load3 is Freq max c through inquiring the target relationship table, so that the maximum frequency value corresponding to the core 2 in the frame drawing task of the current image frame is Freq max b and the maximum frequency value corresponding to the core 1 is Freq max c.
In one example, a maximum frequency value of a processor in a frame drawing task of a current image frame is determined by a load calculation module, and the load calculation module sends the maximum frequency value to a resource control module in the electronic device after determining the maximum frequency value, so that the resource control module adjusts an operating frequency of the processor according to a preset policy. The preset strategy can be set according to requirements, and the embodiment of the application is not limited to the preset strategy.
Step 803: and judging whether the current image frame is a blank frame or not.
Referring to fig. 10, as described above, since a blank frame may exist in addition to a non-blank frame in the process of drawing an image frame. So in order to balance performance and power consumption, in an embodiment of the application, the electronic device may also determine the type of current image frame during the rendering of one image frame. It will be appreciated that the type of current image frame includes either a blank frame or a non-blank frame, i.e., the current image frame may or may not be a blank frame.
The judgment of the blank frame mainly comprises the following two cases:
first case: in the drawing task, the main thread runs, and the rendering thread does not run.
For example, referring to fig. 11, if the application program only runs the main thread during the process of drawing the current image frame, but the main thread does not execute the TRAVERSAL event, it is indicated that the main thread will not call the rendering thread, that is, there will be no rendering thread executing the drawing process, and thus no rendering data will be generated, and in this case, it may be determined that the current image frame is a blank frame.
For this first case, to be able to identify this type of blank frame, a stake point, here denoted stake point 1, may be inserted into the chord in the frame model. A first instrumentation code is added at this instrumentation point 1, which is used to identify blank frames of the first type. The main function of the chord is to receive and process various update messages and callbacks of the application program, and to uniformly process the Vsync signals after arriving. For example, after detecting that the Vsync signal arrives, the chord graphic device executes some events related to the running of the main thread, monitors the callback result of the events during the execution of the events, and when the callback result of the events shows that the main thread does not execute the TRAVERSAL event, determines that the current image frame is a blank frame. If the current image frame is determined to be a blank frame, the chord graph sends a first message to a message center processing module of the kernel layer, wherein the first message comprises first pile point information for indicating the pile point 1, and therefore the message center processing module can determine that the current image frame is the blank frame.
That is, for a first type of blank frame, no TRAVERSAL event pile driving may be employed to identify such blank frame. In some embodiments, the first type of blank frame may be referred to as a blank frame NR.
Second case: in the drawing process of the blank frame, the main thread runs, the rendering thread runs, but no queue buffer exists, that is, no call of the function exists.
For example, referring to fig. 12, if the application runs a main thread during the process of drawing the current image frame, the main thread Cheng Laqi renders the thread, but the rendering thread does not execute the queue buffer. In general, a rendering thread will execute a draw () request to draw rendering data through the draw () request, and then call a queue buffer to store the rendering data in the buffer queue. Therefore, in one possible case, if the draw () request is not performed in the second frame module, it means that the subsequent queue buffer is not performed, so that the rendering data is not generated, in which case it can be determined that the current image frame is a blank frame.
For the second case, in order to be able to identify the blank frames of this type, a stake point, here denoted stake point 2, may be inserted into Hwui in the frame model. A second instrumentation code is added at this instrumentation point 2, which is used to identify blank frames of a second type. In an implementation, if the electronic device executes the second instrumentation code, the Hwui in the frame model sends a first message to the message center processing module of the kernel layer, where the first message includes second instrumentation point information for indicating the instrumentation point 2, so that the message center processing module can determine that the current image frame is a blank frame. The Hwui is used for executing a draw () request after the main line Cheng Laqi renders the thread to assist the rendering thread in executing the rendering process, and listening to the result of the draw () request, if the result of the draw () request is failure, it may be determined that the frame is blank.
That is, for the second type of blank frame, a pile-up request without draw () may be employed to identify such blank frame. In some embodiments, the second type of blank frame may be referred to as a blank frame NQ.
If the current image frame is not a blank frame, then the following step 804 is entered. Otherwise, if the current image frame is a blank frame, the following step 805 is entered.
Step 804: the next queue buffer end point is monitored.
If the next queue buffer end point is monitored, returning to step 801, otherwise, continuing to monitor the queue buffer end point. That is, if the current image frame is not a blank frame, it is monitored whether a new queue buffer end point is reached, if so, it is indicated that the one-time drawing task ends, and at this time, in order to determine the resource requirement of the next drawing task on the processor, the loads of a plurality of key threads on the processor in the drawing frame period of the current drawing task are determined. If the frame drawing task does not arrive, the frame drawing task is not finished, and monitoring is continued.
It will be appreciated that in the event that the current image frame is not a blank frame, the processor maximum frequency value of the electronic device is maintained at the maximum frequency value confirmed in step 802.
In addition, if the current image frame is not a blank frame, when the timing duration of the timer BOOST mechanism reaches the preset duration, the electronic device executes the frequency raising operation, that is, the running frequency of the processor is raised. That is, if the current image frame is not a blank frame, when the timing duration of the timer BOOST mechanism reaches the preset duration, the next queue buffer end point is not yet monitored, which may be caused by the drawing timeout, and the electronic device automatically performs the frequency raising operation.
Step 805: the maximum frequency value of the processor in the current drawing task is adjusted to the target frequency value.
As an example of the present application, the target frequency value is a fixed frequency value that is preset, typically a smaller frequency value, that is, the target frequency value is typically lower than the maximum frequency value of the set processor. In one embodiment, the target frequency value may be scaled in advance from an energy efficiency ratio curve of the system of the electronic device.
That is, if the current image frame is a blank frame, the maximum frequency value of the processor may be reduced to perform the frequency compression on the processor, for example, assuming that the maximum frequency value of the processor is adjusted to 2.2GHz in step 803, if it is determined that the current image is a blank frame during the drawing of the current image frame and the target frequency value is determined to be 1.2GHz in step 805, the electronic device adjusts the maximum frequency value of the processor from 2.2GHz to 1.2GHz again.
In one example, if the electronic device includes multiple cores, each core may correspond to one target frequency value, and the target frequency values corresponding to each core may be different. Illustratively, assuming that the plurality of cores includes a large core, a medium core, and a small core, the target frequency value corresponding to the large core may be 2GHz, the target frequency value corresponding to the medium core may be 1.8GHz, and the target frequency value corresponding to the small core may be 1.2GHz.
If multiple key threads are respectively scheduled to run on different cores, the maximum frequency value corresponding to each core can be redetermined according to the target frequency value corresponding to each core. For example, assuming that the plurality of critical threads includes a main thread, a rendering thread and a thread a, the main thread is scheduled to run on core 2, the rendering thread is scheduled to run on core 1, and the thread a is scheduled to run on core 0, when it is determined that the current image frame is a blank frame, it is determined that a maximum frequency value corresponding to core 2 is 2GHz, a maximum frequency value corresponding to core 1 is 1.8GHz, and a maximum frequency value corresponding to core 0 is 1.2GHz.
Referring to fig. 13, fig. 13 includes two types of blank frames, wherein the rendering thread does not perform all operations during the drawing of the second type of blank frame, which is indicated by a dotted line. In the case that the current image frame is identified as a blank frame, the electronic device adjusts the maximum frequency value of the processor to a target frequency value to depress the maximum frequency value of the processor. For example, assume that cores running critical threads in a processor include core 0 and core i, and that the electronic device depresses the maximum frequency value of core 0 and the maximum frequency value of core i, respectively. Thus, the operation power consumption of the electronic equipment can be reduced, and the purpose of saving the power consumption can be achieved. Wherein the synchronization signal in fig. 13 is provided by the electronic device in order to keep the frame rate of the application synchronized with the timing of the display screen refresh to avoid the problem of split screen display.
It should be noted that, since the electronic device determines that the current image frame is a blank frame during the frame drawing process, and after the queue buffer end point of the previous image frame of the current image frame, the electronic device further determines the maximum frequency value of the processor according to the load condition of the previous image frame, as shown in fig. 13, the maximum frequency value of the electronic device maintains the maximum frequency value of the processor determined according to the load condition of the previous image frame, that is, the maximum frequency value determined in step 802, for a period of time when the blank frame starts to be drawn, that is, before the blank frame is not identified. After the blank frame is identified, the maximum frequency value of the processor is reduced.
The above description is given taking the case where the target frequency value is a fixed value as an example. In some embodiments, the target frequency value for each core may also be determined from a predetermined range, e.g., may be dynamically selected from the predetermined range based on the energy efficiency ratio of the system. The preset range may be set according to requirements, and may be [1ghz,2ghz ] for example. In one embodiment, the target frequency value may be determined according to a maximum frequency value corresponding to a previous frame drawing task, for example, a frequency range in which the maximum frequency value corresponding to the previous frame drawing task is located may be determined, then a target value corresponding to the frequency range is determined, and the maximum frequency value corresponding to the previous frame drawing task is subtracted from the target value to obtain the target frequency value. In general, when the maximum frequency value corresponding to the previous frame drawing task is larger, the target value to be subtracted may be larger, and when the maximum frequency value corresponding to the previous frame drawing task is smaller, the target value to be subtracted may be smaller, so when the value in the frequency range is larger, the corresponding target value is also larger, otherwise, when the value in the frequency range is smaller, the corresponding target value is also smaller.
It should be further noted that, if there is a core that is not scheduled, or if there is a core that is not running a critical thread on a core, the maximum frequency value of the core may be adjusted to a default smaller value to further reduce the running power consumption.
In one example, step 805 is performed by the load calculation module and after determining the target frequency value for the processor, the target frequency value is sent to the resource control module so that the resource control module adjusts the operating frequency of the processor according to a preset policy based on the target frequency value.
Step 806: the timer resources are reclaimed.
That is, in the case where it is determined that the current image frame is a blank frame, the electronic device cancels the timer BOOST mechanism, where the timer BOOST mechanism may be started at the end of a frame drawing task. Therefore, by canceling the timer BOOST mechanism, the judgment result of overtime of the drawing frame in the drawing time window corresponding to the blank frame is not generated, and the problem of automatic frequency raising is not caused.
In one example, where it is determined that the current image frame is a blank frame, the priority of execution of the plurality of critical threads may also be reduced, such as by reducing the priority of the plurality of critical threads from yj to yi, which may be set dynamically according to a common task, such as 100-139, in one example where yj is 120, where the higher the value the lower the priority, so yi is a value greater than yj, which may be 130 by way of example and not limitation. In addition, the priority of the SF process, that is, the operation priority of other functional modules related to the frame drawing task, may be reduced.
In the above embodiment, the previous image frame of the current image frame is taken as an example to describe that the previous image frame is a non-blank frame, and in another embodiment, if the previous image frame of the current image frame is a blank frame, after reaching the drawing timing of the current image frame, it may be determined whether the current image frame is a blank frame in the drawing process. In one example, if the current image frame is a blank frame, a target frequency value may be determined, and the maximum frequency value of the processor may be adjusted to the target frequency value, where the target frequency value determined in the process may be dynamically determined, or may be a fixed frequency value that is set in advance. In another example, if the current image frame is a blank frame, the maximum frequency value of the processor may continue to be maintained, that is, the target frequency value may not need to be determined again, but rather the maximum frequency value corresponding to the last blank frame may be maintained.
In the embodiment of the application, in the frame drawing process, the maximum frequency value of the processor is adjusted to a lower frequency point by identifying the blank frame, so that the performance and the power consumption can be better balanced, and the problems of excessive performance and power consumption waste caused by unnecessary frequency lifting of a user interaction scene are solved. Specifically, the main thread, the rendering thread and the like of the appointed frame drawing task are identified, the type of the current image frame is marked, and the related information such as the running state, the drawing execution and the like is counted when the pile point of the frame model is received to decide the supply and demand strategy, so that the aim of automatically balancing the performance and the power consumption is fulfilled.
Referring to fig. 14, fig. 14 is a flowchart of a method for adjusting a frequency according to another exemplary embodiment, which is applied to an electronic device, by way of example and not limitation, and the electronic device is implemented through interaction of a plurality of modules in fig. 6, and specifically, the method may include some or all of the following:
1401: the application receives the synchronization signal.
In one embodiment, the synchronization signal may be sent to the application by the SF module in the frame model, where the synchronization signal is used to instruct the application to perform the framing operation.
1402: the application program starts a plurality of critical threads, which are used to draw the current image frame.
As described above, the plurality of critical threads mainly includes the main thread and the rendering thread, and further, the plurality of critical threads may also include other threads, such as other threads including thread a.
The current image frame is also the image frame being drawn. The type of the current image frame may be a blank frame or a non-blank frame. Specifically, when the frame rate of the application program is low, the application program may selectively not draw some image frames, i.e., blank frames, after receiving the synchronization signal, in order to keep the frame drawing operation consistent with the screen refreshing operation. It will be appreciated that image frames other than blank frames are non-blank frames.
As one example of the present application, the blank frames include two types of blank frames NR and NQ. If the current image frame is a blank frame, a plurality of key threads may be started according to the type of the blank frame. For example, if it is a blank frame NR, the application starts the main thread, but the main thread does not pull up the rendering thread. For another example, if it is a blank frame NQ, the application starts the main thread, and the main thread Cheng Laqi renders the thread, but the rendering thread does not execute the draw () request, i.e., does not execute the drawing flow.
Next, an example will be described in which the current image frame is a blank frame.
1403: the application invokes the frame model.
As an example of the present application, if the current image frame is a blank frame, the application may call the first frame module or the second frame module in the frame model. A stub 1 is inserted into the first frame model, and a first instrumentation code is added at the stub 1, where the first instrumentation code is used to identify the blank frame of the first type, that is, the blank frame NR. A stub 2 is inserted into the second frame model, and a second plug-in code is added at the stub 2, where the second plug-in code is used for identifying the blank frame of the second type, that is, the blank frame NQ.
If the current image frame is a blank frame of a first type, namely a blank frame NR, a main thread in the application program can call a first frame module in the running process; if the current image frame is a blank frame of a second type, that is, a blank frame NQ, the rendering thread in the application program invokes a second frame module in the frame model during operation.
1404: in the case where the current image frame is a blank frame, the frame model sends a first message to the proxy module.
In one case, if the current image frame is a blank frame of the first type, the frame model sends a first message to the proxy module through the first frame module, and at this time, the first message carries first pile point information, where the first pile point information is used to indicate pile point 1.
In another case, if the current image frame is a blank frame of the second type, the frame model sends a first message to the proxy module through the second frame module, and at this time, the first message carries second pile point information, where the second pile point information is used to indicate pile point 2.
1405: the proxy module forwards the first message to the message center processing module.
As described above, the proxy module plays a role in transparent transmission of the message, so after receiving the first message issued by the frame model, the proxy module forwards the first message to the message center processing module for message processing.
1406: the message center processing module parses the first message.
The first message carries first pile point information or second pile point information, wherein the first pile point information is used for indicating that the current image frame is a blank frame NR, and the second pile point information is used for indicating that the current image frame is a blank frame NQ.
In one example, the message center processing module parses the message to determine the semantics of the message each time the message forwarded by the proxy module is received. Therefore, after the message center processing module receives the first message, the first message is analyzed and processed. In one case, if the first type blank frame of the current image frame is a blank frame, the message center processing module determines that the current image frame is a blank frame by analyzing the first message to obtain first pile point information; in another case, if the current image frame is a blank frame of the second type, the second pile point information is obtained after the first message is parsed, and the message center processing module determines that the current image frame is a blank frame.
1407: the message center processing module sends a blank frame indication to the resource control module.
The blank frame indication is used to indicate that the current image frame is a blank frame.
And under the condition that the message center processing module determines that the current image frame is a blank frame according to the analysis result of the first message, sending a blank frame indication to the resource control module so as to facilitate the resource control module to adjust the maximum frequency value of the processor. In one example, the message center processing module may invoke a designated interface provided by the resource control module to send a blank frame indication to the resource control module. The designated interface can be set according to actual requirements.
It should be noted that, the foregoing is merely illustrative of an example in which the message center processing module sends a blank frame indication to the resource control module, and in another embodiment, the message center processing module may also notify the resource control module that the current image frame is a blank frame in other manners, which is not limited in the embodiment of the present application.
1408: the resource control module adjusts the maximum frequency value of the processor in the current frame drawing task to a target frequency value.
After receiving the blank frame indication sent by the message center processing module, the resource control module determines that the blank frame is the drawing frame in the current drawing frame task, and in this case, the resource control module adjusts the maximum frequency value of the processor to be a lower target frequency value so as to perform frequency pressing on the processor. The specific implementation of the resource control module adjusting the maximum frequency value of the processor may refer to step 805 in the embodiment of fig. 8, and the detailed description is not repeated here.
In one embodiment, the resource control module may cancel the timer BOOST mechanism, so that a judgment result of timeout of the drawing frame does not exist in the drawing time window corresponding to the blank frame, and thus the problem of automatic frequency boosting is not caused.
In one embodiment, the resource control module may also reduce the priority of operation of the plurality of critical threads, e.g., reduce the priority of the plurality of critical threads from yj to yi, as described above.
In the embodiment of the application, in the frame drawing process, the maximum frequency value of the processor is adjusted to a lower frequency point by identifying the blank frame, so that the performance and the power consumption can be better balanced, and the problems of excessive performance and power consumption waste caused by unnecessary frequency lifting of a user interaction scene are solved.
The above embodiment is described taking the example that the current image frame is a blank frame. In another possible case, when the current image frame is not a blank frame, referring to fig. 15, fig. 15 is a schematic flow chart of a method for adjusting frequency according to another exemplary embodiment, and the method is applied to an electronic device, by way of example and not limitation, and the electronic device is implemented through interaction of a plurality of modules in fig. 6, and specifically includes the following:
1501 to 1502 please refer to 1401 to 1402 in the embodiment shown in fig. 14 described above.
1503: the application invokes the third frame module in the frame model.
If the current image frame is not a blank frame, the application program does not call the first frame module or the second frame module in the frame model, but calls the third frame module to perform the drawing operation. The number of the third frame modules may include a plurality of, and illustratively, the third frame modules include a queue buffer module for executing the queue buffer.
1504: the frame model issues a second message to the proxy module.
As an example of the present application, when the current image frame is not a blank frame, the application program invokes a third frame module in the frame model, the third frame module generates one or more second messages, and the third frame module sends the one or more second messages to the proxy module. Illustratively, the second message includes a queue bufferend message for indicating that the queue buffer has ended.
1505: the proxy module forwards the second message to the message center processing module.
As described above, the proxy module functions as a transparent message, so that the proxy module forwards the one or more second messages to the message center processing module after receiving the one or more second messages.
1506: the message center processing module parses the second message.
After receiving the one or more second messages, the message center processing module analyzes the one or more second messages to determine the semantics of each second message. So that corresponding message processing operations are performed according to the semantics of the second message. For example, when the message center processing module determines that the second message is used to indicate that the queue buffer has ended, i.e., the received second message is a queue buffer end message, the following step 1507 is entered.
1507: the message center processing module sends a thread identification indication to the critical thread identification module.
That is, when the queue buffer end point of the image frame is reached, the message center processing module sends a thread identification instruction to the key thread identification module, so that the key thread identification module performs operations such as thread identification.
1508: the critical thread identification module identifies each critical thread and determines relevant information for each critical thread.
In one example, information about a critical thread includes, but is not limited to, the critical thread's runtime, load on the processor, core information of the core in which it resides, and so on.
1509: the key thread identification module sends the relevant information of each key thread to the load calculation module.
1510: and the load calculation module determines the loads of a plurality of key threads in one frame drawing task on the processor according to the related information of each key thread.
1511: the load calculation module determines a maximum frequency value of the processor based on the determined load.
The specific implementation process can be seen in step 802 in the embodiment of fig. 8.
1512: the load calculation module sends the determined maximum frequency value of the processor to the resource control module.
1513: the resource control module adjusts the operating frequency of the processor based on the maximum frequency value sent by the load calculation module.
As an example and not by way of limitation, in the above-mentioned drawing process, the message center module may also notify the resource control module after receiving the queue buffer end message, so that the resource control module starts a timer BOOST mechanism, so that automatic frequency boosting can be performed by the timer BOOST mechanism when a drawing timeout occurs in the process of drawing a non-blank frame.
In the embodiment of the application, when the queue buffer end point is reached in the process of drawing frames, the load of each key thread in the last drawing frame task on the processor is determined, and then the maximum frequency value of the processor in the drawing frame task after the queue buffer end point is adjusted according to the determined load, so that the running frequency of the processor is in a more reasonable range, and the effects of balancing performance and power consumption are achieved.
Fig. 16 is a flowchart of a method for adjusting a frequency according to another exemplary embodiment, where the method may be applied to an electronic device, and may specifically include the following implementation contents:
1610: and drawing the first image frame, wherein the operating frequency of the processor of the electronic device is a first frequency value when the first image frame is drawn.
In one example, the first image frame is the current image frame in the various embodiments described above.
Wherein the first frequency value may be determined based on a current maximum frequency value of the processor. In one example, the last image frame of the first image frame is a non-blank frame, at which point the determination of the current maximum frequency value of the processor may be seen from steps 801 to 802 in the embodiment of fig. 8. In implementation, the electronic device may determine a first frequency value according to a preset resource allocation policy and a current maximum frequency value of the processor, and then adjust an operating frequency of the processor to the first frequency value.
As an example of the present application, the first frequency value may be a value very close to the current maximum frequency value of the processor, which is not particularly limited by the embodiment of the present application.
In another example, if the frame is blank from the previous image frame to the first image frame, the current maximum frequency value of the processor may be the last determined target frequency value, which may be determined in a manner described below.
1620: if the first image frame is a blank frame, determining a second frequency value, wherein the second frequency value is smaller than the first frequency value, and the blank frame is an image frame without outputting image data.
As an example of the present application, if the first image frame is a blank frame, determining the specific implementation of the second frequency value may include: if the first image frame is a blank frame, a target frequency value is obtained, the target frequency value is smaller than the maximum frequency value of the processor in the frame drawing task of the last non-blank frame, the maximum frequency value of the processor is adjusted to be the target frequency value, and a second frequency value is determined according to the adjusted maximum frequency value of the processor.
Illustratively, the target frequency value is less than the processor's current maximum frequency value described in step 1610.
The electronic device may determine the second frequency value according to a preset resource allocation policy and a target frequency value. As an example of the present application, the second frequency value may be a value very close to the target frequency value, which is not particularly limited by the embodiment of the present application.
As one example of the application, a processor includes a plurality of cores, each core of the plurality of cores having a different target frequency value. At this time, if the first image frame is a blank frame, the specific implementation of obtaining the target frequency value may include: if the first image frame is a blank frame, respectively acquiring a target frequency value corresponding to each target core in the plurality of cores, wherein the target core is a core running a key thread for executing a frame drawing task in the plurality of cores. Accordingly, a specific implementation of adjusting the maximum frequency value of the processor to the target frequency value may include: and respectively adjusting the maximum frequency value of each target core to be the target frequency value corresponding to each target core.
It should be noted that, in the embodiment of the present application, the target frequency value is a preset fixed frequency value, and in another embodiment, the target frequency value may also be dynamically determined, which may be specifically referred to the embodiment of fig. 8, and the detailed description is not repeated here.
As an example of the present application, before step 1620, it is determined whether the first image frame is a blank frame. Specifically, the electronic device may determine, during the drawing of the first image frame, whether the first image frame is a blank frame according to the running conditions of the plurality of key threads. Each of the plurality of critical threads is for performing a frame drawing task, illustratively including a main thread, a rendering thread, and other threads a.
As an example of the present application, the plurality of key threads includes a main thread and a rendering thread, in which case, in the process of drawing the first image frame, determining, according to the running conditions of the plurality of key threads, whether the first image frame is a blank frame may include two possible cases as follows:
first case: in the process of drawing the first image frame, if the main thread does not call the rendering thread, determining that the first image frame is a blank frame.
That is, when there is UI read no RENDER THREAD in the process of drawing the first image frame, it is determined that the first image frame is a blank frame.
In one example, an electronic device includes a first frame module and a message center processing module. At this time, in the process of drawing the first image frame of the frame, if the first plug-in code in the first frame module is called in the operation process of the main thread, the first frame module sends first stub information to the message center processing module, where the first stub information is used to indicate the plug-in position of the first plug-in code in the first frame module. And after the message center processing module receives the first pile point information, determining that the rendering thread is not called by the main thread.
In the second case: in the process of drawing the first image frame, if the rendering thread is not drawn by the rendering thread after the rendering thread is called by the main thread, determining that the first image frame is a blank frame.
In one example, an electronic device includes a second frame module and a message center processing module. At this time, in the process of drawing the first image frame of the frame, if the rendering thread is invoked by the main thread, and the second plug-in code in the second frame module is invoked in the running process of the rendering thread, the second frame module sends second stake point information to the message center processing module, where the second stake point information is used for indicating the insertion position of the second plug-in code in the second frame module. And after the message center processing module receives the second pile point information, determining that the rendering thread does not draw the rendering data.
That is, when there are UI read and RENDER THREAD but no queue buffer in the process of drawing the first image frame, it is determined that the first image frame is a blank frame.
1630: the operating frequency of the processor is adjusted to a second frequency value.
Further, under the condition that the first image frame is a blank frame, if the previous frame of the first image frame is a non-blank frame, a timer timing function is canceled, wherein the timer timing function is used for increasing the maximum frequency value of the processor under the condition that the timing reaches the preset duration after the frame drawing task of the previous frame is finished.
The preset duration may be set by a technician according to actual requirements, or may be set by default by the electronic device, which is not limited in the embodiment of the present application.
Further, in the case where the first image frame is a blank frame, the operation priority of at least one of the plurality of key threads is reduced. That is, in the case where the first image frame is a blank frame, the operation priority of some or all of the plurality of critical threads may be reduced, so that other threads may preferentially use resources, and thus the completion efficiency of other functions may be improved.
In the embodiment of the application, in the process of drawing frames, the running frequency value of the processor is adjusted to a lower frequency point by identifying blank frames, so that the performance and the power consumption can be better balanced, and the problems of excessive performance and power consumption waste caused by unnecessary frequency lifting of a user interaction scene are solved.
Fig. 17 is a schematic structural diagram of an apparatus for adjusting frequency according to an embodiment of the present application, where the apparatus may be implemented as part or all of a computer device, which may be the electronic device shown in fig. 5, by software, hardware, or a combination of both. Referring to fig. 17, the apparatus includes:
a drawing module 1710, configured to draw a first image frame, where an operating frequency of a processor of the electronic device is a first frequency value when the first image frame is drawn;
a resource control module 1720, configured to determine a second frequency value if the first image frame is a blank frame, where the second frequency value is smaller than the first frequency value, and the blank frame is an image frame that does not output image data;
the resource control module 1720 is further configured to adjust an operating frequency of the processor to the second frequency value.
As an example of the present application, the resource control module 1720 is configured to:
If the first image frame is the blank frame, acquiring a target frequency value, wherein the target frequency value is smaller than the maximum frequency value of the processor in a frame drawing task of the last non-blank frame;
adjusting a maximum frequency value of the processor to the target frequency value;
and determining the second frequency value according to the adjusted maximum frequency value of the processor.
As an example of the present application, the apparatus further comprises a frame model for:
and in the process of drawing the first image frame, determining whether the first image frame is the blank frame according to the running conditions of a plurality of key threads, wherein each key thread in the plurality of key threads is used for executing a frame drawing task.
As one example of the present application, the plurality of critical threads includes a main thread and a rendering thread; the frame model is used for:
in the process of drawing the first image frame, if the main thread does not call the rendering thread, determining that the first image frame is the blank frame; or alternatively, the process may be performed,
and in the process of drawing the first image frame, if the rendering thread does not draw the rendering data after the main thread calls the rendering thread, determining that the first image frame is the blank frame.
As one example of the present application, the electronic device includes a first frame module and a message center processing module;
in the process of drawing the first image frame, if a first plug-in code in the first frame module is called in the operation process of the main thread, the first frame module sends first pile point information to the message center processing module, wherein the first pile point information is used for indicating the plug-in position of the first plug-in code in the first frame module;
and after the message center processing module receives the first pile point information, determining that the rendering thread is not called by the main thread.
As one example of the present application, the electronic device includes a second frame module and a message center processing module;
in the process of drawing the first image frame, if a second plug-in code in the second frame module is called in the running process of the rendering thread after the rendering thread is called by the main thread, the second frame module sends second stake point information to the message center processing module, wherein the second stake point information is used for indicating the plug-in position of the second plug-in code in the second frame module;
and after the message center processing module receives the second pile point information, determining that the rendering thread does not draw the rendering data.
As one example of the application, the processor includes a plurality of cores, each core of the plurality of cores having a different target frequency value; the resource control module 1720 is configured to:
if the first image frame is the blank frame, respectively acquiring a target frequency value corresponding to each target core in the plurality of cores, wherein the target core is a core running a key thread for executing a frame drawing task in the plurality of cores;
the adjusting the maximum frequency value of the processor to the target frequency value includes:
and respectively adjusting the maximum frequency value of each target core to be the target frequency value corresponding to each target core.
As an example of the present application, the resource control module 1720 is also configured to:
and under the condition that the first image frame is the blank frame, if the previous frame of the first image frame is a non-blank frame, canceling a timer timing function, wherein the timer timing function is used for increasing the maximum frequency value of the processor under the condition that the timing reaches the preset duration after the frame drawing task of the previous frame is ended.
As an example of the present application, the resource control module 1720 is also configured to:
And reducing the operation priority of at least one key thread in the plurality of key threads in the case that the first image frame is the blank frame.
In the embodiment of the application, in the frame drawing process, the maximum frequency value of the processor is adjusted to a lower frequency point by identifying the blank frame, so that the performance and the power consumption can be better balanced, and the problems of excessive performance and power consumption waste caused by unnecessary frequency lifting of a user interaction scene are solved. Specifically, the main thread, the rendering thread and the like of the appointed frame drawing task are identified, the type of the current image frame is marked, and the related information such as the running state, the drawing execution and the like is counted when the pile point of the frame model is received to decide the supply and demand strategy, so that the aim of automatically balancing the performance and the power consumption is fulfilled.
It should be noted that: in the frequency adjustment device provided in the above embodiment, only the division of the above functional modules is used for illustration, and in practical application, the above functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to perform all or part of the functions described above.
The functional units and modules in the above embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiments of the present application.
The frequency adjustment device and the frequency adjustment method provided in the foregoing embodiments belong to the same concept, and specific working processes and technical effects of the units and modules in the foregoing embodiments may be referred to a method embodiment part, which is not described herein again.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, data subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium such as a floppy Disk, a hard Disk, a magnetic tape, an optical medium such as a digital versatile Disk (Digital Versatile Disc, DVD), or a semiconductor medium such as a Solid State Disk (SSD), etc.
The above embodiments are not intended to limit the present application, and any modifications, equivalent substitutions, improvements, etc. within the technical scope of the present application should be included in the scope of the present application.

Claims (9)

1. A method of adjusting a frequency, for application to an electronic device, the method comprising:
drawing a first image frame, wherein the operating frequency of a processor of the electronic device is a first frequency value when the first image frame is drawn;
and in the process of drawing the first image frame, if a main thread does not call a rendering thread or the rendering thread does not draw rendering data after the main thread calls the rendering thread, adjusting the running frequency of the processor to be the second frequency value, wherein the second frequency value is smaller than the first frequency value.
2. The method according to claim 1, wherein the method further comprises:
when the main thread does not call a rendering thread or the rendering thread does not draw rendering data after the main thread calls the rendering thread, the maximum frequency value of the processor is reduced;
the second frequency value is determined based on the adjusted maximum frequency value of the processor.
3. The method of claim 2, wherein the lowering the maximum frequency value of the processor if the main thread does not call a rendering thread or the rendering thread does not draw rendering data after the main thread calls the rendering thread comprises:
acquiring a target frequency value under the condition that the main thread does not call a rendering thread or the rendering thread does not draw rendering data after the main thread calls the rendering thread;
and reducing the maximum frequency value of the processor to the target frequency value.
4. The method of claim 1, wherein the electronic device comprises a first frame module and a message center processing module; the method further comprises the steps of:
in the process of drawing the first image frame, if a first plug-in code in the first frame module is called in the operation process of the main thread, the first frame module sends first pile point information to the message center processing module, wherein the first pile point information is used for indicating the plug-in position of the first plug-in code in the first frame module;
and after the message center processing module receives the first pile point information, determining that the rendering thread is not called by the main thread.
5. The method of claim 1, wherein the electronic device comprises a second frame module and a message center processing module; the method further comprises the steps of:
in the process of drawing the first image frame, if a second plug-in code in the second frame module is called in the running process of the rendering thread after the rendering thread is called by the main thread, the second frame module sends second stake point information to the message center processing module, wherein the second stake point information is used for indicating the plug-in position of the second plug-in code in the second frame module;
and after the message center processing module receives the second pile point information, determining that the rendering thread does not draw the rendering data.
6. The method of claim 3, wherein the processor comprises a plurality of cores, each core of the plurality of cores having a different target frequency value;
and under the condition that the main thread does not call the rendering thread or the rendering thread does not draw the rendering data after the main thread calls the rendering thread, acquiring the target frequency value comprises the following steps:
acquiring a target frequency value corresponding to each target core in the plurality of cores under the condition that the main thread does not call the rendering thread or the rendering thread does not draw rendering data after the main thread calls the rendering thread, wherein the target core is a core running a key thread for executing a frame drawing task in the plurality of cores;
The step of reducing the maximum frequency value of the processor to the target frequency value comprises the following steps:
and adjusting the maximum frequency value of each target core to be the target frequency value corresponding to each target core.
7. The method according to any one of claims 1-6, further comprising:
stopping a timer timing function when a preset condition is met, wherein the timer timing function is used for triggering to increase the maximum frequency value of the processor when timing reaches a preset duration after a frame drawing task of a second image frame is finished, and the second image frame is a previous frame image of the first image frame;
the preset conditions include:
in the process of drawing the first image frame, the main thread does not call the rendering thread, or if the main thread calls the rendering thread, the rendering thread does not draw rendering data; and, in addition, the processing unit,
in the process of drawing the second image frame, the main thread calls the rendering thread, and the rendering thread draws rendering data.
8. An electronic device, characterized in that the electronic device comprises in its structure a processor and a memory for storing a program supporting the electronic device to perform the method as provided in any of claims 1-7, and for storing data involved for implementing the method as claimed in any of claims 1-7; the processor is configured to execute a program stored in the memory.
9. A computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the method of any of claims 1-7.
CN202310358482.7A 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium Pending CN116774809A (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN202210267048 2022-03-17
CN2022102670483 2022-03-17
CN202210402879.7A CN114911336B (en) 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202210402879.7A Division CN114911336B (en) 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN116774809A true CN116774809A (en) 2023-09-19

Family

ID=82764670

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210402879.7A Active CN114911336B (en) 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium
CN202310358482.7A Pending CN116774809A (en) 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202210402879.7A Active CN114911336B (en) 2022-03-17 2022-04-18 Method and device for adjusting frequency, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (2) CN114911336B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116704087B (en) * 2022-10-17 2024-02-27 荣耀终端有限公司 Parameter adjustment method and electronic equipment
CN117130768A (en) * 2023-02-25 2023-11-28 荣耀终端有限公司 Frequency modulation relation table generation method and electronic equipment
CN116204059B (en) * 2023-04-28 2023-09-26 荣耀终端有限公司 Frame rate adjustment method and device for eye movement tracking
CN116414215B (en) * 2023-06-05 2023-10-20 荣耀终端有限公司 Frequency modulation method and frequency modulation device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4528027B2 (en) * 2004-05-11 2010-08-18 株式会社バンダイナムコゲームス Image generation program, information storage medium, and image generation system
CN106155263B (en) * 2015-04-14 2021-07-20 华为技术有限公司 Parameter adjusting method and device
WO2019205172A1 (en) * 2018-04-28 2019-10-31 华为技术有限公司 Power distribution method, device, and system of image processor
US11430358B2 (en) * 2019-03-27 2022-08-30 Huawei Technologies Co., Ltd. Frequency adjustment method and apparatus applied to terminal, and electronic device
CN110209501B (en) * 2019-06-03 2022-02-08 Oppo广东移动通信有限公司 Frequency adjusting method and device of graphic processor, terminal and storage medium
CN112363842B (en) * 2020-11-27 2023-01-06 Oppo(重庆)智能科技有限公司 Frequency adjusting method and device for graphic processor, electronic equipment and storage medium
CN113132059B (en) * 2021-04-21 2022-02-25 广东工业大学 Frame synchronization method and device for blank frame transmission

Also Published As

Publication number Publication date
CN114911336A (en) 2022-08-16
CN114911336B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN114911336B (en) Method and device for adjusting frequency, electronic equipment and readable storage medium
CN116501210B (en) Display method, electronic equipment and storage medium
CN113254120B (en) Data processing method and related device
US20220350602A1 (en) Multi-Thread Synchronization Method and Electronic Device
EP4280056A1 (en) Method for application performing drawing operation, and electronic device
CN114697446B (en) Refresh rate switching method, electronic device and storage medium
CN114632329B (en) Terminal equipment performance adjusting method and related device
CN116680153B (en) Application frame rate smoothing method, electronic device and storage medium
CN116048933B (en) Fluency detection method
CN116010076A (en) Application running method and related equipment
CN116467221B (en) Pile inserting method and system based on interpreter and related electronic equipment
CN116048771B (en) Resource scheduling method and related equipment
WO2023066165A1 (en) Animation effect display method and electronic device
CN113641431A (en) Method and terminal equipment for enhancing display of two-dimensional code
CN116700813B (en) Method for loading widget, electronic device and readable storage medium
WO2024016798A9 (en) Image display method and related apparatus
EP4258655A1 (en) Electronic device and photographing method thereof, and medium
CN116052609B (en) Voltage control method, electronic device and readable storage medium
CN116700463B (en) Activity recognition method and related equipment
WO2024131486A1 (en) Performance analysis method, readable storage medium, program product and electronic device
WO2024032430A1 (en) Memory management method and electronic device
WO2023066177A1 (en) Animation effect display method and electronic device
CN117806745A (en) Interface generation method and electronic equipment
CN117909070A (en) Information transmission method, electronic device, storage medium and chip system
CN117952579A (en) Information acquisition method and mobile terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination