A resource scheduling method and apparatus for terminal devices

By dynamically adjusting the priority of critical threads and resource allocation strategies of the floating window application, the problem of the floating window not running smoothly in multi-window parallel scenarios on terminal devices was solved, and the synchronous and smooth operation of the floating window and the main window application was achieved.

CN120234127BActive Publication Date: 2026-11-10HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311779953.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2026-11-10
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

In multi-window parallel scenarios on terminal devices, applications within the floating window may not run smoothly, resulting in a laggy and poor user experience.

Method used

By detecting the window information of the floating window, the priority of key threads and resource allocation strategies of the floating window application are dynamically adjusted, including increasing CPU frequency, migrating to medium or large cores, and adjusting frame rate, in order to optimize resource scheduling of applications within the floating window.

Benefits of technology

It improves the smoothness and user experience of floating window applications, ensures that the performance of the main window application is not affected, and improves resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234127B_ABST
    Figure CN120234127B_ABST
Patent Text Reader

Abstract

This application provides a resource scheduling method and apparatus for a terminal device. The method detects when an application starts or switches to a floating window mode, and increases the scheduling priority of the application's critical threads, thereby accelerating the execution of critical threads within the floating window. Furthermore, it statistically analyzes the load of critical threads in the application running within the floating window (hereinafter referred to as the floating window application), and dynamically adjusts resource scheduling strategies based on the load of the application's critical threads (such as increasing CPU frequency, selecting medium or large cores to run critical threads), thereby increasing the CPU resource supply to the application running within the floating window, improving the smoothness of the floating window application's operation, and ultimately enhancing the user's experience with the floating window mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a resource scheduling method and apparatus for a terminal device. Background Technology

[0002] As terminal device technology continues to develop, terminal devices support parallel operation scenarios. For example, a user can run another application, such as shopping, news, or live streaming, while simultaneously holding a WeChat® video call within a small window. In this case, the WeChat video window is the top-level window, while the other application's interface is at the bottom. Similarly, a user can browse another application, such as shopping, WeChat, or video, within a live streaming window. These scenarios involve multiple applications running in the foreground and visible to the user. In such scenarios, it's crucial to ensure the smoothness of each application running in the foreground; otherwise, it can lead to lag and a poor user experience. Summary of the Invention

[0003] In view of this, this application provides a resource scheduling method and apparatus for terminal devices to solve at least some of the above-mentioned problems, and the disclosed technical solution is as follows:

[0004] Firstly, this application provides a resource scheduling method for a terminal device, comprising: when a floating window is detected, acquiring window information of the floating window, including window type, window state information, and key thread information of the application running within the floating window; when it is determined that the floating window is currently visible based on the window state information, increasing the priority of the key thread corresponding to the floating window, and calculating the load rate of the key thread; when the load rate of the key thread is greater than or equal to a first threshold, optimizing the resource supply strategy of the key thread to accelerate the resource supply of the application running within the floating window; when the load rate of the key thread drops from greater than or equal to the first threshold to less than or equal to a second threshold, canceling the resource supply strategy of the key thread. It is evident that this solution increases the scheduling priority of the floating window application when it detects the start or switch to floating window mode, thereby accelerating the execution of the application. Furthermore, it dynamically schedules CPU resources based on the calculated key thread load of the floating window application (e.g., increasing CPU frequency, selecting medium or large cores to run key threads), thereby increasing the CPU resource supply of the floating window application, thus improving the smoothness of the floating window application's operation, and ultimately improving the user's experience with the floating window mode.

[0005] Secondly, this application also provides a resource scheduling method for a terminal device. The terminal device stores resource scheduling configuration information matching different types of applications. The method includes: when a floating window is detected, obtaining the window information of the floating window, including window type, window state information, application information running within the floating window, and key thread information; when it is determined that the floating window is currently visible based on the window state information, obtaining the matching resource scheduling configuration information based on the information of the application running within the floating window, and increasing the priority of the key thread corresponding to the floating window; when the execution of a key thread is detected, adjusting the resource supply of the application running within the floating window according to the resource scheduling configuration information. It is evident that this solution can configure different resource scheduling configuration information for different types of applications. Thus, when a configured application is detected running within a floating window, the resource scheduling configuration information matching that application is directly read, and when the key thread of that application is executed, the resource supply of that application is adjusted according to the matching resource scheduling configuration information to accelerate the running speed and smoothness of the application running within the floating window.

[0006] In one possible implementation of the first aspect, when the load rate of a critical thread is greater than or equal to a first threshold, the resource allocation strategy for the critical thread is optimized, including: increasing the CPU frequency corresponding to the critical thread from a first frequency to a second frequency, migrating the critical thread to a medium or large CPU core, and reducing the frame rate of the floating window from a first frame rate to a second frame rate. In this way, when a high load rate is detected in the application within the floating window, the resource scheduling strategy is automatically optimized for that application, such as increasing the CPU frequency or migrating to a medium or large core, thereby ensuring the performance of the application within the floating window. Furthermore, reducing the frame rate of the floating window can reduce the resources required by the floating window, further improving the smoothness and performance of the application within the floating window.

[0007] In one possible implementation of the first aspect, when the load rate of a critical thread drops from greater than or equal to a first threshold to less than or equal to a second threshold, the resource allocation strategy for the critical thread is canceled. This includes: when the load rate of the critical thread drops from greater than or equal to the first threshold to less than the second threshold, reducing the CPU frequency corresponding to the critical thread from the second frequency to the first frequency, migrating the critical thread to its original CPU core, and increasing the frame rate of the floating window from the second frame rate to the second frame rate. In this way, when the load rate of the floating window application drops below a certain threshold, the floating window application typically does not experience sluggish performance. Therefore, the resource scheduling strategy for this application can be canceled to allocate resources to other applications, improving resource utilization.

[0008] In one possible implementation of the first or second aspect, the method further includes: restoring the priority of the critical thread when the completion of the frame drawing in the critical thread is detected. Thus, by increasing the scheduling priority of the critical thread of the floating window application only during the execution of the frame drawing task, it is possible to ensure that the frame drawing process of the floating window application does not experience any lag. Simultaneously, restoring the original scheduling priority after the floating window application completes the frame drawing (i.e., without needing to guarantee application performance) allows tasks of other applications to be executed first, improving the performance of other applications and increasing resource utilization.

[0009] In one possible implementation of the first or second aspect, a VIP scheduling queue is added within the terminal device; the priority of the critical thread corresponding to the floating window is increased, including: migrating the critical thread corresponding to the floating window from the CFS scheduling queue to the VIP scheduling queue, wherein the priority of the VIP scheduling queue is higher than that of the CFS scheduling queue.

[0010] In one possible implementation of the first or second aspect, the floating window includes a third-party floating window, which is a floating window built into a third-party application. Detecting the floating window includes: determining that the third-party floating window pops up when a page is detected to be created and the window type of the creating page is a preset floating window type identifier; and determining that the third-party floating window exits when a page is detected to be destroyed and the window type of the destroyed page is a preset floating window type identifier. It is evident that this solution can detect the pop-up and exit of the third-party floating window, ensuring accurate execution of subsequent processes.

[0011] In one possible implementation of the first or second aspect, detecting a floating window includes: determining that a floating window is launched when an Activity task is detected to be switched to the foreground. The floating window includes third-party floating windows and custom floating windows, where a custom floating window is a floating window developed by the terminal device for the application. Therefore, this solution can detect the launch of both third-party and custom floating windows, thus allowing the solution to be executed when the floating window launches, improving the smoothness of the floating window application's operation.

[0012] In one possible implementation of the first or second aspect, after optimizing the resource allocation strategy for the critical thread when the load rate of the critical thread is greater than or equal to a first threshold, the method further includes: when it is detected that the application running in the main window is a preset type application, canceling the resource allocation strategy corresponding to the floating window application. The preset type applications include at least game applications and live video streaming applications. Thus, when it is determined that the application running in the main window is a preset type application, canceling the resource allocation strategy for the floating window application effectively disables performance optimization for the floating window application, thereby ensuring the performance of the application running in the main window.

[0013] In one possible implementation of the first or second aspect, the method further includes: accelerating the release of resources allocated to the critical thread of the floating window when the floating window is closed based on window state information.

[0014] In one possible implementation of the second aspect, the resource scheduling configuration information includes: configuration information corresponding to CPU frequency, CPU cores, and frame rate.

[0015] Thirdly, this application also provides a terminal device, which includes: one or more processors, a memory, and a touch screen; the memory is used to store program code; the processor is used to run the program code, enabling the terminal device to implement the resource scheduling method of the terminal device as described in any of the first aspects.

[0016] Fourthly, this application also provides a chip system, including: at least one processor and an interface, the interface being used to receive code instructions and transmit them to the at least one processor; the at least one processor executes the code instructions to implement the resource scheduling method of the terminal device according to any one of the first aspects.

[0017] Fifthly, this application also provides a computer-readable storage medium having instructions stored thereon, which, when executed on an electronic device, cause the electronic device to perform the resource scheduling method for a terminal device as described in any of the first aspects.

[0018] Sixthly, this application also provides a computer program product having stored thereon that, when executed on an electronic device, causes the electronic device to implement the resource scheduling method for a terminal device as described in any of the first aspects. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of a multi-window parallel scenario;

[0020] Figure 2 This is a schematic diagram of another multi-window parallel scenario;

[0021] Figure 3 This is a schematic diagram of a multi-window parallel scenario provided in an embodiment of this application;

[0022] Figure 4 This is a schematic diagram of another multi-window parallel scenario provided in an embodiment of this application;

[0023] Figure 5 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application;

[0024] Figure 6 This is a schematic diagram of the software architecture of a terminal device provided in an embodiment of this application;

[0025] Figure 7This is a flowchart of a resource scheduling method for a terminal device provided in an embodiment of this application;

[0026] Figure 8 This is a schematic diagram of dynamically scheduled resources provided in an embodiment of this application;

[0027] Figure 9 This is a flowchart of another resource scheduling method for terminal devices provided in the embodiments of this application. Detailed Implementation

[0028] The terms "first," "second," and "third," etc., used in this application specification, claims, and drawings are used to distinguish different objects, not to limit a specific order.

[0029] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0030] Please see Figure 1 The diagram illustrates a multi-window parallel scenario, using a mobile phone in a multi-window parallel scenario as an example, and also using a scenario where a user watches other video applications in a WeChat live streaming window as an example.

[0031] In one exemplary embodiment, when a user is watching a WeChat live stream in full screen, they can operate the button on the interface to switch to a small window or directly swipe up from the bottom of the screen. At this time, the WeChat live stream window exits the full-screen window and switches to a small window that floats on the desktop interface.

[0032] like Figure 1 As shown in (1), the floating window 102 is located above the desktop interface 101. The floating window 102 includes a video playback area 103 and operation buttons located below the video playback window, such as a pause button 104 and a close button 105. During the playback of WeChat live video within the floating window 102, after receiving the user's click on the video APP icon 106, it jumps to, for example,... Figure 1 The interface shown in (2) is as follows.

[0033] like Figure 1As shown in (2), the floating window 102 is located at the top layer, and the bottom layer is the interface 201 of the video APP, which includes a video playback area 202 and a comment area 203. In related technologies, during the cold start and swiping processes of the video APP, the application tasks of the floating window 102 do not receive sufficient CPU resources. For example, in this example, the UI tasks and rendering tasks of WeChat have a large number of runnable threads that do not receive CPU resources and are waiting to be executed, resulting in the floating window 102 experiencing playback stuttering.

[0034] In another scenario, when a user launches another application, such as a video app, while playing a game, the video app will enter a small window running mode.

[0035] like Figure 2 As shown in (1), the mobile phone is currently running a game app, displaying the game interface 301 in full screen. While the mobile phone is running the game app, the user can bring up the application quick launch panel 302 by swiping from the edge of the screen to the center. The quick launch panel 302 includes icons of at least some of the applications installed on the terminal device, such as the browser app icon 303, the music app icon 304, and the video app icon 305. The user can click on the icon to run the clicked application in the floating window.

[0036] For example, in this example, after the terminal device receives a 305 error message indicating that the user clicked the video app icon, it redirects to... Figure 2 The interface shown in (2) includes a game app interface 301 at the bottom layer and a floating window 306 above the interface 301. The floating window 306 displays the video app interface, which may include a video playback area 307 and a comment area 308. In related technologies, insufficient CPU resources are not available during the video startup process, resulting in slow loading of the video app interface and video.

[0037] For example, when a terminal device is running a game app, it receives a WeChat video call invitation. After answering, the WeChat video window pops up slowly. These are just a few examples, which will not be described in detail here.

[0038] To address the issue of lag and stuttering in applications running within floating windows on terminal devices in multi-window parallel operation scenarios, this application provides a resource scheduling method for terminal devices. This method detects when an application starts or switches to floating window mode, and increases the scheduling priority of the application's critical threads, thereby accelerating the execution of these critical threads within the floating window. For example, if the critical thread is in a waiting state, its waiting time can be reduced; if it is already executing, its execution time can be shortened. Furthermore, the method analyzes the load of critical threads in the application running within the floating window (hereinafter referred to as the floating window application) and dynamically schedules CPU resources based on this load (e.g., increasing CPU frequency, selecting medium or large cores to run critical threads), thereby increasing the CPU resource supply to the floating window application, improving its smoothness, and ultimately enhancing the user experience with the floating window mode.

[0039] For example, after applying the resource scheduling method for the aforementioned terminal devices, such as Figure 3 As shown in (1), during the process of displaying the floating window 102 of WeChat Live on the top layer of the desktop interface 101, the video APP is launched and jumps to Figure 3 As shown in (2), the WeChat live stream plays smoothly in the video playback area 103 of the floating window 102, and the video plays smoothly in the video playback area 202 of the video app. That is, after applying the resource scheduling method of the terminal device provided in this application embodiment, both the application running in the floating window and the application running in the main window run smoothly.

[0040] For example, Figure 4 In the scenario shown, such as Figure 4 As shown in (1), while the game APP is running in the main window, the video APP is also launched. For example, the video APP can be launched through the application shortcut launch panel 302, which jumps to Figure 4 The interface shown in (2) is as follows. Figure 4 As shown in (2), the game app in the main window runs smoothly, and the video app in the floating window 306 also runs smoothly. That is, after applying the resource scheduling method of the terminal device provided in this application embodiment, both the application running in the floating window and the application running in the main window run smoothly.

[0041] In some embodiments, the terminal device may be a mobile phone (e.g., Figure 1As shown in the diagram, the terminal device can be a tablet computer, desktop computer, laptop computer, ultra-mobile personal computer (UMPC), handheld computer, netbook, personal digital assistant (PDA), wearable electronic device, smartwatch, etc. In this embodiment, the terminal device structure can be as follows: Figure 5 As shown,

[0042] like Figure 5 As shown, the terminal device may include a processor 110, a memory 120, a touch screen 130, and an audio module 140. The audio module 140 may include a speaker 141, a receiver 142, a microphone 143, and a headphone jack 144.

[0043] The memory 120 stores computer-executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the terminal device by running the instructions stored in the internal memory 120. For example, in this embodiment, the processor 110 can identify the type of the floating window by executing the instructions stored in the internal memory 120 and adjust resources according to the critical threads of the application corresponding to the floating window.

[0044] The touchscreen 130 may include a touch panel and a display screen. The touch panel is used to detect touch operations applied to or near it and to pass the detected touch operations to a processor to determine the type of touch event. The display screen is used to display images, videos, etc., and to provide visual output related to touch operations.

[0045] The terminal device can implement audio functions such as music playback and recording through an audio module 140, a speaker 141, a receiver 142, a microphone 143, a headphone jack 144, and an application processor.

[0046] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the terminal device. In other embodiments, the terminal device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0047] Furthermore, a smart operating system runs on top of the aforementioned components. This application uses the layered architecture of the Android® system as an example to exemplify the software structure of the terminal device.

[0048] Figure 6 This is a software structure block diagram of a terminal device according to an embodiment of this application.

[0049] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the system libraries, and the kernel layer.

[0050] The application layer can include a series of application packages. For example... Figure 6 As shown, the application package can include applications such as WeChat, games, and videos.

[0051] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example... Figure 6 As shown, the application framework layer may include a window manager (WindowManagerService, WMS) and an activity management service (ActivityManagerService, AMS).

[0052] WMS is used to manage window applications. The window manager can obtain the screen size, determine if a status bar is present, lock the screen, and capture the screen, etc. In this embodiment, WMS includes window recognition to identify window types, such as floating windows of third-party applications (e.g., Figure 1 (1) The floating window 102 shown is the floating window of the WeChat application) and custom floating windows (such as Figure 2 (2) The floating window 306 shown is a custom floating window developed by the terminal device manufacturer for the application, etc.

[0053] The main function of AMS is to manage the lifecycle of applications and the interactions between applications.

[0054] The system library may include multiple functional modules. For example, in this embodiment, the system library may include a message broker module, which is used to receive window information issued by window identification and pass it to the kernel layer through system calls.

[0055] The kernel layer is the layer between hardware and software. In this embodiment, the kernel layer includes a multi-window scheduler, message queues, load balancing modules, etc.

[0056] The multi-window scheduler is used to accelerate window applications. It receives and parses window information and formulates corresponding scheduling strategies based on information such as the load of the floating window application to improve the running speed of the floating window application.

[0057] In this embodiment, the multi-window scheduler may include modules such as message processing, task selection, frequency adjustment, task core selection, and frame rate adjustment.

[0058] The message processing module is used to parse the window information sent by the message broker module to obtain key thread information of the application running in the floating window.

[0059] The task selection module is used to select tasks from the task queue for execution according to certain rules.

[0060] The frequency adjustment module is used to dynamically adjust the CPU's operating frequency based on the load of critical threads, and to dynamically adjust the number of times the thermal limit is exceeded based on the CPU's operating temperature. For example, it can be used to increase the CPU frequency of a floating window application.

[0061] The task core selection module is used to ensure that applications running within the floating window run on the middle core of the CPU, while other applications run on other CPU cores.

[0062] The frame rate adjustment module is used to adjust the frame rate of the floating window application, such as reducing or increasing the frame rate of the floating window. For example, the original frame rate of 60 frames can be limited to 30 frames, or the frame rate can be increased from 30 frames to 60 frames.

[0063] Thread message queues can include RT (Real-Time) scheduling queues, CFS (Completely Fair Scheduler) scheduling queues, and VIP (Virtual VIP) scheduling queues. The priority of each queue, from highest to lowest, is: RT scheduling queue > VIP scheduling queue > CFS scheduling queue. All three queues are used to store threads that are currently executing or waiting to be executed.

[0064] The load balancing module is used to track and analyze CPU load, and is used for load balancing such as task migration (e.g., migrating from small cores to medium or large cores) and adjusting CPU frequency.

[0065] The following will combine Figure 7 This application provides a detailed description of the resource scheduling method for terminal devices according to embodiments. This method is applied within the terminal device. For example... Figure 7 As shown, the method may include the following steps:

[0066] S101, when WMS detects a window switch, it identifies the window type.

[0067] In one exemplary embodiment, such as Figure 6 As shown, WMS includes a window recognition module, which is mainly used to perform window type detection when switching windows, such as recognizing third-party floating windows and custom floating windows.

[0068] Third-party floating windows refer to the floating window mode built into third-party applications, such as the floating windows built into applications like WeChat, Taobao, Douyin, Xiaohongshu, and Bilibili. Figure 1 The floating window 102 shown in (1) is the floating window of the WeChat application.

[0069] Custom floating windows refer to floating windows developed by terminal device manufacturers for applications (including third-party applications and system applications), for example, Figure 2 The floating window shown in (2) is one possible style of a custom floating window. This application does not limit the style of custom floating windows.

[0070] For example, first window recognition logic can be inserted into the createSurfaceLocked() and destroySurface() methods of WindowStateAnimator to identify the floating windows of third-party applications.

[0071] The WindowStateAnimator class in WMS is used to manage the state of all windows on the screen. During the window layout process, WMS first calls the createSurfaceLocked() function of the WindowStateAnimator class to create a SurfaceControl object, that is, to create a Surface page. If the window type of the created page is a third-party floating window, it is determined that the floating window of the third-party application is visible, that is, the floating window of the third-party application is running.

[0072] For example, the screen of a terminal device may include multiple window types, each corresponding to a unique type identifier, which may be called a window type ID. For instance, the window type ID of a third-party application's floating window is "1", and the window type ID of a custom floating window is "2". When the window type ID of a created page is detected to be "1", it is determined that the floating window of the third-party application is running.

[0073] The destroySurface() function requests SurfaceFlinger to destroy a Surface. When it detects that the window type corresponding to the page requesting destruction is "1", it determines that the floating window of the third-party application will exit.

[0074] As can be seen, the pop-up and exit states of the floating window of a third-party application can be identified through the first window recognition logic, thereby ensuring the resource supply of the floating window application during its operation.

[0075] For example, a second window recognition logic can be inserted at the `moveToFront()` method of the Task to identify the startup status of third-party or custom floating windows. When it is detected that the window type calling the `moveToFront()` function is the window type ID corresponding to the third-party application's floating window or the window type ID corresponding to the custom floating window, it is determined that the third-party floating window or the custom floating window has started.

[0076] Among them, Task is the task stack, which maintains the state of Activity, such as visibility and lifecycle management.

[0077] S102, When WMS identifies that a window includes a floating window, it obtains the window information of the identified floating window.

[0078] Window information may include window type information and the critical task threads of the application running within the window, such as thread identifiers for logic threads and rendering threads. In this embodiment, window type information includes a window type identifier and window state information, such as whether it is running, visible, or closed.

[0079] After identifying a floating window currently in operation, obtain the key thread information of the application running within that floating window, such as the task IDs of the logic thread and the rendering thread. The task ID of the logic thread can be denoted as utid, and the task ID of the rendering thread can be denoted as rtid.

[0080] The logic thread refers to the main thread that displays the page within the floating window. The main thread handles most of the business logic, including UI display and updates. The rendering thread is primarily responsible for rendering the page.

[0081] In one scenario, or alternatively, only the window state information of the first floating window launched within a certain period could be recorded; this application does not impose any restrictions on this. The recorded window state information of the floating window is used to perform corresponding processing based on the real-time state of the floating window, such as ensuring resource supply for the floating window application during its operation.

[0082] S103, the window management service sends the floating window information to the message broker module.

[0083] After obtaining the window information of the floating window, the window management service packages it and sends it to the message broker module. For example, the window management service sends a floating window open message carrying the window information to the message broker module.

[0084] S104, the message broker module sends the window information of the floating window to the multi-window scheduler.

[0085] After receiving the floating window information from WMS, the message broker module passes the window information to the multi-window scheduler in the kernel layer. In one example, the message broker module passes the floating window information to the message processing module in the multi-window scheduler.

[0086] S105, the multi-window scheduler parses window information to obtain window type, window state information and key thread information corresponding to the floating window.

[0087] After parsing the received window information, the message processing module obtains the window type, window state information, and key thread information corresponding to the floating window.

[0088] If the window type is determined to be a floating window of a third-party application or a custom floating window, different processing logic is executed based on different window state information. In an exemplary embodiment, if the window state information is open or visible, then S106 is executed.

[0089] The key thread information corresponding to the floating window is the key thread information of the application running within the floating window, such as the logical thread utid and the rendering thread rtid mentioned above.

[0090] S106, When the multi-window scheduler determines that the window type is a floating window and the window state is visible, it increases the priority of critical threads.

[0091] In one exemplary embodiment, when the floating window is detected to be open or switched to the foreground, i.e. when the floating window is visible, the priority of the critical thread of the floating window application is increased, thereby accelerating the operation of the critical thread.

[0092] In another exemplary embodiment, when the rendering thread of the floating window application is detected to have started executing (i.e., when the interface of the floating window is continuously refreshed), the priority of the critical thread of the floating window application is increased.

[0093] For example, the application's critical threads can be set to VIP scheduling, which means moving the application's logic thread utid and rendering thread rtid from the CFS scheduling queue to the VIP scheduling queue. The VIP scheduling queue has a higher priority than the CFS scheduling queue, meaning tasks are read from the VIP scheduling queue for execution, and only after all tasks in the VIP scheduling queue have been read will tasks be read from the CFS scheduling queue for execution.

[0094] S107, calculate the load rate of critical threads and dynamically adjust the resource allocation of the application based on the load rate of critical threads of the floating window application.

[0095] In one exemplary embodiment, it is possible to utilize Figure 6 The kernel-level WALT statistics show the load of critical threads in the floating window application, i.e., the average load value of each critical thread.

[0096] For example, the load rate of the critical threads of a floating window application can be calculated using the following formula:

[0097] (1)

[0098] In Equation 1, task_util kThis represents the load of the k-th task of a critical thread. For example, it can be used to count the load of any critical thread of an application running within a floating window over a period of 100ms.

[0099] in, This represents the load rate of the k-th task.

[0100] For example, the critical thread load of an application may include the load of the logic thread (utid) and the rendering thread (rtid). In this scenario, the average load rate of the logic thread and the rendering thread can be calculated using Formula 1. A higher load rate indicates a greater task load, and a lower load rate indicates a smaller task load.

[0101] In an exemplary embodiment, the process of dynamically adjusting the resource allocation of the application based on the load of the critical threads running within the floating window may include the following steps:

[0102] S1071: If the load rate of the critical thread is greater than or equal to the first threshold, then dynamically adjust the CPU frequency, dynamically adjust the CPU cores, and dynamically adjust the frame rate.

[0103] The first threshold can be set according to actual needs, for example, 80%. When the load rate of the critical thread is ≥80%, it is considered that the floating window application will experience sluggish performance, such as video stuttering, and the CPU resource allocation strategy for that critical thread will be dynamically adjusted. In an exemplary embodiment, the CPU resource allocation strategy may include:

[0104] 1. Dynamically adjust the CPU frequency of critical threads.

[0105] Utilization clamping (uclamp) provides a user-space mechanism to limit tasks. This mechanism allows user space to clamp tasks within the range [util_min, util_max], with CPU resource limits determined by the uclamp value of the task in its run queue. Setting a task's uclamp value to a larger value allows it to obtain more CPU resources, such as a higher CPU frequency or running on a higher-performance CPU core. Similarly, for tasks requiring limitation, limiting their maximum load reduces their ability to obtain CPU resources.

[0106] To improve the smoothness of applications running within the floating window, when the load rate of a critical thread of the application within the floating window is detected to be greater than a first threshold (e.g., 80%), the load uclamp value of the critical thread of that application is increased, for example, set to 1024 (maximum load). This allows the critical thread of the floating window application to obtain more CPU resources, such as a higher CPU frequency. In addition, the number of times the thermal throttling is broken is dynamically adjusted according to the CPU temperature. For example, if the CPU temperature is greater than 45℃, two times the throttling is allowed; if the temperature is between 43℃ and 45℃, three times the throttling is allowed; and if the temperature is lower, four times the throttling is allowed.

[0107] 2. Dynamically adjust the CPU cores running critical threads.

[0108] A processor that integrates different cores on a single chip typically has higher frequencies and stronger performance, used to handle high-load tasks such as large applications and games with high graphics requirements. Small cores, on the other hand, are low-power and highly efficient, used to handle low-load tasks such as everyday applications and answering phone calls.

[0109] In this embodiment, when the load rate of a critical thread of the floating window application exceeds a first threshold, the critical thread is redirected to a processor with a larger core. For example, the CPU includes eight CPU cores, CPU0 to CPU7, where CPU0 to CPU2 are small cores, CPU3 to CPU5 are medium cores, and CPU6 to CPU7 are large cores. The critical thread of the floating window application runs on CPU0 to CPU2. When the load rate of this critical thread is detected to be ≥80%, the critical thread is redirected to run on CPU3 to CPU5.

[0110] 3. Dynamically adjust the frame rate of the floating window application.

[0111] In one exemplary embodiment, when the load rate of a critical thread in a floating window application is detected to be greater than or equal to a first threshold, the application's frame rate is reduced. For example, if the application's frame rate is 60 frames per second, and the complexity rate of the application's critical thread is ≥80%, the frame rate is limited to 30 frames per second. Reducing the frame rate can reduce the CPU resources required by the critical thread, thereby making the application run more smoothly.

[0112] In conclusion, as follows: Figure 8 As shown, when the load rate of the critical thread of the floating window application is detected to be greater than or equal to the first threshold, the critical thread of the application is moved from the CFS scheduling queue to the higher priority VIP queue to speed up the operation of the critical thread; the medium core is selected to run the critical thread; the CPU frequency is increased and the frame rate is reduced.

[0113] In addition to increasing the CPU frequency by increasing the load uclamp value of critical threads as mentioned above, the CPU frequency can also be increased by directly controlling it.

[0114] S1072, if the critical thread load of the floating window application decreases from greater than or equal to the first threshold to less than the second threshold, then cancel the dynamic adjustment of resource supply strategy.

[0115] The second threshold is less than the first threshold. The second threshold can be set according to actual needs, for example, 60%.

[0116] When the load rate of the critical thread of the floating window application drops from 85% to 58%, it is determined that the floating window application is currently running smoothly. The dynamic resource supply adjustment strategy in S1071 can be canceled, that is, the CPU frequency is restored, the small core is restored to run the critical thread, and the frame rate of the critical thread is restored.

[0117] If the load rate of the floating window application is between the second threshold and the first threshold, the dynamic adjustment of resource supply strategy in S1071 is maintained.

[0118] In other embodiments of this application, when WMS detects that the floating window is visible, it can also detect the application running in the main window at the bottom of the floating window. If the application running in the main window is a preset application (e.g., video, game, or other application that requires a lot of resources), the performance optimization strategy of the floating window is turned off, that is, the above-mentioned dynamic adjustment of resource supply strategy is canceled, thereby ensuring the performance of the application running in the main window.

[0119] S108, after detecting that the floating window application has completed its frame drawing, restore the scheduling priority of the critical thread of the floating window application.

[0120] The frame drawing process typically requires a lot of resources. If this process is executed late, the screen may not refresh in time, causing the display to stutter. To ensure the smoothness of the frame drawing process, the scheduling priority of the application's critical threads can be increased during the frame drawing process, that is, the critical threads of the floating window application are executed first to speed up the operation of the floating window application.

[0121] In one scenario, when it is detected that the floating window application has completed its frame rendering (i.e., the floating window's interface does not need to be refreshed), the priority of that critical thread is restored. When the rendering thread rtid of the floating window application is detected to have finished, it indicates that the frame rendering is complete, and the VIP scheduling of the application's critical thread can be canceled. That is, the application's critical thread is moved from the VIP scheduling queue to the CFS scheduling queue. In other words, the scheduling priority of the application's critical thread is reduced.

[0122] For example, if the floating window is a WeChat live stream, when the WeChat live stream is playing normally, the priority of the WeChat application's critical thread is increased. However, when the pause button is detected to be clicked (i.e., the WeChat live stream's floating window pauses playback), the priority of the WeChat application's critical thread is restored to the level before it was increased.

[0123] In an exemplary embodiment of this application, the terminal device supports running two or more floating windows simultaneously and records the state information of each floating window. For example, it uses a file or data structure to record the application corresponding to each floating window, as well as its open, closed, and other states. When the state of the floating window is determined to be invisible, the file or data structure recording the floating window state can be queried to determine resource supply optimization for that floating window application. In this case, the scheduling priority of the critical thread of the floating window application is restored, i.e., reduced to the level before resource supply optimization.

[0124] In another exemplary embodiment, the terminal device may only record information about the first launched floating window, such as the application running within the floating window and the window state. When the state of the floating window is determined to be invisible, the record is queried to determine whether resource allocation optimization should be performed for the floating window. If so, the scheduling priority of the critical threads of the floating window application is restored; otherwise, subsequent steps are executed.

[0125] S109, In ​​response to a window switching operation, the window management service sends window information to the message broker module.

[0126] In an exemplary embodiment, the window switching operation may include closing the floating window, switching the floating window to the main window, etc. When the above operation is detected, the window management service sends window information to the message broker module. For example, the window information includes information such as window type, window state information, and key threads (such as logic threads and rendering threads). This step is the same as the implementation process of S101, and will not be described again here.

[0127] S110, the message broker module sends the window information to the multi-window scheduler.

[0128] S111, the multi-window scheduler parses the window information and determines that after the floating window is closed, it accelerates the release of resources allocated to the critical thread corresponding to the floating window.

[0129] The message processing module within the multi-window scheduler parses the window information sent by the message broker module to determine whether the window type is a third-party floating window or a custom floating window. It then obtains the state of the floating window. If the floating window is determined to be closed, it determines the resources allocated to the application based on the key threads running within the floating window, such as the logic thread utid and the rendering thread rtid, and accelerates the release of these resources so that they can be allocated to other applications.

[0130] The resource scheduling method for terminal devices provided in this embodiment increases the scheduling priority of critical threads of an application when it detects that an application has started / switched to floating window mode (i.e., the floating window is visible). While the critical thread of the floating window application is executing, the load of the critical thread is statistically analyzed, and CPU resources are dynamically scheduled based on the load (e.g., increasing CPU frequency, selecting medium or large cores to run the critical thread), thereby increasing the CPU resource supply to the application running within the floating window, improving the smoothness of the floating window application, and ultimately enhancing the user experience of the floating window mode. Furthermore, when it is detected that the floating window does not require acceleration, such as when the screen or video within the floating window is paused or stopped, the VIP scheduling of the critical thread of the floating window application is canceled. When it is detected that the floating window is closed, the resources allocated to the floating window are released more quickly so that these resources can be allocated to other applications. Through the above process, it can be seen that this solution optimizes the resource supply strategy for the floating window when it detects that the floating window is running, speeds up the operation of the floating window application, and improves the smoothness of the application.

[0131] Please see Figure 9 This document illustrates a flowchart of another resource scheduling method for a terminal device provided in an embodiment of this application. This method is applied within the terminal device. Figure 7 The difference in the illustrated embodiment is that this embodiment can configure corresponding resource scheduling configuration information for different applications. When the floating window application is detected to be a preset application type, the resource scheduling configuration information matching the application type is directly obtained, and the resource supply of the floating window application is adjusted according to the configuration information.

[0132] like Figure 9 As shown, the method may include the following steps:

[0133] S201, when WMS detects a window switch, it identifies the window type.

[0134] S202, when WMS identifies a floating window within a window, it acquires the window information of the identified floating window. In an exemplary embodiment, the window information includes window type, window state information, and information about the application running within the floating window, as well as key thread information.

[0135] S203, the window management service sends the window information to the message broker module.

[0136] S204, the message broker module sends the window information of the floating window to the multi-window scheduler.

[0137] S205, the multi-window scheduler parses window information to obtain window type, window state information, application information corresponding to the floating window, and key thread information.

[0138] S206, When the multi-window scheduler determines that the window type is a floating window and the window state is visible, it obtains the resource scheduling configuration information that matches the floating window application and increases the priority of critical threads.

[0139] In this embodiment, resource scheduling configuration information matching the application can be queried based on the application information in the window information.

[0140] For example, in an exemplary embodiment, applications can be categorized into different types based on their resource requirements, such as video or live streaming applications, shopping or news applications, etc. Different resource scheduling configuration information (e.g., task priority, task core selection, CPU frequency, and frame rate) can be configured for each type of application. The terminal device maintains a mapping relationship between application types and their corresponding resource scheduling configuration information. For example, for video or live streaming applications, the CPU frequency can be configured to 2.0 GHz, the frame rate to 30, and it can run on a medium core. For shopping or news applications, the CPU frequency can be configured to 1.0 GHz, the frame rate to ≤30, and it can run on a small core, etc.

[0141] This application does not limit the number of resource scheduling configuration information. For example, it may configure the corresponding resource scheduling configuration information for only one type of application or configure the corresponding resource scheduling configuration information for multiple types of applications.

[0142] For example, for resource-intensive applications such as video applications, resource scheduling configuration information can be configured. When an application running in the floating window is detected to be of this type, the resource supply for that application can be dynamically adjusted according to the pre-configured resource scheduling configuration information to ensure the smooth operation of the application.

[0143] S207, When the multi-window scheduler detects the execution of a critical thread, it adjusts the resource supply of the floating window application according to the resource scheduling configuration information.

[0144] For example, if a WeChat video is running within the floating window, the resource scheduling configuration information for the video or live streaming application is retrieved, indicating a CPU frequency of 2.0GHz, medium core operation, and 30 frames per second. The resource allocation for the floating window application is then adjusted according to this configuration. When a critical thread of the floating window application is detected to begin execution, resource allocation is accelerated to improve the application's speed and smoothness.

[0145] S208, when the multi-window scheduler detects that the floating window application has finished drawing frames, it restores the scheduling priority of the critical threads of the floating window application.

[0146] S209: When the multi-window scheduler detects that the floating window is closed, it accelerates the release of resources allocated to the critical thread corresponding to the floating window.

[0147] The specific implementation processes of S201~S205 and S208~S209 in this embodiment are as follows: Figure 7 The real-time processes of the corresponding steps in the illustrated embodiments are the same, and will not be repeated here.

[0148] The resource scheduling method for terminal devices provided in this embodiment can configure different resource scheduling configuration information for different types of applications. In this way, when a configured application is detected running in the floating window, the resource scheduling configuration information matching the application is directly read, and when the critical thread of the application is executed, the resource supply of the application is adjusted according to the matching resource scheduling configuration information, so as to speed up the running speed and smoothness of the application running in the floating window.

[0149] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.

[0150] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A resource scheduling method for a terminal device, characterized in that, include: The system displays a main window and a floating window, with the floating window located above the main window. The main window displays the interface of a first application, and the floating window displays the interface of a second application. The critical thread corresponding to the second application is moved from the CFS scheduling queue to the VIP scheduling queue, and the load rate of the critical thread is calculated. The VIP scheduling queue is a newly added scheduling queue in the terminal device, and the priority of the VIP scheduling queue is higher than that of the CFS scheduling queue. If the load rate of the critical thread is greater than or equal to the first threshold, the resource supply strategy for optimizing the critical thread includes: increasing the CPU frequency corresponding to the critical thread from the first frequency to the second frequency, migrating the critical thread from the first CPU core to the second CPU core, and reducing the frame rate of the floating window from the first frame rate to the second frame rate, wherein the performance of the second CPU core is higher than that of the first CPU core. If the load rate of the critical thread of the second application decreases from greater than or equal to the first threshold to less than or equal to the second threshold, the CPU frequency corresponding to the critical thread is reduced from the second frequency to the first frequency, the critical thread is migrated from the second CPU core to the first CPU core for operation, and the frame rate of the floating window is increased from the second frame rate to the first frame rate.

2. The method according to claim 1, characterized in that, The method further includes: restoring the priority of the critical thread when the completion of the drawing frame in the critical thread is detected.

3. The method according to claim 1, characterized in that, When the load rate of the critical thread is greater than or equal to a first threshold, after optimizing the resource allocation strategy for the critical thread, the method further includes: If the first application running in the main window is a preset type application, the resource supply strategy for the second application is canceled. The preset type applications include at least game applications and live video streaming applications.

4. The method according to claim 1, characterized in that, The method further includes: When the floating window is determined to be closed, resources allocated to the critical thread of the floating window are released more quickly.

5. A resource scheduling method for a terminal device, characterized in that, The terminal device stores resource scheduling configuration information matching different types of applications. The method includes: The system displays a main window and a floating window, with the floating window located above the main window. The main window displays the interface of a first application, and the floating window displays the interface of a second application. Obtain resource scheduling configuration information matching the second application, and migrate the critical thread corresponding to the second application from the CFS scheduling queue to the VIP scheduling queue. The VIP scheduling queue is a newly added scheduling queue in the terminal device, and the priority of the VIP scheduling queue is higher than that of the CFS scheduling queue. The resource scheduling configuration information includes configuration information corresponding to CPU frequency, CPU cores, and frame rate. When the load rate of the critical thread is detected to be greater than or equal to the first threshold, the resource supply strategy for the critical thread is optimized as follows: according to the resource scheduling configuration information, the CPU frequency corresponding to the critical thread is increased from the first frequency to the second frequency, the critical thread is migrated from the first CPU core to the second CPU core for operation, and the frame rate of the floating window is reduced from the first frame rate to the second frame rate, wherein the performance of the second CPU core is higher than that of the first CPU core. When the load rate of a critical thread is detected to decrease from greater than or equal to the first threshold to less than or equal to the second threshold, the CPU frequency corresponding to the critical thread is reduced from the second frequency to the first frequency, the critical thread is migrated from the second CPU core to the first CPU core for operation, and the frame rate of the floating window is increased from the second frame rate to the first frame rate. Once the completion of the drawing frame in the critical thread is detected, the priority of the critical thread is restored; When it is determined that the floating window is closed, resources allocated to the critical thread of the floating window are released more quickly.

6. The method according to claim 1 or 5, characterized in that, The floating window includes a third-party floating window, which is a floating window built into a third-party application; the method also includes: When a page is detected to be created and the window type of the created page is a preset floating window type identifier, it is determined that the third-party floating window will pop up; When page destruction is detected and the window type of the destroyed page is a preset floating window type identifier, the third-party floating window is determined to exit.

7. The method according to claim 1 or 5, characterized in that, The method further includes: When the Activity task is detected to be switched to the foreground, the floating window is activated. The floating window includes third-party floating windows and custom floating windows. The custom floating window is a floating window developed by the terminal device for the application.

8. A terminal device, characterized in that, The terminal device includes: one or more processors, a memory, and a touch screen; the memory is used to store program code; the processor is used to run the program code, so that the terminal device implements the resource scheduling method of the terminal device as described in any one of claims 1 to 7.

9. A chip system, characterized in that, include: At least one processor and an interface, the interface being used to receive code instructions and transmit them to the at least one processor; The at least one processor executes the code instructions to implement the resource scheduling method of the terminal device according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, It stores instructions that, when executed on the electronic device, cause the electronic device to perform the resource scheduling method for the terminal device as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Game application display method and device, terminal, and storage medium

    CN109165076A

  • Application processing method and device

    CN113986558A