Resource scheduling method and electronic device
By setting levels and scheduling parameters for application threads and dynamically adjusting resource allocation, the existing technology problems of increased power consumption and rough resource management when improving the performance of electronic devices are solved, achieving stable operation of applications and efficient resource utilization. .
Patent Information
- Application Number
- PCT/CN2024/075525
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-09
- Filing Date
- 2024-02-02
- Publication Date
- 2024-09-12
AI Technical Summary
Existing technologies tend to increase power consumption when improving the overall performance of electronic devices, affecting the running smoothness of applications. Moreover, the granularity of resource scheduling is relatively coarse and cannot effectively manage the resource requirements of different applications in different operating states.
By setting the level and scheduling parameters for application threads, resource allocation is dynamically adjusted. The application thread is used as the granularity, and resource allocation is adjusted according to the thread level and operating data to ensure stable operation and avoid resource waste.
It achieves precise adjustment of resource allocation under different application running states, improves the running stability and fluency of applications, while saving power consumption and avoiding resource competition and waste.
Smart Images

Figure CN2024075525_12092024_PF_FP
Abstract
Description
Resource scheduling method and electronic equipment
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 9, 2023, with application number 202310271542.1 and application name “Resource Scheduling Method and Electronic Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminal technology, and in particular to a resource scheduling method and electronic equipment. Background Art
[0003] When each application is running, the electronic device can provide each application with hardware resources for supporting the running of each application.
[0004] During the execution of each application, the electronic device can identify the running status of each application and, based on the running status of each application, improve or reduce the overall performance of the electronic device. For example, the operating frequency of hardware resources such as the central processing unit (CPU) in the electronic device can be increased or decreased.
[0005] However, improving the overall performance of the electronic device will increase the power consumption of the electronic device, while reducing the overall performance of the electronic device will easily affect the smoothness of the application program running.
[0006] Summary of the Invention
[0007] Embodiments of the present application provide a resource scheduling method and an electronic device, which can dynamically adjust the resources allocated by the electronic device to an application based on the granularity of the threads included in the application.
[0008] To achieve the above objectives, the present invention adopts the following technical solutions:
[0009] In a first aspect, an embodiment of the present application provides a resource scheduling method that can be applied to an electronic device. In the method, when it is detected that the running state of a first application is switched from a first state to a second state, the level of at least one first thread is determined. The at least one first thread is used to run the first application. The level is the relative level of each first thread corresponding to the first application. According to the level of the first thread, the scheduling parameters corresponding to each level are determined. The scheduling parameters are used to allocate resources to the first thread with the corresponding level. Different levels correspond to different scheduling parameters. Resources are allocated to the first thread according to the scheduling parameters corresponding to the level of the first thread.
[0010] In the method of the present application, when the running state of the first application changes, the level of the first thread can be kept unchanged, and the scheduling parameters corresponding to the level of the first thread can be determined, so that the allocated resources for each first thread can be increased or decreased differently.
[0011] In combination with the first aspect, in one possible design, the first thread is a thread in a running state corresponding to the first application.
[0012] In conjunction with the first aspect, in one possible design, when the first thread completes execution, first execution data is obtained. The first execution data is associated with the first thread and includes execution data of the first application during the current execution of the first thread. Based on the first execution data and the second execution data, the scheduling parameters corresponding to the level of the first thread are adjusted. The second execution data is associated with the first thread and is obtained based on execution data of the first application during the historical execution of the first thread.
[0013] In this solution, when the first thread ends its operation, the scheduling parameters corresponding to the first thread's level can be adjusted based on the first operation data and the second operation data. Therefore, when the first thread runs again, resources are allocated to the first thread based on the adjusted scheduling parameters corresponding to the first thread's level, which can ensure the stable operation of the second thread and avoid wasting resources.
[0014] In conjunction with the first aspect, in one possible design, based on the first operating data and the second operating data, it is determined whether resources need to be reallocated to the first thread. If it is determined that resources need to be reallocated to the first thread, the scheduling parameters corresponding to the level of the first thread are adjusted.
[0015] In this solution, conditions for adjusting the scheduling parameters corresponding to the level of the first thread are given.
[0016] In conjunction with the first aspect, in one possible design, normalization processing is performed on the first running data to obtain a first value. Normalization processing is performed on the second running data to obtain a second value. A ratio of the first value to the second value is determined as a third value. When the third value is greater than or equal to a fourth value, or when the third value is less than or equal to a fifth value, the scheduling parameter corresponding to the rank of the first thread is adjusted.
[0017] In this solution, conditions for determining whether to adjust the scheduling parameters corresponding to the level of the second thread are given.
[0018] In conjunction with the first aspect, in one possible design, upon detecting that the running state of a first application program has switched from a first state to a second state, a setting operation input by a user is received before determining the rank of at least one first thread. In response to the setting operation, the rank of the at least one first thread corresponding to the first application program and a scheduling parameter corresponding to the rank of the at least one first thread are set.
[0019] In this solution, by setting levels for the first threads corresponding to the first application and setting scheduling parameters corresponding to the levels, resources can be allocated to the first threads corresponding to the first application at the thread granularity when the first application is running.
[0020] In combination with the first aspect, in a possible design, when the first application is a third-party application, the level of each first thread is less than the level threshold.
[0021] In this solution, it is possible to only allow developers of third-party applications to set the level of the first thread below the level threshold, thereby preventing developers of third-party applications from setting higher levels for each first thread to preempt resources, resulting in resource competition among the running threads.
[0022] In a second aspect, embodiments of the present application provide an electronic device. The electronic device includes a memory and one or more processors, the memory and the processors being coupled; the memory is configured to store computer program code, the computer program code comprising computer instructions, and when the processor executes the computer instructions, the electronic device executes the method described in the first aspect and any possible design thereof.
[0023] In a third aspect, embodiments of the present application provide a chip system. The chip system includes one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via wiring. The interface circuits are configured to receive signals from a memory of an electronic device and send signals to the processors. The signals include computer instructions stored in the memory. When the processors execute the computer instructions, the electronic device executes the method described in the first aspect and any possible design thereof.
[0024] In a fourth aspect, an embodiment of the present application provides a computer storage medium comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and any possible design thereof.
[0025] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the method described in the first aspect and any possible design thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] FIG1 is a hardware structure diagram of an electronic device provided in an embodiment of the present application;
[0027] FIG2 is a software structure diagram of an electronic device provided in an embodiment of the present application;
[0028] FIG3 is a flow chart of a resource scheduling method provided in an embodiment of the present application;
[0029] FIG4 is a schematic diagram of setting levels and scheduling parameters provided in an embodiment of the present application;
[0030] FIG5 is a scene diagram of a state switching of a first application provided by an embodiment of the present application;
[0031] FIG6 is a schematic diagram of adjusting resources allocated to threads according to an embodiment of the present application;
[0032] FIG7 is a schematic diagram of adjusting scheduling parameters provided in an embodiment of the present application;
[0033] FIG8 is a schematic diagram of a resource scheduling system provided in an embodiment of the present application;
[0034] FIG9 is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0036] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0037] When each application is running, the electronic device can provide corresponding hardware resources (referred to as resources in the embodiment of the present application) for each application to ensure that each application can run stably and smoothly. However, the resources required to use different applications when running are usually different. The same application usually requires different resources in different running states. For example, the memory space of the electronic device that the application needs to use when running in the background is usually smaller than the memory space of the electronic device that the application needs to use when running in the foreground. The CPU resources required to use when the application interacts with the user in the foreground are usually greater than the CPU resources required to use when the application is in a dormant state in the foreground, etc.
[0038] If the resources provided to an application are less than the resources required by the application in its corresponding operating state, it may cause problems such as lag during the application's operation. If the resources provided to an application are far greater than the resources required by the application in its corresponding operating state, it will result in resource waste. Therefore, how to provide resources to the application during its operation is a problem that needs to be solved.
[0039] In a related technology, electronic devices can identify the running status of each application and, based on the running status of each application, improve or reduce the overall performance of the electronic device. For example, the operating frequency of resources such as the central processing unit (CPU) in the electronic device can be increased or reduced. However, improving the overall performance of the electronic device will increase the power consumption of the electronic device, while reducing the overall performance of the electronic device will easily affect the smoothness of the application operation.
[0040] In another related technology, when an application is running, the electronic device can identify the key threads with dependencies included in the application to form a Related Thread Group (RTG). Among them, the key threads can be, for example, threads used to support the operation of the application or threads used to implement the main functions of the application. The electronic device can prioritize allocating resources to the key threads in the RTG group, and not allocate additional resources to non-key threads included in the application (such as threads used to support the application to implement additional functions) or only allocate fewer additional resources to the non-key threads included in the application, so as to reduce the power consumption of the electronic device.
[0041] However, the above method of focusing only on the key threads in the RTG group is likely to oversupply the key threads in the RTG group with resources, resulting in resource waste. In addition, the above method pays little or no attention to non-critical threads, resulting in a coarse granularity in resource scheduling for applications.
[0042] Based on the above content, an embodiment of the present application provides a resource scheduling method that can dynamically adjust the resources allocated by an electronic device to each application program based on the granularity of the threads included in the application program. In this method, by setting a level for each first thread corresponding to the first application program and setting the scheduling parameters corresponding to each level, resources can be allocated to each first thread based on the granularity of each first thread included in the first application program. When the running state of the first application program changes, the level of each first thread in the running state can be kept unchanged, and by adjusting the scheduling parameters corresponding to each level, the resources allocated to each first thread can be increased or decreased differently.
[0043] The resource scheduling method provided in the embodiment of the present application can be applied to electronic devices. The electronic devices in the embodiment of the present application can be portable computers (such as mobile phones, folding screen mobile phones), tablet computers, laptop computers, personal computers (PCs), wearable electronic devices (such as smart watches), augmented reality (AR) and virtual reality (VR) devices, car computers, etc. The operating system installed in the electronic device can be such as Harmony This application does not limit the specific type of electronic device or the type of operating system installed.
[0044] FIG1 shows a schematic structural diagram of an electronic device 100 .
[0045] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging 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 sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0046] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0047] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0048] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0049] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0050] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.
[0051] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0052] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0053] When an application in the electronic device is running, the hardware resources such as the processor 110, sensor module 180, motor 191, internal memory 121 in FIG1 can be allocated to at least one thread corresponding to the application so that each thread corresponding to the application can run.
[0054] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.
[0055] FIG2 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present invention.
[0056] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0057] The application layer can include a series of application packages.
[0058] As shown in Figure 2, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, video, etc. The application layer may also include a scene recognition module for detecting the running status of each application.
[0059] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer, such as a level setting interface for setting the corresponding thread level and a parameter setting interface for setting the corresponding level. The application framework layer includes some predefined functions.
[0060] As shown in FIG2 , the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a level setting interface, and a parameter setting interface.
[0061] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0062] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0063] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.
[0064] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering, hanging up, etc.).
[0065] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0066] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include displaying text messages in the status bar, emitting alert sounds, vibrating electronic devices, or flashing indicator lights.
[0067] The level setting interface is an interface used to set the thread level corresponding to the application.
[0068] The parameter setting interface is an interface used to set the scheduling parameters corresponding to the different levels set by the level setting interface.
[0069] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
[0070] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.
[0071] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.
[0072] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0073] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0074] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0075] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0076] A 2D graphics engine is a drawing engine for 2D drawings.
[0077] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, parameter adjustment module, scheduling module, and data storage module.
[0078] The parameter adjustment module is used to adjust the scheduling parameters. The scheduling module is used to allocate hardware resources to the corresponding threads based on the scheduling parameters. The data storage module is used to store the running data of each application.
[0079] The resource scheduling method provided in the embodiment of the present application is described below. As shown in FIG3 , the method may include the following steps S301-S306:
[0080] S301: Determine a first application, where the first application corresponds to at least one first thread.
[0081] The first application corresponds to an application process. The application process of the first application is the program process corresponding to the first application, that is, the set of instructions corresponding to the first application that are active in the system. The application process of the first application may include only one thread. For example, a critical thread used to support the operation of the first application or implement the main functions of the first application. The application process of the first application may also include multiple threads. For example, including the aforementioned critical thread and at least one non-critical thread used to implement additional functions of the first application.
[0082] For example, when the first application is an application for playing a video, the first thread corresponding to the first application may be the first thread for executing screen display (this thread may be a critical thread). The first thread corresponding to the first application may also be the first thread for executing audio playback (this thread may be a non-critical thread). The first thread corresponding to the first application may also be the first thread for executing bullet screen display (this thread may also be a non-critical thread), etc.
[0083] When the first application is running, the critical thread corresponding to the first application starts running, and the non-critical threads corresponding to the first application may or may not run.
[0084] S302: Setting a level for each first thread and a scheduling parameter corresponding to each level.
[0085] Scheduling parameters are parameters associated with resource allocation and can be used to allocate resources to threads of corresponding ranks. For example, the nice parameter is associated with the priority of the target thread. A smaller nice parameter indicates a higher priority for the target thread, allowing it to execute earlier and receive more resources. Another example is the uclamp parameter, which is associated with the target thread's CPU usage.
[0086] The resources in the embodiment of the present application may include hardware resources such as CPU, GPU, input / output device (I / O device), memory of electronic device, etc. The embodiment of the present application does not limit the specific content of the resources.
[0087] In some embodiments, the user may input a first setting operation to the electronic device based on the importance of each first thread relative to the first application, so as to instruct the electronic device to set the level of each first thread.
[0088] For example, when the first application is an application for playing music, the first application may correspond to a first thread for executing the playback service, a first thread for displaying playback effects, a first thread for displaying lyrics, and a first thread for displaying comments related to the music, etc. Based on the importance of each first thread relative to the first application, the user may input a first setting operation to the electronic device to instruct the electronic device to set the level corresponding to the first thread for displaying comments related to the music to the first level, the level corresponding to the first thread for displaying playback effects to the second level, the level corresponding to the first thread for displaying lyrics to the third level, and the level corresponding to the first thread for executing the playback service to the fourth level. Among them, the higher the level corresponding to the first thread, the higher the importance of the first thread relative to the first application, that is, the greater the probability of creating and running the first thread when the first application is running.
[0089] It is understood that the levels in the embodiments of the present application are relative levels of the first threads corresponding to the first application. For example, the first application includes a first thread 1 corresponding to the first level, a first thread 2 corresponding to the second level, and a first thread 3 corresponding to the third level. A second application different from the first application includes a first thread a corresponding to the first level, a first thread b corresponding to the second level, and a first thread c corresponding to the third level. The first level corresponding to the first thread 1 has a different meaning from the first level corresponding to the first thread a.
[0090] In some embodiments, the user may input a second setting operation to the electronic device to instruct the electronic device to set a scheduling parameter corresponding to the level of each first thread.
[0091] For example, the first application corresponds to seven first threads, and the level corresponding to each first thread is set to be different, that is, a total of seven levels are set (level 1 to level 7), see Table 1.
[0092] Table 1
[0093] The first parameter, the second parameter, the third parameter, and the fourth parameter are all scheduling parameters. When the first application is running, the rank of the first thread in the running state can be determined based on Table 1. Resources are then allocated to each first thread based on the scheduling parameters corresponding to the rank of each first thread.
[0094] In the above example, the first threads corresponding to the first application have different levels. In actual applications, among the first threads corresponding to the first application, at least two of the first threads may have the same level. For example, the first application corresponds to first thread 1, first thread 2, first thread 3, first thread 4, and first thread 5. Among them, the level corresponding to first thread 1 is level 7, the levels corresponding to first thread 2 and first thread 3 are both level 5. The levels corresponding to first thread 4 and first thread 5 are both level 1, and so on.
[0095] In some embodiments, in order to prevent the developer of a third-party application from setting a higher level for the non-critical threads of the third-party application to preempt resources, resulting in resource competition between the running threads, a corresponding first permission mechanism can be set. The first permission mechanism is to only allow the developer of the third-party application to set the level of the thread below the level threshold. For example, if the level threshold is the fourth level, the permission mechanism is to only allow the developer of the third-party application to set the level of the thread to the first level, the second level, or the third level (the first level, the second level, or the third level are all lower than the fourth level).
[0096] In some embodiments, a second permission mechanism may also be provided. This second permission mechanism only allows the user to set the level of each first thread and the scheduling parameters corresponding to each level in preset scenarios. The preset scenarios may include the failure of the electronic device to automatically set the level of each first thread and the scheduling parameters corresponding to each level, etc., which is not limited in the embodiments of the present application.
[0097] In some embodiments, referring to FIG4 , a level setting interface 401 and a parameter setting interface 402 may be opened to the user. The user may input a first setting operation into the electronic device to set the level of each first thread corresponding to the first application 400 through the level setting interface 401. Also, the user may input a second setting operation into the electronic device to set the scheduling parameters corresponding to each level through the parameter setting interface 402. A scheduling table 403 may be generated based on the level of each first thread set by the user and the scheduling parameters corresponding to each level. Afterwards, the electronic device may store the scheduling table 403 in a memory, and when it is detected that each first thread is running, the scheduling table 403 may be directly called to allocate resources to each running first thread based on the level corresponding to the first thread in the scheduling table 403 and the scheduling parameters corresponding to the level.
[0098] S303: When the first thread is running, resources are allocated to the first thread based on the level of the first thread and the scheduling parameters corresponding to each level.
[0099] In the embodiment of the present application, the first thread in the running state may be referred to as the second thread.
[0100] In some embodiments, a user may click on a first application displayed on an electronic device to input an instruction to the electronic device to launch the first application. In response to the instruction input by the user to launch the first application, the electronic device launches the first application and runs at least one second thread to support the execution of the first application.
[0101] When the electronic device detects that a second thread corresponding to the first application is running, it can obtain the rank of the second thread. Based on the rank of the second thread, the electronic device can determine scheduling parameters for allocating resources to the second thread. The electronic device then allocates resources to the corresponding second thread based on the determined scheduling parameters.
[0102] For example, the electronic device detects that the second thread 1, the second thread 2, and the second thread 3 have all started running. The electronic device obtains that the level corresponding to the second thread 1 is level 3 in Table 1. The levels corresponding to the second threads 2 and 3 are level 1 in Table 1. The electronic device can call the scheduling parameters corresponding to level 3 in Table 1 and allocate resources to the second thread 1 based on the scheduling parameters. Furthermore, the electronic device can call the scheduling parameters corresponding to level 1 in Table 1 and allocate resources to the second threads 2 and 3 based on the scheduling parameters.
[0103] S304: When the running state of the first application program changes, determining a scheduling parameter corresponding to the level of each second thread based on the level of each second thread.
[0104] The running state of the first application is a first state before the change occurs and a second state after the change occurs, and the first state is different from the second state.
[0105] Exemplarily, the running state of the first application may include a foreground state and a background state. Referring to Figure 5, when the running state of the first application 500 is the foreground state, the display screen of the electronic device may display the application interface 501 of the first application. The application interface 501 includes a close control 502 for closing the application interface 501. The user can input a switching instruction for instructing to switch the running state of the first application 500 to the electronic device by clicking the close control 502. After the electronic device detects the user's click operation on the close control 502, that is, after the electronic device receives the switching instruction input by the user, it can close the application interface 501 and switch the running state of the application from the foreground state to the background state.
[0106] It is understandable that the foreground state and background state described above are merely examples of the operating state of the first application in the embodiments of the present application. The operating state of the first application may also include various states such as game state, standby state, chat state, and energy-saving state. The embodiments of the present application do not limit the operating state of the first application.
[0107] In some embodiments, the first application stores the ranks corresponding to each first thread and the scheduling parameters corresponding to each rank. When the running state of the first application changes, the first application can determine the scheduling parameters corresponding to the ranks of each second thread based on the first state, the second state, and the ranks corresponding to each second thread. The first application can then request from the electronic device to increase or decrease the resources allocated to each second thread based on the determined scheduling parameters corresponding to the ranks of each second thread.
[0108] For example, referring to Figure 6, when the first application 600 is an application for playing music, the first application 600 corresponds to a thread 610 for executing the playback service (corresponding to the seventh level), a thread 620 for displaying playback special effects (corresponding to the third level), and a thread 630 for displaying lyrics (corresponding to the first level).
[0109] When the first application is running in the foreground, threads 610, 620, and 630 are all executed. When the first application switches from the foreground state to the background state, the first application can adjust the parameters corresponding to the seventh level, the third level, and the first level respectively based on the foreground state, the background state, and the levels (seventh level, third level, and first level) of threads 610, 620, and 630.
[0110] In this example, since the electronic device will not display the playback characteristics and lyrics when the first application is in the background state. Therefore, in order to save the power consumption of the electronic device, the scheduling parameters corresponding to the third level and the first level can be adjusted to reduce the resources allocated to thread 620 and thread 630. Since the electronic device will still play music when the first application is in the background state, in order to improve the playback effect of the music, the scheduling parameters corresponding to the seventh level can also be adjusted to increase the resources allocated to the thread 610. Since the resources allocated to thread 620 and thread 630 are reduced and the resources allocated to thread 610 are increased, the total resources allocated to thread 610, thread 620 and thread 630 can be reduced or increased compared to before the running state of the first application changes.
[0111] In this example, in order to further reduce the power consumption of the electronic device, the scheduling parameters corresponding to the seventh level, the third level, and the first level can be adjusted, so that the resources allocated to thread 610, thread 620, and thread 630 are all reduced. Among them, the resources reduced by thread 610, thread 620, and thread 630 can be the same. It is also possible to proportionally reduce the resources allocated to thread 610, thread 620, and thread 630 based on the levels corresponding to thread 610, thread 620, and thread 630 respectively. For example, thread 610 has the highest level and its allocated resources are reduced by 10%. Thread 620 has a lower level than thread 610 and its allocated resources are reduced by 20%. Thread 630 has a lower level than thread 620 and its allocated resources are reduced by 30%. The embodiment of the present application does not limit the proportion of the resources allocated to each thread to be reduced.
[0112] Moreover, since the resources allocated to threads 610, 620 and 630 are all reduced, the total resources allocated to threads 610, 620 and 630 are also reduced compared to before the running state of the first application program changes, which can save power consumption and resource loss for the electronic device.
[0113] In some embodiments, the electronic device stores the level corresponding to each first thread and the scheduling parameters corresponding to each level. The electronic device can monitor in real time whether the running state of the first application has changed. When the electronic device detects a change in the running state of the first application, it can determine the scheduling parameters corresponding to the level of each second thread based on the first state, the second state, and the level corresponding to each second thread. The electronic device can then increase or decrease the resources allocated to each second thread based on the scheduling parameters corresponding to the determined level of each second thread.
[0114] The electronic device may determine the scheduling parameters corresponding to the levels of the second threads by referring to the manner in which the first application determines the scheduling parameters corresponding to the levels of the second threads in the aforementioned embodiment, which will not be elaborated here.
[0115] S305: When at least one third thread in each second thread is finished running, obtain first running data.
[0116] The first running data is associated with the third thread, and the first running data includes running data of the first application during the current running of the third thread.
[0117] Exemplarily, when the third thread is a thread related to the screen display of the first application, the first operating data may include the frame loss rate of the first application during the operation of the third thread. When the third thread is a thread related to the interaction between the first application and the user, the first operating data may include the response delay data of the first application during the operation of the third thread. When the third thread is a thread related to the compression / decompression function of the first application, the first operating data may include the compression rate / decompression rate of the target file by the first application during the operation of the third thread. The embodiment of the present application does not limit the specific content included in the first operating data.
[0118] S306: Determine whether to adjust the scheduling parameter corresponding to the level of the third thread based on the first running data and the second running data.
[0119] The second running data is associated with the third thread, and the second running data is obtained based on running data of the first application during the historical running of the third thread.
[0120] In some embodiments, each time the third thread finishes executing, it can obtain the execution data of the first application during the execution of the third thread. The execution data can be stored in a performance data file corresponding to the first application. Second execution data can be generated based on the execution data stored in the performance data file.
[0121] The second operating data can be obtained based on all operating data stored in the performance data file. The second operating data can also be obtained based on the operating data stored in the performance data file for the most recent time or times (for example, the most recent time or the most recent five times, which can also be referred to as a preset period). Alternatively, the second operating data can also be obtained based on a preset number of (for example, 5 randomly selected) operating data randomly extracted from the performance data file. This is not limited in the embodiments of the present application.
[0122] In some embodiments, a first value may be obtained by performing normalization processing on the first running data. A second value may be obtained by performing normalization processing on the second running data. A ratio of the first value to the second value may be determined as a third value. Based on the third value, a determination may be made as to whether to adjust a scheduling parameter corresponding to the rank of the second thread.
[0123] In some embodiments, when the third value is greater than or equal to a preset fourth value, the scheduling parameter corresponding to the level of the third thread may be adjusted to increase the resource supply to the third thread when the third thread is running. Furthermore, the larger the third value, the faster the resource supply to the third thread when the third thread is running.
[0124] In some embodiments, when the third value is greater than the preset fifth value and less than the fourth value, the scheduling parameters corresponding to the levels of the third threads may not be adjusted.
[0125] In some embodiments, when the third value is less than or equal to the fifth value, the scheduling parameter corresponding to the level of the third thread may be adjusted to reduce the resource supply to the third thread when the third thread is running. Furthermore, the smaller the third value, the slower the resource supply to the third thread when the third thread is running.
[0126] The following takes the example of the first application being an application for playing videos to specifically describe how to determine the first operating data, the second operating data, and how to determine whether to adjust the scheduling parameters corresponding to the levels of each third thread corresponding to the first application.
[0127] The third thread is a thread related to implementing the screen display of the first application. When the third thread finishes running, the first operating data corresponding to the first application can be obtained. The first operating data at least includes the frame loss rate of the first application during the display of the screen. Afterwards, the second operating data can be generated based on the operating data stored in the performance data file. For example, the second operating data includes the frame loss rate of the first application during the display of the screen for the last ten times obtained from the performance storage file. By performing normalization processing on the first operating data and the second operating data respectively, the first value and the second value can be obtained. Based on the ratio of the first value and the second value, the third value can be obtained.
[0128] Referring to Figure 7 , when the third value is greater than or equal to 110%, it indicates that the frame loss rate of the first application displayed during the current execution of the third thread is significantly higher than the frame loss rate of the first application displayed during the third thread's previous execution. Therefore, it is necessary to adjust the scheduling parameters corresponding to the third thread's level to increase the resource supply to the third thread while it is running. Furthermore, the larger the third value, the faster the resource supply to the third thread.
[0129] When the third value is between 85% and 110%, it indicates that the frame loss rate of the first application displayed during the current execution of the third thread is much similar to the frame loss rate of the first application displayed during the previous execution of the third thread. Therefore, the scheduling parameters corresponding to the levels of the third threads do not need to be adjusted.
[0130] When the third value is less than or equal to 85%, it indicates that the frame loss rate of the first application's display screen during the current execution of the third thread is much lower than the frame loss rate of the first application's display screen during the third thread's previous execution. Therefore, the scheduling parameters corresponding to the third thread's level can be adjusted to reduce the resource supply to the third thread when the third thread is running. Furthermore, the smaller the third value, the slower the resource supply to the third thread.
[0131] In the embodiment of the present application, the resource scheduling method provided by the present application is described by taking the first application as an example. In actual application, the resource scheduling method provided by the embodiment of the present application can also be applied to a second application, a third application, and more applications that are different from the first application. When the resource scheduling method provided by the embodiment of the present application is applied to the second application, a level can also be set for each thread corresponding to the second application and corresponding scheduling parameters can be set for each level. Among them, the level set for each thread corresponding to the second application and the scheduling parameters set for each level can be the same as those of the first application, and can also be different from those of the first application.
[0132] For example, the first application corresponds to 7 threads, each of which corresponds to levels 1 to 7 as shown in Table 1. The second application may also correspond to 7 threads, each of which may also correspond to levels 1 to 7. Although the level 1 for the threads in the first application is the same as the level 1 for the threads in the second application, the scheduling parameters corresponding to these two levels 1 may be the same or different. This is not limited in the present embodiment.
[0133] The embodiment of the present application provides a resource scheduling method and electronic device, which can allocate resources to each first thread included in the first application at the granularity of each first thread by setting a level for each first thread corresponding to the first application and setting the scheduling parameters corresponding to each level. When the running state of the first application changes, the level of the second thread in the running state in each first thread can be kept unchanged, and the scheduling parameters corresponding to each level can be adjusted, so as to increase or decrease the allocated resources for each second thread differently. When the third thread in each second thread has finished running, it can be determined whether to adjust the scheduling parameters corresponding to the level of the third thread based on the first running data and the second running data corresponding to the first application during the current running of the third thread, so as to improve the accuracy of the scheduling parameters. The second running data is obtained based on the running data corresponding to the first application during the historical running of the third thread.
[0134] In some schemes, multiple embodiments of the present application can be combined and the combined scheme can be implemented. Optionally, some operations in the process of each method embodiment are optionally combined, and / or the order of some operations is optionally changed. In addition, the execution order between the steps of each process is only exemplary and does not constitute a limitation on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be performed. Ordinary technicians in this field will think of many ways to reorder the operations described herein. In addition, it should be noted that the process details involved in a certain embodiment of this article are also applicable to other embodiments in a similar manner, or different embodiments can be used in combination.
[0135] Furthermore, some steps in the method embodiments may be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiments.
[0136] Furthermore, the various method embodiments may be implemented separately or in combination.
[0137] It is understandable that in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of this application.
[0138] This embodiment can divide the electronic device into functional modules based on the above-mentioned method example. For example, each functional module can be divided according to its function, or two or more functions can be integrated into a single processing module. The above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the module division in this embodiment is illustrative and only represents a logical functional division. In actual implementation, other division methods may be used.
[0139] By way of example, an embodiment of the present application further provides a resource scheduling system, as shown in FIG8 , comprising an application layer 801, a framework layer 802, a kernel layer 803, and a resource layer 804. The application layer may include multiple applications, such as application 8011, application 8012, and application 8013. Application layer 801 may also include a scene recognition module 8010. Scene recognition module 8010 is used to monitor the operating status of each application in the application layer.
[0140] In some embodiments, the scene recognition module 8010 may also be located in the kernel layer 803. In other embodiments, the scene recognition module 8010 may exist in both the application layer 801 and the kernel layer 803.
[0141] The framework layer 802 includes a level setting module 8021 and a parameter setting module 8022. The level setting module 8021 can set the level of the thread corresponding to each application program, and the parameter setting module 8022 can set the scheduling parameters corresponding to each level.
[0142] The kernel layer 803 includes a parameter adjustment module 8031, a scheduling module 8032, and a data storage module 8033. The resource layer 804 includes at least one hardware resource (eg, hardware resource 8041, hardware resource 8042, and hardware resource 8043 in FIG8).
[0143] The parameter adjustment module 8031 is used to adjust the scheduling parameters corresponding to each level. The scheduling module 8032 is used to allocate hardware resources to the threads of each application based on the corresponding scheduling parameters. The data storage module 8033 is used to store the running data of each application during the running of each thread.
[0144] The resource scheduling system shown in FIG8 can execute all steps of the resource scheduling method provided in the embodiment of the present application.
[0145] For example, in conjunction with the system shown in FIG8 , the rank of each thread corresponding to application 8011 can be pre-set using rank setting module 8021, and the scheduling parameters corresponding to each rank can be set using parameter setting module 8022. When application 8011 is executed, at least one thread corresponding to application 8011 also begins to execute. Scheduling module 8032 can obtain the rank and scheduling parameters corresponding to the thread, and allocate hardware resources to the thread based on the obtained scheduling parameters.
[0146] When the scene recognition module 8010 in the application layer 801 and / or the scene recognition module 8010 in the kernel layer 803 detects a change in the running state of the application 8011, the parameter adjustment module 8031 can adjust the scheduling parameters corresponding to the thread level. The scheduling module 8032 can then adjust the hardware resources allocated to the thread based on the adjusted scheduling parameters.
[0147] After the thread completes execution, the parameter adjustment module 8031 can obtain first execution data corresponding to the application 8011 during the current execution of the thread, and obtain second execution data based on the execution data corresponding to the application 8011 during the historical execution of the thread obtained from the data storage module 8033. Based on the first and second execution data, the parameter adjustment module 8031 can determine whether to adjust the scheduling parameters corresponding to the thread's level.
[0148] Moreover, after the thread is finished running, the first running data corresponding to the application 8011 during the running process of the thread can also be stored in the data storage module 8033.
[0149] An embodiment of the present application further provides an electronic device, as shown in FIG9 , which may include one or more processors 901 , a memory 902 , and a communication interface 903 .
[0150] The memory 902 and the communication interface 903 are coupled to the processor 901. For example, the memory 902, the communication interface 903 and the processor 901 may be coupled together via a bus 904.
[0151] The communication interface 903 is used to transmit data with other devices. The memory 902 stores computer program code. The computer program code includes computer instructions. When the computer instructions are executed by the processor 901, the electronic device executes the resource scheduling method in the embodiment of the present application.
[0152] Among them, the processor 901 can be a processor or controller, for example, a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It can implement or execute the various exemplary logic blocks, modules and circuits described in conjunction with the present disclosure. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like. The processor can be used to support the electronic device to execute the method steps provided in the above embodiments. For example, the processor can be used to support the electronic device to execute S301-S306 in Figure 3.
[0153] The bus 904 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus 904 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, FIG9 shows only one thick line, but this does not imply that there is only one bus or only one type of bus.
[0154] An embodiment of the present application also provides a chip system, including: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the chip system implements the method in any of the above method embodiments.
[0155] Optionally, there may be one or more processors in the chip system. The processor may be implemented in hardware or software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0156] Optionally, the memory in the chip system may be one or more. The memory may be integrated with the processor or may be provided separately from the processor, which is not limited in the embodiments of the present application. For example, the memory may be a non-transient processor, such as a read-only memory (ROM), which may be integrated with the processor on the same chip or provided on different chips. The embodiments of the present application do not specifically limit the type of memory or the configuration of the memory and the processor.
[0157] Exemplarily, the chip system may be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.
[0158] It should be understood that each step in the above method embodiment can be completed by hardware integrated logic circuits in a processor or by software instructions. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.
[0159] An embodiment of the present application further provides a computer-readable storage medium, in which computer program code is stored. When the processor executes the computer program code, the electronic device executes the relevant method steps in the method embodiment.
[0160] An embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the relevant method steps in the above method embodiment.
[0161] In addition, embodiments of the present application further provide a device. Specifically, the device may be a component or module, and may include one or more processors and a memory connected to each other. The memory is configured to store a computer program. When the computer program is executed by one or more processors, the device performs the scenario configuration method described in each of the above method embodiments.
[0162] The apparatus, computer-readable storage medium, computer program product, or chip provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0163] The steps of the method or algorithm described in conjunction with the disclosure of the embodiments of the present application can be implemented in hardware or by executing software instructions by a processor. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, read-only compact discs (CD-ROMs), or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC).
[0164] Through the description of the above embodiments, those skilled in the art will clearly understand that for the sake of convenience and brevity, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed; that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working processes of the above-mentioned systems, devices, and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0165] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
Claims
1. A resource scheduling method, characterized in that: include: determining a level of at least one first thread when detecting that the running state of the first application is switched from the first state to the second state; The at least one first thread is used to run the first application; The level is a relative level of each of the first threads corresponding to the first application; Determining, according to the level of the first thread, a scheduling parameter corresponding to each level; The scheduling parameters are used to allocate resources to the first threads with corresponding levels; different levels correspond to different scheduling parameters; Allocate resources to the first thread according to the scheduling parameters corresponding to the level of the first thread.
2. The method according to claim 1, characterized in that The first thread is a thread in a running state corresponding to the first application.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: When the first thread ends running, first running data is acquired; the first running data is associated with the first thread, and the first running data includes running data of the first application during the current running of the first thread; Based on the first operating data and the second operating data, the scheduling parameters corresponding to the level of the first thread are adjusted; the second operating data is associated with the first thread, and the second operating data is obtained based on the operating data of the first application during the historical operation of the first thread.
4. The method according to claim 3, characterized in that The adjusting, based on the first running data and the second running data, the scheduling parameter corresponding to the level of the first thread includes: Determining whether it is necessary to reallocate resources to the first thread based on the first running data and the second running data; When it is determined that resources need to be reallocated to the first thread, a scheduling parameter corresponding to the level of the first thread is adjusted.
5. The method according to claim 3 or 4, characterized in that: The adjusting, based on the first running data and the second running data, the scheduling parameter corresponding to the level of the first thread includes: Performing normalization processing on the first operation data to obtain a first value; performing normalization processing on the second operation data to obtain a second value; determining a ratio of the first value to the second value as a third value; When the third value is greater than or equal to the fourth value, or when the third value is less than or equal to the fifth value, the scheduling parameter corresponding to the level of the first thread is adjusted.
6. The method according to any one of claims 1 to 5, characterized in that: Before determining the level of at least one first thread when detecting that the running state of the first application program is switched from the first state to the second state, the method further includes: Receive user input for setting operations; In response to the setting operation, the level of the at least one first thread corresponding to the first application and the scheduling parameters corresponding to the level of the at least one first thread are set.
7. The method according to any one of claims 1 to 6, characterized in that: In the case that the first application is a third-party application, the level of the first thread corresponding to the first application is less than a level threshold.
8. An electronic device, characterized in that: include: A memory and one or more processors; the memory is coupled to the processor; wherein the memory stores computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-7.
9. A computer storage medium comprising computer instructions, characterized in that: When the computer instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 7.
10. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Resource scheduling method and electronic equipment
CN118626218A
Resource allocation method and device, terminal and storage medium
CN109032793A
Resource allocation method and device, mobile terminal and computer readable storage medium
CN109992400A
Resource allocation method and device, storage medium and electronic equipment
CN111831433A
Resources scheduling method and device in cloud desktop, equipment and storage medium
CN114090258A
