Resource scheduling method and electronic device

By employing preemptive scheduling and fine-grained group scheduling, the problem of slow or laggy startup of foreground applications on electronic devices under heavy system loads has been resolved, improving the smoothness of foreground applications and critical background tasks, and enhancing the user experience.

WO2026000926A1PCT designated stage Publication Date: 2026-01-02HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/143856
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-29
Filing Date
2024-12-30
Publication Date
2026-01-02

AI Technical Summary

Technical Problem

When electronic device systems are under heavy workloads, issues such as slow startup or lag in foreground applications have not been effectively resolved.

Method used

A preemptive scheduling approach is adopted to divide the drawing threads that affect the smoothness of the foreground application into the first group, and to schedule non-drawing threads and background applications according to the IO resource quota of the second group. This fine-grained group scheduling improves resource utilization and the smoothness of critical background tasks.

Benefits of technology

It improves the responsiveness of foreground applications, reduces startup or display time, enhances the smoothness of foreground application operation and critical background task operation, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024143856_02012026_PF_FP_ABST
    Figure CN2024143856_02012026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of terminals, and provides a resource scheduling method and an electronic device. The method comprises: using a preemptive scheduling method to schedule I / O requests in a first group; and on the basis of an IO resource quota of a second group, scheduling IO requests in the second group. The first group comprises drawing threads of a foreground application; and the second group comprises non-drawing threads of the foreground application and / or a background application. The technical solution provided by the present application can improve the operating smoothness of foreground applications.
Need to check novelty before this filing date? Find Prior Art

Description

Resource scheduling method and electronic device

[0001] The present application claims priority to the Chinese patent application No. 202410875334.7, filed on June 29, 2024, and entitled "Resource scheduling method and electronic device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the technical field of terminals, and in particular to a resource scheduling method and an electronic device. BACKGROUND

[0003] With the continuous development of terminal technology, portable terminals such as mobile phones and tablet computers have become indispensable electronic devices in people's daily life and work.

[0004] When using an electronic device, a user often opens multiple applications. When running multiple applications, the electronic device usually schedules resources according to the foreground or background state of the applications. However, when the system task load is too heavy, the foreground application is still prone to slow startup or freezing and other running smoothness problems. SUMMARY

[0005] Therefore, the present application provides a resource scheduling method and an electronic device to improve the smoothness of application running.

[0006] To achieve the above purpose, in a first aspect, the present application provides a resource scheduling method applied to an electronic device, the method comprising:

[0007] scheduling IO requests of a first group in a pre-emptive scheduling manner; the first group comprising a drawing thread of a foreground application;

[0008] scheduling IO requests of a second group according to an IO resource quota of the second group; the second group comprising a non-drawing thread of the foreground application and / or a background application.

[0009] The resource scheduling method provided in the present application divides the drawing thread affecting the smoothness of the foreground application running into the first group, divides the non-drawing thread and / or the background application into the second group, schedules the IO requests of the first group in the pre-emptive scheduling manner, and schedules the IO requests of the second group according to the IO resource quota of the second group. In this way, the response speed of the drawing thread can be improved, thereby reducing the startup or display time consumption of the foreground application and improving the smoothness of the foreground application running.

[0010] In a possible implementation of the first aspect, the drawing thread comprises a UI thread and a rendering thread.

[0011] The UI thread and the rendering thread have a greater impact on the display fluency of the foreground application, and scheduling the IO requests of the UI thread and the rendering thread in a preemption mode can effectively improve the fluency of the foreground application.

[0012] In a possible implementation of the first aspect, the second group includes a foreground group, a key background group, and a non-key background group; the foreground group includes threads of the foreground application other than the rendering thread, the key background group includes perceptible background tasks, and the non-key background group includes other background tasks other than the perceptible background tasks.

[0013] The IO resource quota of the foreground group and the key background group is higher than the IO resource quota of the non-key background group.

[0014] In the above implementation, the second group is further divided into multiple groups, so that more fine-grained resource scheduling can be performed, thereby improving resource utilization. In addition, the user-perceptible background tasks are divided into the key background group, and the IO resource quota of the key background group is higher than the IO resource quota of the non-key background group, so that the running fluency of the key background tasks can be improved, and the user experience can be improved.

[0015] In a possible implementation of the first aspect, the IO resource quota of the key background group is lower than or equal to the IO resource quota of the foreground group.

[0016] In the above implementation, the priority of the key background group bg1 is not higher than the priority of the foreground group fg, so that the running fluency of the foreground tasks can be better guaranteed.

[0017] In a possible implementation of the first aspect, the method further includes:

[0018] When the running state of the first application changes, the group to which the application task corresponding to the first application belongs is updated, and the first application is any application.

[0019] Through the above implementation, the group information can be updated in a timely manner, and the accuracy of resource scheduling can be improved.

[0020] In a possible implementation of the first aspect, when the running state of the first application changes, the group to which the application task corresponding to the first application belongs is updated, including:

[0021] When the first application switches to the foreground running state, the rendering thread of the first application is divided into the first group, and the non-rendering thread of the first application is divided into the foreground group.

[0022] In a possible implementation of the first aspect, the method further includes:

[0023] When the first application switches to the background running state, if the first application belongs to the perceivable background application, the first application is divided into the critical background group; if the first application does not belong to the perceivable background application, the first application is divided into the non-critical background group.

[0024] Alternatively,

[0025] When the first application switches to the background running state, if the first application includes the target task, the target task of the first application is divided into the critical background group, and the non-target task of the first application is divided into the non-critical background group; if the first application does not include the target task, the first application is divided into the non-critical background group; the target task includes the perceivable background process or thread.

[0026] Through the above embodiments, different grouping manners can be used for grouping, so that the flexibility of grouping can be improved.

[0027] In a possible implementation of the first aspect, the IO requests of the first group are scheduled in a preemptive scheduling manner, including:

[0028] Before scheduling each IO request of the second group, if there is an IO request of the first group, the IO request of the first group is scheduled.

[0029] Through the above embodiments, the scheduling timeliness of the IO requests of the first group can be improved, and the processing time consumption of the IO requests of the first group can be reduced.

[0030] In a possible implementation of the first aspect, the second group includes a plurality of subgroups, each subgroup has a corresponding IO resource quota, and the IO requests of each subgroup are stored in a subgroup corresponding group queue; the IO requests of the second group are scheduled according to the IO resource quota of the second group, including:

[0031] In each scheduling period, the group queues of the subgroups are traversed in descending order of the IO resource quota;

[0032] For the group queue of the subgroup traversed, when there is an IO request in the group queue and the subgroup has a remaining IO resource quota, the IO request in the group queue is scheduled, and the remaining IO resource quota of the subgroup is updated.

[0033] In the above embodiments, the group queue is used to store the IO request, which can facilitate the scheduling of the IO request; the IO requests of the subgroups are processed in descending order of the IO resource quota, which can more timely process the IO requests of high priority and improve the response speed of the IO requests of high priority.

[0034] In a second aspect, an embodiment of the present application provides a resource scheduling apparatus applied to an electronic device, the apparatus comprising:

[0035] a first scheduling module configured to schedule IO requests of a first group in a preemptive scheduling manner; the first group comprising drawing threads of foreground applications;

[0036] a second scheduling module configured to schedule IO requests of a second group according to IO resource quotas of the second group; the second group comprising non-drawing threads of foreground applications and / or background applications.

[0037] In a possible implementation of the second aspect, the drawing threads comprise UI threads and rendering threads.

[0038] In a possible implementation of the second aspect, the second group comprises a foreground group, a critical background group and a non-critical background group; the foreground group comprises threads other than the drawing threads of the foreground applications, the critical background group comprises perceptible background tasks, and the non-critical background group comprises other background tasks other than the perceptible background tasks.

[0039] The IO resource quotas of the foreground group and the critical background group are both higher than the IO resource quota of the non-critical background group.

[0040] In a possible implementation of the second aspect, the IO resource quota of the critical background group is lower than or equal to the IO resource quota of the foreground group.

[0041] In a possible implementation of the second aspect, the apparatus further comprises:

[0042] a group updating module configured to update a group to which an application task of a first application belongs when a running state of the first application changes; the first application being any application.

[0043] In a possible implementation of the second aspect, the group updating module is specifically configured to:

[0044] when the first application switches to a foreground running state, divide a drawing thread of the first application to the first group and divide a non-drawing thread of the first application to the foreground group.

[0045] In a possible implementation of the second aspect, the group updating module is further configured to:

[0046] when the first application switches to a background running state, if the first application belongs to a perceivable background application, the first application is classified into the critical background group; if the first application does not belong to a perceivable background application, the first application is classified into the non-critical background group;

[0047] or,

[0048] when the first application switches to a background running state, if the first application includes a target task, the target task of the first application is classified into the critical background group, and the non-target task of the first application is classified into the non-critical background group; if the first application does not include a target task, the first application is classified into the non-critical background group; the target task includes a perceivable background process or thread.

[0049] In a possible implementation of the second aspect, the first scheduling module is specifically configured to:

[0050] Before scheduling each IO request of the second group, if there is an IO request of the first group, the IO request of the first group is scheduled.

[0051] In a possible implementation of the second aspect, the second group includes a plurality of sub-groups, each sub-group has a corresponding IO resource quota, and an IO request of each sub-group is stored in a group queue corresponding to the sub-group; the second scheduling module is specifically configured to:

[0052] In each scheduling period, the group queues of the sub-groups are traversed in descending order of IO resource quota;

[0053] For the group queue of the traversed sub-group, when there is an IO request in the group queue and the sub-group has a remaining IO resource quota, the IO request in the group queue is scheduled, and the remaining IO resource quota of the sub-group is updated.

[0054] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, the memory is used to store a computer program; the processor is used to execute the method in the first aspect or any of the implementation manners of the first aspect when the computer program is called.

[0055] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method in the first aspect or any of the implementation manners of the first aspect.

[0056] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on an electronic device, causes the electronic device to perform the method in the first aspect or any of the implementation forms of the first aspect.

[0057] In a sixth aspect, an embodiment of the present application provides a chip system, comprising a processor coupled with a memory, and the processor executes a computer program stored in the memory to implement the method in the first aspect or any of the implementation forms of the first aspect. The chip system can be a single chip or a chip module composed of multiple chips.

[0058] It can be understood that the beneficial effects of the second aspect to the sixth aspect can be referred to the related description in the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0059] FIG. 1 is a schematic diagram of a software architecture of an electronic device according to an embodiment of the present application;

[0060] FIG. 2 is a schematic diagram of grouping according to an embodiment of the present application;

[0061] FIG. 3 is a schematic diagram of a resource scheduling method according to an embodiment of the present application;

[0062] FIG. 4 is a schematic diagram of a resource scheduling principle according to an embodiment of the present application;

[0063] FIG. 5 is a schematic diagram of a grouping update process according to an embodiment of the present application;

[0064] FIG. 6 is a schematic diagram of an IO request scheduling process according to an embodiment of the present application;

[0065] FIG. 7 is a schematic diagram of a resource scheduling method according to another embodiment of the present application;

[0066] FIG. 8 is a schematic diagram of a structure of a resource scheduling apparatus according to an embodiment of the present application;

[0067] FIG. 9 is a schematic diagram of a structure of an electronic device according to an embodiment of the present application;

[0068] FIG. 10 is a schematic diagram of a structure of a chip system according to an embodiment of the present application. DETAILED DESCRIPTION

[0069] The embodiments of the present application will be described hereinafter with reference to the accompanying drawings. The terms used in the implementation manner part of the embodiments of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in some embodiments.

[0070] For the convenience of understanding the technical solutions in the embodiments of the present application, first, some terms involved in the embodiments of the present application are explained as follows:

[0071] Frontground running state: refers to that the electronic device is running an application and the application is in a state that is visible to the user or can be directly interacted with by the user interface. For example, the electronic device displays a play interface of a music application, the user can see and interact with the music play interface, and the music application is in a frontground running state. The application in the frontground running state is a frontground application.

[0072] Background running state: refers to that the electronic device is running an application but the application is in a state that is invisible to the user. For example, the electronic device is playing music but displays an application interface of another application, at this time, the music application is in a background running state. The application in the background running state is a background application.

[0073] Control group (cgroup): a mechanism for resource control, which manages and controls the behavior of tasks in the system in the form of groups in terms of system resource usage. The electronic device can group each task running in the system through the cgroup, and then allocate and control resources for each divided group as a whole. These resources include but are not limited to input output (IO) resources and memory resources, etc.

[0074] Memory: used for temporarily storing data in the processor and data exchanged with external storage such as hard disk. In the embodiments of the present application, the memory refers to the physical memory; the physical memory can be divided into a plurality of fixed-size pages (physical pages) as the basic unit of system management of physical memory, and the size of the page is generally 4 KB (kilobyte) or 8 KB, etc.

[0075] When the electronic device runs multiple applications, the cgroup mechanism described above can be used to group the applications according to the foreground and background states of the applications, and then to schedule resources for each group. For example, the frontground applications are divided into a frontground cgroup, and the background applications are divided into a background cgroup, and more optimal or more resources are allocated to the frontground applications in the frontground cgroup, so that the response speed of the frontground applications is faster. However, the performance of the electronic device is limited, and when the system task load is too heavy, the problem of slow application startup or stuttering running fluency still easily occurs.

[0076] To this end, an embodiment of the present application provides a resource scheduling scheme, in which threads in an electronic device that have a greater impact on the fluency of foreground application running are divided into a group as privileged tasks, IO requests of the privileged tasks are preemptively scheduled, and IO requests of other groups are scheduled according to resource quotas, so as to reduce the time consumption of starting or displaying the foreground application and improve the fluency of application running.

[0077] The electronic device can be a mobile phone, a tablet, a notebook computer, a smart wearable device, a vehicle-mounted terminal, or the like, which has a display function. Embodiments of the present application do not particularly limit this. For ease of description, a mobile phone is taken as an example for illustrative description in the embodiments of the present application.

[0078] The software architecture of the electronic device related to the embodiments of the present application is described below.

[0079] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The software system of the electronic device can be an Android system, system, a Microsoft system, a Harmony system, or an Apple system, or the like.

[0080] The embodiments of the present application take the Android system with a layered architecture as an example to illustratively describe the software structure of the electronic device. FIG. 1 is a schematic diagram of the software architecture of the electronic device provided by an embodiment of the present application. As shown in FIG. 1, the software system of the electronic device can be divided into several layers, and the layers communicate with each other through software interfaces. In some embodiments, the Android system can be divided into an application program layer (referred to as an application layer), an application program framework layer (referred to as a framework layer), and a kernel layer from top to bottom. In some embodiments, the framework layer and the kernel layer can further include an Android runtime and a system library, and the like.

[0081] The application layer can include a series of application programs (referred to as applications). For example, the application layer can include camera, gallery, calendar, call, wireless local area network (WLAN), Bluetooth, music, video, short message, map, browser, and the like.

[0082] The framework layer provides application programming interfaces (APIs) and programming frameworks for the application programs of the application layer. The framework layer includes some pre-defined functions.

[0083] Exemplarily, the framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. The window manager provides a window manager service (WMS), which can be used for window management, window animation management, surface management, and as a relay station of an input system. The window manager can acquire a display screen size, determine whether there is a status bar, lock a screen, and intercept a screen, etc. The content provider is used to store and acquire data, and make the data accessible by an application program. The data can include videos, images, audios, dialed and received calls, browsing history and bookmarks, a phone book, etc. The view system includes visual controls, such as a control for displaying text, a control for displaying pictures, etc. The view system can be used to build an application program. A display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide a communication function of the electronic device. For example, management of a call state (including call connection, call hang-up, etc.). The resource manager provides various resources for an application program, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables an application program to display notification information in a status bar, which can be used to convey a notification type of message, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify a download completion, a message reminder, etc. The notification manager can also be a notification appearing in a system top status bar in a chart or a scroll bar text form, such as a notification of a background running application, and can also be a notification appearing on a screen in a dialog window form. For example, prompting text information in a status bar, issuing a prompt sound, electronic device vibration, indicator light blinking, etc.

[0084] The application layer and the framework layer run in a virtual machine. The virtual machine executes java files of the application layer and the framework layer into binary files. The virtual machine is used to perform functions of management of an object life cycle, stack management, thread management, security and exception management, and garbage collection, etc.

[0085] In some embodiments, the framework layer can further include an application life cycle management module and a resource management and control module.

[0086] It can be understood that the life cycle management module and the resource management and control module can also be located in other layers, such as the kernel layer, and subsequent examples in the embodiments of the present application are exemplarily described with the life cycle management module and the resource management and control module located in the framework layer.

[0087] The application life cycle management module can monitor application states of various applications, such as an application state of an application starting to enter a foreground running state, an application state of an application switching from a foreground running state to a background running state, an application state of an application switching from a background running state to a foreground running state, etc.

[0088] Each application of the application layer can initiate one or more processes, and each process can include one or more threads. For any thread, the thread can initiate one or more resource requests, that is, each application can initiate one or more resource requests.

[0089] The resource request can include an input output (IO) request and a memory application request, and the application can request to perform a corresponding input operation or output operation through the IO request, and apply for a required memory space through the memory application request. The following will be exemplarily described mainly by taking the two requests as examples.

[0090] The resource management and control module can configure groups for the application tasks of the applications according to the application states of the applications running in the system, so as to manage and control the resource requests of the applications through the resource groups.

[0091] The resource management and control module can obtain the application states of the applications from the application lifecycle management module.

[0092] In some implementations, the application lifecycle management module can periodically report the application states of the applications to the resource management and control module, and the period can be a short time length.

[0093] In some implementations, the application lifecycle management module can report the application state of any application to the resource management and control module when monitoring that the application state of the application changes.

[0094] Similarly, the resource management and control module can periodically update the groups; or can update the group to which the application task of any application belongs when the application state of the application changes. For example, the group to which the application task of an application belongs can be updated after the application state of the application reported by the application lifecycle management module is received, so as to improve the timeliness of the group, and the following will be exemplarily described by taking this as an example.

[0095] The application task described above can refer to an application, or a process or a thread of an application. That is, the elements in the group can include one or more of an application, a process and a thread.

[0096] The resource management and control module can divide the application tasks of the system into multiple groups, such as the foreground group and the background group described above, by using a cgroup mechanism. The resource management and control module can configure priorities for the groups, for example, the priority of the foreground group is higher than that of the background group. In the embodiments of the present application, the specific grouping scheme can be referred to the subsequent embodiments.

[0097] The resource management module can also configure a resource quota for the group. The resource quota of the group can indicate an amount of resources that the group can use.

[0098] In some embodiments, the resource quota of the group can include a resource quota of IO resources (referred to as an IO resource quota).

[0099] The IO resources are used to process IO requests, one IO request indicating one IO operation, and the IO operation corresponding to the IO request can include an input operation and an output operation.

[0100] Optionally, the IO resource quota of the group can be the number of IO requests that can be processed per second by the group, i.e., the number of IO operations per second, in units of IOPS (input output per second).

[0101] Optionally, the IO resource quota of the group can also be the bandwidth occupied by the IO requests that can be processed per second by the group, i.e., the bandwidth occupied by the IO operations per second, in units of BPS (byte per second).

[0102] In some embodiments, the resource quota of the group can include a resource quota of memory resources (referred to as a memory resource quota).

[0103] The memory resources are used to process memory application requests (or referred to as memory allocation requests), i.e., to allocate memory for the memory application requests.

[0104] Optionally, the memory resource quota of the group can be the size of the memory space that can be used by the group, for example, the memory resource quota of a certain group is 10 MB (megabytes).

[0105] Optionally, the memory resource quota of the group can also be the number of page resources that can be used by the group, for example, each page can provide a storage space of 8 KB, and the memory resource quota of a certain group can be 1500 pages.

[0106] The IO resource quota and the memory resource quota of the group can also be expressed in other ways, which are not particularly limited in the embodiments of the present application.

[0107] In some embodiments, the resource management module can specifically configure the resource quota for the group according to the priority of the group.

[0108] For example, the resource quota of the high-priority group can be greater than the resource quota of the low-priority group. For example, the IOPS of the foreground group is 500, and the IOPS of the background group is 300. For another example, the memory resource quota of the foreground group is 5000 pages, and the memory resource quota of the background group is 1000 pages. It can be understood that the above is only an example and is not intended to limit the present application.

[0109] In some embodiments, the resource management module can include a plurality of sub-modules, one for each type of resource. For example, the IO resource corresponds to the IO management module, and the memory resource corresponds to the memory management module. Each sub-module can manage the corresponding resource in groups. The groups divided by each sub-module can be the same or different. In the embodiments of the present application, the same resource management module is used for each resource, and the grouping strategy of the resource management module is used as an example for illustrative purposes.

[0110] The kernel layer is the layer between hardware and software, which provides core system services for the Android kernel, such as security services, network services, memory management services, detection management services, and driver models. The kernel layer can include an IO driver and other drivers, such as display drivers, camera drivers, and sensor drivers.

[0111] In the embodiments of the present application, the kernel layer can also include a resource scheduling module. The resource scheduling module can schedule resource requests according to a preset scheduling strategy. For example, the resource management module can send the grouping information and the resource quota information to the resource scheduling module. The resource scheduling module can schedule the resource requests of the application tasks in each group according to the resource quota of each group, or schedule the resource requests of the application tasks in each group according to the priority of each group. The specific scheduling process can be referred to in the subsequent embodiments.

[0112] The resource scheduling module can include an IO scheduling module for managing IO resources and scheduling IO requests. The resource scheduling module can also include a memory management module for managing memory resources and processing memory application requests. The resource scheduling module can also include resource scheduling modules corresponding to other types of resources.

[0113] Specifically, the resource management module can send the grouping information and the IO resource quota of each group to the IO scheduling module, and the IO scheduling module schedules the IO requests accordingly. The resource management module can send the grouping information and the memory resource quota of each group to the memory management module, and the memory management module processes the memory application requests accordingly.

[0114] The IO requests of the applications are usually more, and the IO scheduling module can store the IO requests of each group in a queue to facilitate the management of the IO requests. For example, the IO scheduling module can store the IO requests of the application tasks in the foreground group in a foreground group IO queue, and store the IO requests of the application tasks in the background group in a background group IO queue.

[0115] The IO scheduling module can extract the IO requests from the group IO queues for scheduling. For the currently scheduled IO request, the IO scheduling module can issue it to the IO driver to drive the IO device to perform the corresponding IO operation through the IO driver.

[0116] After receiving the memory application request of the application task, the memory management module can allocate memory for the application task.

[0117] When the memory is tight, i.e., the free memory is low, the memory management module can perform memory reclamation.

[0118] Specifically, when the free memory is lower than the page low threshold (pages_low), the memory management module can call a core swap (kswapd) thread to perform memory reclamation in the background (i.e., background memory reclamation). The memory reclamation process is asynchronous with the memory allocation process and does not block the memory allocation process, i.e., while the memory management module is performing memory allocation for a memory application request initiated by a process (i.e., an application task), it can call the kswapd thread to perform background memory reclamation without blocking the execution of the process.

[0119] The memory management module can periodically call the kswapd thread to perform background memory reclamation, or call the kswapd thread to perform background memory reclamation when it finds that the free memory is lower than the page low threshold during memory allocation. The memory management module can stop performing background memory reclamation when the free memory reaches above the page high threshold (pages_high).

[0120] When the free memory is lower than the page minimum threshold (pages_min, also referred to as the direct memory reclamation threshold), the memory management module can perform a direct memory reclamation (direct reclaim) process. The memory reclamation process is synchronous with the memory allocation process and blocks the memory allocation process, i.e., the memory management module performs memory reclamation before performing memory allocation for a memory application request initiated by a process, and allocates memory for the process after reclaiming sufficient memory.

[0121] The direct memory reclaiming process can be executed simultaneously with the background memory reclaiming process. When the free memory is below the page minimum threshold, the memory management module can call the kswapd thread to perform background memory reclaiming while performing the direct memory reclaiming operation, until the free memory is above the page minimum threshold. At this time, the memory management module can allocate memory for the process, and the kswapd thread can continue to execute until the free memory is above the page high threshold.

[0122] The above background memory reclaiming and direct memory reclaiming processes can reclaim file pages (pages mapped to specific disk files) and anonymous pages (pages not mapped to specific disk files).

[0123] If the free memory of the system is still insufficient after the direct memory reclaiming is performed, the memory management module can also perform memory reclaiming by killing the process.

[0124] The grouping scheme provided by the embodiments of the present application will be described below.

[0125] FIG. 2 is a grouping diagram provided by the embodiments of the present application. As shown in FIG. 2, the groupings divided by the resource management and control module can include a first grouping sg and second groupings. The priority of the first grouping sg is higher than the priority of each second grouping.

[0126] To improve the running fluency of the foreground application, in the embodiments of the present application, the first grouping sg can include threads that will affect the running fluency of the foreground application, i.e., privileged tasks (hereinafter referred to as first tasks). The IO requests of the first tasks in the first grouping sg can not be limited by the IO resource quota, and the first tasks can be scheduled in a preemptive scheduling manner. In this way, the processing time of the resource requests of the foreground application can be reduced, thereby reducing the situations of foreground application freezing and slow starting, and thus improving the running fluency of the foreground application.

[0127] The first tasks can include threads related to interface drawing of the foreground application, i.e., drawing threads, such as user interface (UI) threads, render threads, and the like. That is, the application tasks in the first grouping sg can include the drawing threads of the foreground application.

[0128] It can be understood that in some embodiments, the first tasks can also include other threads / processes that affect the running fluency of the foreground application.

[0129] In some embodiments, the second grouping can include one grouping (also referred to as a sub-grouping); in some embodiments, the second grouping can include multiple sub-groupings to better perform resource scheduling.

[0130] As an optional implementation, the second group can include one or more of a foreground group and a background group.

[0131] The foreground group includes application tasks in a foreground running state (referred to as foreground tasks) other than the first task.

[0132] The background group includes application tasks in a background running state (referred to as background tasks).

[0133] The priority of the foreground group is higher than the priority of the background group, so that the foreground tasks can be allocated to better resources, thereby reducing the running unsmoothness of the foreground application such as foreground application lag, and improving the running smoothness of the foreground application.

[0134] As another optional implementation, the second group can include more subgroups for finer-grained resource scheduling, thereby improving resource utilization.

[0135] In some embodiments, as shown in FIG. 2, the second group can include one or more of a foreground group fg, a critical background group bg1, and a non-critical background group bg2.

[0136] The critical background group bg1 can be understood as a group separated from the background group. In an implementation, the critical background group bg1 can include some critical background tasks; and the non-critical background group bg2 can include background tasks other than the critical background tasks.

[0137] Optionally, the critical background tasks can include user-perceptible background tasks, such as music playing tasks, navigation tasks, application updating tasks, data transmission tasks, recording tasks, device connection tasks, timing reminder tasks, and motion health tasks (such as step counting tasks).

[0138] The data transmission task can include long-distance transmission tasks (uploading / download tasks), and can also include Bluetooth transmission tasks, WLAN transmission tasks, and other short-distance transmission tasks.

[0139] It can be understood that in some implementations, the critical background tasks can also include other relatively critical background tasks.

[0140] The priority of the critical background group bg1 is higher than the priority of the non-critical background group bg2, so that for the user-perceptible background tasks, better resources can be allocated, thereby improving the running smoothness of these critical background tasks, and further improving the user experience.

[0141] In some implementations, the priority of the critical background group bg1 can be equal to the priority of the foreground group fg; in some implementations, the priority of the critical background group bg1 can be lower than the priority of the foreground group fg, so as to better guarantee the smoothness of the running of the foreground task.

[0142] The critical background task can be a critical background application (also referred to as a target application) or a critical background process / thread (also referred to as a target task). For example, taking a music playing task as an example, the critical background task can be a music application or a music playing process / thread of the music application. That is, in some implementations, the music application can be divided into the critical background group bg1; in other implementations, the music playing process / thread of the music application can be divided into the critical background group bg1, and other processes / threads of the music application can be divided into the non-critical background group bg2.

[0143] In some embodiments, as shown in FIG. 2, the groups divided by the resource management module can include a first group sg, a foreground group fg, a critical background group bg1, and a non-critical background group bg2. The first group sg includes a first task such as a drawing thread, the foreground group fg includes other foreground tasks except the first task, the critical background group bg1 includes a critical background task, and the non-critical background group bg2 includes other background tasks except the critical background task. The priority of the first group sg is higher than the priority of the foreground group fg, the priority of the foreground group fg is higher than the priority of the critical background group bg1, and the priority of the critical background group bg1 is higher than the priority of the non-critical background group bg2.

[0144] The resource scheduling method of the embodiments of the present application is described below based on the above groups.

[0145] FIG. 3 is a flow diagram of a resource scheduling method provided by an embodiment of the present application. The execution subject of the method is an electronic device. As shown in FIG. 3, the method provided by the embodiment of the present application can include the following steps:

[0146] S100, when the running state of any application changes, updating the group to which the application task corresponding to the application belongs.

[0147] As described above, the electronic device can monitor the application states of the running applications through the application lifecycle management module. As shown in FIG. 4, the application lifecycle management module can report the application state of any application to the resource management module when the application state of the application changes.

[0148] The resource management module can update the group to which the application task corresponding to the application (hereinafter referred to as a first application) belongs after receiving the application state of the first application reported by the application lifecycle management module. The first application can be any application.

[0149] In some embodiments, when the first application switches to the foreground running state, the first task of the first application can be divided into the first group, and the second task (i.e., other application tasks except the first task) of the first application can be divided into the foreground group in the second group.

[0150] The first application can switch from the background running state to the foreground running state, or switch from the closed state to the foreground running state, i.e., the user opens the first application, and the first application enters the foreground running state after starting.

[0151] In some embodiments, the first application can switch from the foreground running state to the background running state. As a first optional implementation, when the first application switches to the background running state, if the first application belongs to a key background application (i.e., a target application), the first application is divided into the key background group; if the first application does not belong to the key background application, the first application is divided into the non-key background group.

[0152] As a second optional implementation, when the first application switches to the background running state, if the first application includes a perceivable background process or thread (i.e., a target task), the target task of the first application is divided into the key background group, and the non-target task of the first application is divided into the non-key background group; if the first application does not include the target task, the first application is divided into the non-key background group.

[0153] Taking the first implementation as an example, as shown in FIG. 5, for any application, the group updating process thereof can include the following steps:

[0154] S101, detecting that the application state of an application changes.

[0155] As described above, the electronic device can monitor the application states of the running applications through the application lifecycle management module. For any application, if it is detected that the application state of the application changes, the electronic device can update the group to which the application task corresponding to the application belongs through the resource management module.

[0156] When the application state of an application changes, the application can switch to the foreground running state or the background running state.

[0157] S102, determining whether the application switches to the foreground running state, if yes, performing step S103, otherwise, performing step S104.

[0158] The resource management module can first determine whether the application switches to the foreground running state when updating the group to which the application task of the application belongs.

[0159] As described above, the application can switch from the background running state to the foreground running state, or switch from the closed state to the foreground running state.

[0160] S103, the first task of the application is divided into the first group, and the second task of the application is divided into the foreground group.

[0161] If the application switches to the foreground running state, the resource management module can divide the first task of the application into the first group, and the second task (i.e., other application tasks other than the first task) of the first application into the foreground group.

[0162] As described above, the first task can include the aforementioned UI thread, rendering thread, and other drawing threads, and the second task includes other application tasks of the application other than the first task.

[0163] The priority of the first group is higher than that of the foreground group, the resource quota of the first group is unlimited, and the IO request of the application task in the group can be scheduled in a pre-emptive scheduling manner.

[0164] The priority of the foreground group is higher than that of the critical background group and the non-critical background group, and correspondingly, the resource quota of the foreground group is superior to that of the critical background group and the non-critical background group; the IO request of the application task in the foreground group is scheduled according to the IO resource quota of the group.

[0165] S104, determine whether the application is a critical background application, if yes, execute step S105, otherwise, execute step S106.

[0166] If the application switches from the foreground running state to the background running state, the resource management module can first determine whether the application is a critical background application, and then determine whether to divide the application into the critical background group or the non-critical background group according to the determination result.

[0167] As described above, the critical background application can include a user-perceptible background application, such as a music application, a navigation application, an application in an updating state, an application in data transmission / equipment connection, a recording application, a timing reminder application, a sports health application, etc.

[0168] S105, divide the application into the critical background group.

[0169] If the application belongs to the critical background application, the resource management module can divide the application into the critical background group.

[0170] As mentioned above, the priority of the key background group is higher than that of the non-key background group, and the resource quota of the key background group is superior to that of the non-key background group; the IO request of the application task in the key background group is scheduled according to the IO resource quota of the group.

[0171] S106, the application is divided into a non-key background group.

[0172] If the application does not belong to the key background application, the resource management module can divide the application into a non-key background group. The IO request of the application task in the non-key background group is scheduled according to the IO resource quota of the group.

[0173] The above is an example of taking the second group as an example, which includes a foreground group, a key background group and a non-key background group. It can be understood that for other grouping modes of the second group, similar grouping information updating modes can be adopted.

[0174] For example, the second group only contains one group, and when the first application switches to the foreground running state, the first task of the first application is divided into the first group, and the second task of the first application is divided into the second group; when the first application switches to the background running state, the first application is divided into the second group.

[0175] For example, the second group includes a foreground group and a background group, and when the first application switches to the foreground running state, the first task of the first application is divided into the first group, and the second task of the first application is divided into the foreground group; when the first application switches to the background running state, the first application is divided into the background group.

[0176] The resource management module can issue the updated grouping information to the resource scheduling module after updating the group.

[0177] S200, the first IO request of the first group is scheduled in a preemption mode; the second IO request of the second group is scheduled according to the IO resource quota of the second group.

[0178] The first IO request is the IO request of the first task, and the second IO request is the IO request of the second task.

[0179] Specifically, the priority of the first group is higher than that of the second group, and the first IO request of the first group is processed preferentially by the electronic device; the resource quota of the group is equivalent to an unlimited quota, and when the first IO request exists in the first group, the electronic device preempts the first IO request.

[0180] For the second group, the electronic device can schedule the second IO requests of the second group according to the IO resource quota of the second group.

[0181] As mentioned above, the second group can include one or more sub-groups, in some implementations, the second group includes one or more of a foreground group, a key background group and a non-key background group.

[0182] For each sub-group, the electronic device can process the second IO requests of each sub-group in each scheduling period in order of priority from high to low, to give priority to high-priority IO requests; when processing a certain sub-group, the second IO requests of the group can be scheduled according to the resource quota of the group.

[0183] It can be understood that in some embodiments, the electronic device can also process the IO requests of each sub-group in other orders. The priority can indicate the IO resource quota, and the above-mentioned processing of the second IO requests of each sub-group in order of priority from high to low can also be understood as processing the second IO requests of each sub-group in order of IO resource quota from high to low.

[0184] As mentioned above, the resource scheduling module can store the IO requests of each group through a queue, as shown in FIG. 4, the IO scheduling module can store the IO requests of the first group sg in the group queue Q_sg, store the IO requests of the foreground group fg in the group queue Q_fg, store the IO requests of the key background group bg1 in the group queue Q_bg1, and store the IO requests of the non-key background group bg2 in the group queue Q_bg2. Wherein, the group queue Q_sg is the first group queue, and the group queue Q_fg, the group queue Q_bg1 and the group queue Q_bg2 are the second group queue.

[0185] The IO scheduling module can process the IO requests of each group queue through an IO request processing thread.

[0186] When processing the first IO request, the IO scheduling module can access the group queue IOQ_sg at intervals, and if the first IO request exists in the queue, the first IO request can be issued to the IO driver for processing.

[0187] Specifically, the IO scheduling module can access the group queue IOQ_sg once every certain time length, or can access the group queue Q_sg once after processing one or more second IO requests.

[0188] In some embodiments, when processing the first IO request, the IO scheduling module can detect whether the first IO request exists in the first group queue (i.e., whether the first IO request exists in the group queue Q_sg) before scheduling each second IO request; when the first IO request exists, the first IO request is scheduled and issued to the IO driver for processing, so as to improve the response speed of the first IO request.

[0189] In each time of accessing the group queue Q_sg, one first IO request can be extracted and issued to the IO driver for processing, or all the first IO requests in the group queue can be extracted and issued to the IO driver for processing.

[0190] When processing the second IO request, the IO scheduling module can traverse the group queues (i.e., the second group queues) of the subgroups in each scheduling period in the order of priority from high to low; for the second group queue traversed, the second IO request in the group queue can exist, and the sub-group has a remaining IO resource quota; in this case, the second IO request in the group queue is scheduled, and the remaining IO resource quota of the sub-group can be updated.

[0191] In each time of accessing the group queue Q_sg, one first IO request can be extracted and issued to the IO driver for processing, or all the first IO requests in the group queue can be extracted and issued to the IO driver for processing.

[0192] In each scheduling period, for each subgroup, in some implementations, a scheduling upper limit can be set, i.e., in the case that the remaining IO resource quota of the subgroup is sufficient, the number of first IO requests of the subgroup scheduled does not exceed the scheduling upper limit of the subgroup; in some implementations, in the case that the remaining IO resource quota of the subgroup is sufficient, all the second IO requests of the subgroup can be scheduled.

[0193] The following exemplary describes a specific IO request scheduling process.

[0194] Referring to FIG. 6, FIG. 6 is a schematic diagram of an IO request scheduling process provided by an embodiment of the present application, as shown in FIG. 6, the IO scheduling process of the IO scheduling module in each scheduling period can include the following steps when performing IO scheduling:

[0195] S201, start traversing the second group queues.

[0196] As described above, the second group queues include the group queue Q_fg of the foreground group, the group queue Q_bg1 of the critical background group, and the group queue Q_bg2 of the non-critical background group.

[0197] The IO scheduling module can traverse the second packet queues in order of priority from high to low, that is, traverse the packet queue Q_fg, the packet queue Q_bg1 and the packet queue Q_bg2 in order from front to back.

[0198] It can be understood that in some embodiments, the IO scheduling module can also traverse the second packet queues in other orders.

[0199] S202, traverse the packet queue of the foreground packet.

[0200] The packet queue of the foreground packet in the second packet queues has the highest priority, and the IO scheduling module can first traverse the packet queue Q_fg of the foreground packet after starting to traverse the second packet queues in order of priority.

[0201] S203, determine whether there is an IO request in the first packet queue, if yes, execute step S204, otherwise execute step S205.

[0202] The IO scheduling module can first determine whether there is an IO request in the first packet queue (that is, the packet queue Q_sg) before scheduling the current packet queue (that is, the packet queue Q_fg of the foreground packet) that is traversed, so as to preferentially process the IO request of the first packet.

[0203] S204, extract an IO request from the first packet queue and issue it to the IO driver.

[0204] If there is an IO request in the first packet queue, the IO scheduling module can extract an IO request from the first packet queue and issue it to the IO driver; then return to execute the above step S203 to continue to determine whether there is an IO request in the first packet queue until there is no IO request in the first packet queue.

[0205] S205, determine whether there is an IO request in the current packet queue that is traversed, if yes, execute step S207, otherwise execute step S206.

[0206] If there is no IO request in the first packet queue, the IO scheduling module can start to process the IO request of the second packet queue.

[0207] Specifically, the IO scheduling module can determine whether there is an IO request in the current packet queue (the first current packet queue is the packet queue Q_fg of the foreground packet) that is traversed. If there is an IO request in the current packet queue, the IO request can be processed; if there is no IO request in the current packet queue, the next second packet queue can be continued to be traversed.

[0208] S206, traverse the next second packet queue.

[0209] As described above, if there is no IO request in the current group queue being traversed, no processing is needed, and the next second group queue can be traversed, and then the step S205 is returned to judge whether there is an IO request in the current group queue being traversed.

[0210] For example, there is no IO request in the group queue Q_fg of the foreground group being traversed, the next second group queue, i.e., the group queue Q_bg1 of the critical background group, can be traversed, and then it is judged whether there is an IO request in the group queue Q_bg1 of the critical background group.

[0211] S207, it is judged whether there is a remaining IO resource quota in the current group queue, if yes, the step S208 is executed, otherwise, the step S205 is executed.

[0212] If there is an IO request in the current group queue being traversed, the IO scheduling module can first judge whether there is a remaining IO resource quota in the group queue before scheduling. The remaining IO resource quota of the current group queue is the remaining IO resource quota of the sub-group corresponding to the current group queue, i.e., the remaining IO resource that can be used by the group queue. The IO resource of the group can be the IOPS or BPS described above.

[0213] If there is a remaining IO resource quota in the current group queue, an IO request can be extracted from the group queue for scheduling; if there is no remaining IO resource quota in the current group queue, the step S206 described above can be executed to traverse the next second group queue to continue processing the IO request of the next second group queue.

[0214] S208, an IO request is extracted from the current group queue and issued to the IO driver, and the remaining IO resource quota of the current group queue is updated.

[0215] If there is an IO request in the current group queue being traversed and there is a remaining IO resource quota, the IO scheduling module can extract an IO request from the group queue and issue it to the IO driver, and then the step S203 described above can be returned to judge whether there is an IO request in the first group queue.

[0216] In addition to extracting the IO request from the current group queue and issuing it to the IO driver, the IO scheduling module can also update the remaining IO resource quota of the current group queue, i.e., subtract the IO resource used by the current scheduled IO request from the original remaining IO resource quota, for example, reduce the IOPS of the current group queue by 1.

[0217] As mentioned above, the IO scheduling module can update the remaining IO resource quota of the current grouping queue after the IO request is issued to the IO driver, or can update the remaining IO resource quota of the current grouping queue at the same time when the IO request is issued to the IO driver.

[0218] It can be understood that in some embodiments, step S205 can be directly executed after step S202 is executed.

[0219] As mentioned above, the second grouping can also have only one grouping, and correspondingly, the IO request of the second grouping can be stored in one grouping queue. Then in each scheduling period, the IO scheduling module can not execute steps S201, S202 and S206, and when there is no IO request in the grouping queue of the second grouping or there is no remaining IO resource quota, the current scheduling period is ended and the next scheduling period is started.

[0220] In some embodiments, the memory application request of each grouping can also be processed according to the memory resource quota of the grouping in a manner similar to the IO request.

[0221] The memory resource quota of the first grouping is equivalent to an unlimited quota, and the memory application request of the first task is processed after the first task initiates the memory application request.

[0222] For the memory application request of the second task, the execution of the second task can be temporarily blocked when the remaining memory resource quota of the second grouping is insufficient, and the memory application request of the second task is processed when the remaining memory resource quota of the second grouping is sufficient.

[0223] The memory management module can process the memory application request according to the above-mentioned free memory threshold (such as pages_low and pages_min).

[0224] In order to further improve the smoothness of application running, in some embodiments, the following step S300 can be executed to reduce the memory application time of the first grouping.

[0225] S300, when the free memory is lower than the direct memory recovery threshold, if the first task of the first grouping initiates a memory application request, memory is allocated to the first task from the free memory; if the second task of the second grouping initiates a memory application request, memory is allocated to the second task after direct memory recovery.

[0226] Specifically, when the memory management module processes a memory request from the second task, if the free memory is below the direct memory reclamation threshold (i.e., pages_min), it can perform direct memory reclamation as described above, that is, reclamation occurs while the second task is blocked. After sufficient memory is reclaimed, the memory management module allocates memory to the second task. For example, the memory management module can stop performing direct memory reclamation and allocate memory to the second task when the free memory reaches or exceeds the direct memory reclamation threshold.

[0227] Understandably, when direct memory reclamation is insufficient, further memory reclamation can be achieved by destroying processes. While performing direct memory reclamation, the memory management module can also invoke the kswapd thread for background memory reclamation until free memory reaches or exceeds the aforementioned page height threshold (pages_high).

[0228] When processing a memory request from the first task, if the free memory is below the direct memory reclamation threshold, the memory management module can continue to allocate memory for the first task without blocking its execution. In other words, for a memory request from the first task, the direct memory reclamation threshold can be ignored, and free memory below the threshold can be used to allocate memory for the first task.

[0229] It is understandable that when allocating memory for the first task, memory can also be reclaimed asynchronously in the background until the free memory reaches or exceeds the page height threshold (pages_high); correspondingly, the memory allocated for the first task can also include the memory reclaimed in the background.

[0230] To reduce the risk of memory exhaustion, in some embodiments, a memory threshold lower than the direct memory reclamation threshold can be further set. The memory management module can allocate memory for the first task from the free memory when the free memory is less than or equal to the memory threshold and lower than the direct memory reclamation threshold; when the free memory is lower than the memory threshold, the first task is blocked and direct memory reclamation is performed; when the free memory after reclamation reaches or exceeds the memory threshold, direct memory reclamation is stopped and memory is allocated for the first task.

[0231] Those skilled in the art will understand that the above embodiments are exemplary and not intended to limit this application. Where possible, the execution order of one or more of the above steps can be adjusted, or they can be selectively combined to obtain one or more other embodiments.

[0232] For example, there is no strict time sequence relationship between the steps S100, S200 and S300 described above. For any two steps, one of the steps can be executed before or after the other step, or can be executed simultaneously.

[0233] For another example, in some embodiments, any one or two of the steps S100, S200 and S300 described above can not be included.

[0234] Those skilled in the art can select and combine any of the above steps as needed, as long as the spirit of the present application is not deviated, it falls within the protection scope of the present application.

[0235] The resource scheduling method provided by the embodiments of the present application divides the drawing thread affecting the fluency of the foreground application into the first group, divides other application tasks outside the first task into the second group, adopts the pre-emptive scheduling manner to schedule the IO request of the first group, and schedules the IO request of the second group according to the resource quota. In this way, the response speed of the drawing thread can be improved, so that the startup or display time consumption of the foreground application can be reduced, and the fluency of the application running can be improved.

[0236] FIG. 7 is a flowchart of a resource scheduling method provided by another embodiment of the present application. The execution subject of the method is an electronic device. As shown in FIG. 7, the method provided by the embodiment can include the following steps:

[0237] S701, scheduling the IO request of the first group by using the pre-emptive scheduling manner.

[0238] The first group can include the drawing thread of the foreground application. The processing time consumption of the IO request of the drawing thread affects the interface display fluency of the foreground application. In the embodiment of the present application, the pre-emptive scheduling manner is adopted to schedule the IO request of the drawing thread, so that the processing time consumption of the IO request of the drawing thread can be reduced, and the running fluency of the foreground application can be improved.

[0239] Optionally, the drawing thread can include a UI thread and a rendering thread. It can be understood that the drawing thread can also include other threads related to interface drawing.

[0240] As described in step S200, the first group does not limit the resource quota, and the resource quota thereof is equivalent to an unlimited quota. When the first group has an IO request, the electronic device pre-emptively schedules the IO request.

[0241] In some implementations, the electronic device can check whether the first group has an IO request once per IO request of the second group, and schedule the IO request of the first group if the first group has an IO request. In some implementations, the electronic device can also check whether the first group has an IO request after processing multiple (e.g., two) IO requests of the second group, and schedule the IO request of the first group.

[0242] In some implementations, the IO requests of the first group can be stored in a queue, and the electronic device can extract the IO requests from the queue one by one when scheduling the IO requests of the first group, and issue the IO requests to the IO driver for processing.

[0243] In some embodiments, the first group can be updated. Specifically, the electronic device can monitor the running state of each application, and update the group to which the application task of the first application belongs when the running state of the first application changes, where the first application can be any application.

[0244] For example, when the first application switches to a foreground running state, the rendering thread of the first application can be divided into the first group, and the electronic device can use a preemptive scheduling manner to schedule the IO request initiated by the rendering thread of the first application.

[0245] For the scheduling and updating of the first group, please refer to the related description in the foregoing embodiments.

[0246] S702, schedule the IO request of the second group according to the IO resource quota of the second group.

[0247] The second group can include non-rendering threads of foreground applications and / or background applications.

[0248] Specifically, the IO request of the second group can be scheduled when the second group has an IO request and has a remaining IO resource quota.

[0249] In some implementations, the IO requests of the second group can be stored in a queue, and the electronic device can extract the IO requests from the queue one by one when scheduling the IO requests of the second group, and issue the IO requests to the IO driver for processing.

[0250] In some implementations, the second group can include one sub-group; in some implementations, the second group can include multiple sub-groups to better schedule resources.

[0251] In some embodiments, the second group can include one or more of a foreground group, a critical background group, and a non-critical background group; the foreground group can include threads other than the rendering thread of a foreground application, the critical background group can include a perceivable background task, and the non-critical background group can include other background tasks other than the perceivable background task.

[0252] In some embodiments, the IO resource quota of the foreground group and the critical background group are both higher than the IO resource quota of the non-critical background group.

[0253] In some implementations, the IO resource quota of the critical background group is lower than the IO resource quota of the foreground group; in some implementations, the IO resource quota of the critical background group is equal to the IO resource quota of the foreground group.

[0254] The perceivable background task can be a perceivable background application or a perceivable thread / process of a background application.

[0255] For the case where the second group includes multiple sub-groups, the electronic device can sequentially traverse each sub-group in each scheduling period, and for the traversed sub-group, schedule the IO request of the sub-group according to the IO resource quota of the sub-group.

[0256] In some embodiments, the second group can be updated. As described above, the electronic device can monitor the running state of each application, and when the running state of the first application changes, update the group to which the application task corresponding to the first application belongs, where the first application can be any application.

[0257] For example, the first application switches from a foreground running state to a background running state, and the first application can be divided into the second group. For the IO request initiated by the first application, the electronic device can schedule the IO request according to the IO resource quota of the second group.

[0258] For other descriptions of the scheduling and updating of the second group, please refer to the related descriptions in the foregoing embodiments.

[0259] It can be understood that the foregoing step S701 can be executed before step S702 or after step S702.

[0260] The resource scheduling method provided by the embodiment divides the rendering thread that affects the smoothness of the foreground application into the first group, divides the non-rendering thread and / or the background application into the second group, schedules the IO request of the first group in a preemptive manner, and schedules the IO request of the second group according to the IO resource quota of the second group. This can improve the response speed of the rendering thread, thereby reducing the startup or display time consumption of the foreground application and improving the smoothness of the foreground application running.

[0261] Based on the same concept, as an implementation of the above method, the embodiment of the application provides a resource scheduling device. The device embodiment corresponds to the foregoing method embodiment. For ease of reading, the details of the foregoing method embodiment will not be described one by one in the device embodiment, but it should be clear that the device in the embodiment can correspondingly implement all the contents in the foregoing method embodiment.

[0262] FIG. 8 is a structural schematic diagram of a resource scheduling device provided by an embodiment of the application. As shown in FIG. 8, the device provided by the embodiment includes:

[0263] A first scheduling module 801 is configured to schedule IO requests of a first group in a preemptive scheduling manner; the first group includes a drawing thread of a foreground application.

[0264] A second scheduling module 802 is configured to schedule IO requests of a second group according to an IO resource quota of the second group; the second group includes a non-drawing thread of the foreground application and / or a background application.

[0265] In a possible implementation, the drawing thread includes a UI thread and a rendering thread.

[0266] In a possible implementation, the second group includes a foreground group, a critical background group, and a non-critical background group; the foreground group includes threads other than the drawing thread of the foreground application, the critical background group includes a perceivable background task, and the non-critical background group includes other background tasks other than the perceivable background task.

[0267] The IO resource quota of the foreground group and the critical background group is higher than the IO resource quota of the non-critical background group.

[0268] In a possible implementation, the IO resource quota of the critical background group is lower than or equal to the IO resource quota of the foreground group.

[0269] In a possible implementation, the device further includes:

[0270] A group updating module 803 is configured to update a group to which an application task corresponding to a first application belongs when a running state of the first application changes; the first application is an arbitrary application.

[0271] In a possible implementation, the group updating module 803 is specifically configured to:

[0272] When the first application switches to a foreground running state, the drawing thread of the first application is divided into the first group, and the non-drawing thread of the first application is divided into the foreground group.

[0273] In a possible implementation, the group updating module 803 is further configured to:

[0274] When the first application switches to the background running state, if the first application belongs to the perceivable background application, the first application is divided into the critical background group; if the first application does not belong to the perceivable background application, the first application is divided into the non-critical background group.

[0275] Alternatively,

[0276] When the first application switches to the background running state, if the first application includes a target task, the target task of the first application is divided into the critical background group, and the non-target task of the first application is divided into the non-critical background group; if the first application does not include the target task, the first application is divided into the non-critical background group; the target task includes a perceivable background process or thread.

[0277] In a possible implementation, the first scheduling module 801 is specifically configured to:

[0278] Before scheduling each IO request of the second group, if there is an IO request of the first group, the IO request of the first group is scheduled.

[0279] In a possible implementation, the second group includes a plurality of subgroups, each subgroup has a corresponding IO resource quota, and the IO request of each subgroup is stored in a subgroup corresponding group queue; the second scheduling module 802 is specifically configured to:

[0280] In each scheduling period, the group queues of the subgroups are traversed in descending order of the IO resource quotas of the subgroups.

[0281] For the group queue of the subgroup traversed, when there is an IO request in the group queue and the subgroup has a remaining IO resource quota, the IO request in the group queue is scheduled, and the remaining IO resource quota of the subgroup is updated.

[0282] The apparatus provided in this embodiment can execute the method embodiments described above, and has similar implementation principles and technical effects, which will not be described here again.

[0283] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is exemplified, and in actual application, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to complete all or part of the above described functions. The functional units and modules in the embodiments can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit, and the integrated unit can be realized in the form of hardware or software. In addition, the specific names of the functional units and modules are only for easy distinction, and do not limit the protection scope of the application. The specific working process of the units and modules in the system can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0284] Based on the same concept, the embodiments of the present application also provide an electronic device, please refer to Figure 9, Figure 9 is the structural schematic diagram of the electronic device provided by the embodiments of the present application.

[0285] The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0286] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than illustrated, or combine certain components, or split certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.

[0287] The processor 110 can include one or more processing units, for example: the processor 110 can 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), etc. Different processing units can be independent devices or integrated in one or more processors.

[0288] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.

[0289] The processor 110 can also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can directly call from the memory. This avoids repeated access and reduces the waiting time of the processor 110, thereby improving the efficiency of the system.

[0290] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can 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, etc.

[0291] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). The I2S interface can be used for audio communication. The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. The UART interface is a universal serial data bus used for asynchronous communication; the bus can be a bidirectional communication bus that converts data to be transmitted between serial communication and parallel communication. The MIPI interface can be used to connect the processor 110 and peripheral devices such as the display screen 194 and the camera 193; the MIPI interface includes a camera serial interface (CSI), a display screen serial interface (DSI), and the like. The GPIO interface can be configured by software, and the GPIO interface can be configured as a control signal or as a data signal. The USB interface 130 is an interface that meets the USB standard specification, and can be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and a peripheral device. It can also be used to connect a headset to play audio through the headset. The interface can also be used to connect to other electronic devices, such as AR devices, and the like.

[0292] It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative and does not constitute a structural limitation of the electronic device 100. In some other embodiments of the present application, the electronic device 100 can also use different interface connection methods or combinations of multiple interface connection methods in the above embodiments.

[0293] The charging management module 140 is configured to receive charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input through the wireless charging coil of the electronic device 100. The charging management module 140 can charge the battery 142 while also providing power to the electronic device through the power management module 141.

[0294] The power management module 141 is configured to connect the battery 142 and the charging management module 140 to the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 can also be configured to monitor parameters such as the battery capacity, the number of battery cycles, the battery health status (leakage, impedance), and the like. In some embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.

[0295] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, and the like.

[0296] The antenna 1 and the antenna 2 are configured to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be configured to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in combination with a tuning switch.

[0297] The mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G and the like applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter, amplify, and the like the received electromagnetic waves, and transmit the processed signals to the modem processor for demodulation. The mobile communication module 150 can also amplify signals modulated by the modem processor and radiate the signals as electromagnetic waves through the antenna 1. In some embodiments, at least part of the functional modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 can be disposed in the same device.

[0298] The modem processor can include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is configured to demodulate a received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal processed by the baseband processor is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a microphone 170B, etc.), or displays an image or a video through the display 194. In some embodiments, the modem processor can be a separate device. In other embodiments, the modem processor can be independent of the processor 110 and disposed in the same device as the mobile communication module 150 or other functional modules.

[0299] The wireless communication module 160 can provide a wireless communication solution applied to the electronic device 100, including wireless local area networks (WLAN) (e.g., a wireless fidelity (Wi-Fi) network), Bluetooth (BT), a global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signal, and transmits the processed signal to the processor 110. The wireless communication module 160 can also receive a signal to be transmitted from the processor 110, perform frequency modulation, amplification, and convert the signal into electromagnetic wave radiation via the antenna 2.

[0300] In some embodiments, the antenna 1 and the mobile communication module 150 of the electronic device 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology. The wireless communication technology can include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time division-synchronous code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include a global positioning system (GPS), a global navigation satellite system (GNSS), a beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and / or a satellite based augmentation systems (SBAS).

[0301] The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs, which execute program instructions to generate or change display information.

[0302] The display screen 194 is configured to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Mini LED, a Micro LED, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.

[0303] The electronic device 100 can implement a photographing function through an ISP, the camera 193, a video codec, a GPU, the display screen 194, and an application processor, and the like.

[0304] The ISP is configured to process data fed back by the camera 193. The camera 193 is configured to capture still images or videos. The digital signal processor is configured to process digital signals, which can be digital image signals and other digital signals. The video codec is configured to compress or decompress digital videos.

[0305] The NPU is a neural-network (NN) computing processor, which is configured to process input information quickly by referring to a biological neural network structure, for example, by referring to a transmission mode between neurons in a human brain, and can be self-learned constantly. Through the NPU, intelligent cognition of the electronic device 100 can be implemented, for example, image recognition, face recognition, voice recognition, text understanding, and the like.

[0306] The internal memory 121 can be used to store computer executable program codes including instructions. The processor 110 performs 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 can include a program storage area and a data storage area. The program storage area can store an operating system and at least one application program (such as a sound play function, an image play function, etc.) required by a function. The data storage area can store data (such as audio data, a phone book, etc.) created during use of the electronic device 100. In addition, the internal memory 121 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0307] The external memory interface 120 can be used to connect an external memory 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 through the external memory interface 120 to implement a data storage function. For example, files such as music, videos, etc. are saved in the external memory card.

[0308] The electronic device 100 can implement an audio function through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, etc. For example, music play, recording, etc.

[0309] The audio module 170 is used to convert digital audio information into an analog audio signal output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used to encode and decode an audio signal. In some embodiments, the audio module 170 can be disposed in the processor 110, or part of the functions of the audio module 170 can be disposed in the processor 110. The speaker 170A, also known as a "loudspeaker", is used to convert an audio electrical signal into a sound signal. The receiver 170B, also known as a "earpiece", is used to convert an audio electrical signal into a sound signal. The microphone 170C, also known as a "microphone", "sound transducer", is used to convert a sound signal into an electrical signal. The earphone interface 170D is used to connect a wired earphone. The earphone interface 170D can be a USB interface 130, or a 3.5 mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0310] The keys 190 include a power key, a volume key, and the like. The keys 190 can be mechanical keys. The keys 190 can also be touch keys. The electronic device 100 can receive a key input, and generate a key signal input related to user settings and function control of the electronic device 100. The motor 191 can generate a vibration prompt. The motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 192 can be an indicator light, and can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, and the like. The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to achieve contact and separation with the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, and N is a positive integer greater than 1. The SIM card interface 195 can support a Nano SIM card, a Micro SIM card, a SIM card, and the like.

[0311] The electronic device provided in the embodiment can execute the method embodiments described above, and the implementation principle and technical effects are similar, which will not be described here.

[0312] As shown in FIG. 10, the embodiment of the present application further provides a chip system, comprising a processor, the processor is coupled with a memory, and the processor executes a computer program stored in the memory to realize the method described in the above method embodiments. Wherein, the chip system can be a single chip, or a chip module composed of multiple chips.

[0313] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the method described in the above method embodiments.

[0314] The embodiment of the present application further provides a computer program product, when the computer program product runs on an electronic device, so that the electronic device executes to realize the method described in the above method embodiments.

[0315] In the embodiments described above, all or some of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or some of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into and executed by a computer, all or some of the procedures or functions described in the embodiments of the present application are performed. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatuses. The computer instructions can be stored in or transmitted from a computer readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (such as a floppy disk, a hard disk or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0316] It should be understood that the processor mentioned in the embodiments of the present application can be a central processing unit (CPU), and can also be other general purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0317] It should also be understood that the memory mentioned in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM), a flash memory (Flash), a multi media card (MMC), an embedded multi media card (eMMC) or an SSD, etc. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM) and direct rambus RAM (DR RAM).

[0318] The naming or numbering of the steps appearing in the present application does not mean that the steps in the method flow must be executed in the time / logical order indicated by the naming or numbering. The flow steps that have been named or numbered can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.

[0319] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in a certain embodiment can be referred to the related description of other embodiments.

[0320] In the embodiments of the present disclosure, it should be understood that the disclosed apparatuses / devices and methods can be implemented in other manners. For example, the embodiments of the apparatuses / devices described above are merely schematic. For example, the division of the modules or units is merely logical function division. There can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, can be indirect couplings or communication connections through some interfaces, devices or units.

[0321] It should be understood that the terms "comprise", "comprising", "including", "including", "have", "having", and any variations thereof in the description and the appended claims of the present application are intended to cover non-exclusive inclusion, and mean "including but not limited to", unless otherwise specifically emphasized. For example, a process, method, system, product or device that includes a series of steps or modules does not necessarily limit to those steps or modules clearly listed, but can include other steps or modules not clearly listed or inherent to these processes, methods, products or devices.

[0322] In the description of the present application, unless otherwise specified, " / " means that the associated objects before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in the present application is used to describe the association relationship of the associated objects, which means that there can be three kinds of relationships, for example, A and / or B, which can represent: A alone, A and B exist at the same time, and B alone, where A and B can be singular or plural.

[0323] Also, in the description of the present application, unless otherwise specified, "multiple" means two or more than two. "At least one of the following" or similar expressions means any combination of the items, including any combination of single or multiple items. For example, at least one of a, b, or c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.

[0324] As used in the specification and the appended claims of the present application, the term "if" can be interpreted as "when" or "upon" or "in response to a determination" or "in response to detecting" depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted as meaning "upon determining" or "in response to determining" or "upon detecting [a described condition or event]" or "in response to detecting [a described condition or event]" depending on the context.

[0325] In addition, in the description and drawings of the present application, the terms "first", "second", and the like are used to distinguish similar objects from each other, and are not necessarily used to describe a particular sequential or chronological order, nor are they used to indicate or imply relative importance or a particular number of features. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments described herein can be implemented in an order other than that illustrated or described herein; the features defined with "first", "second" can explicitly or implicitly include at least one of the features.

[0326] In the embodiments of the present application, the words "exemplarily" or "for example" and the like are used to represent as an example, illustration or description. Any embodiment or design scheme described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the use of "exemplarily" or "for example" and the like is intended to present the relevant concept in a specific manner.

[0327] In the embodiments of the present application, the reference "one embodiment" or "some embodiments" and the like means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in further some embodiments" and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that the technical solutions recorded in the foregoing embodiments can still be modified, or some or all of the technical features can be replaced by equivalents; and such modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

A resource scheduling method, characterized in that, Applied to electronic devices, the method includes: The IO requests of the first group are scheduled using a preemptive scheduling method; the first group includes the drawing thread of the foreground application. I / O requests for the second group are scheduled according to the I / O resource quota of the second group; the second group includes non-drawing threads of foreground applications and / or background applications. The method according to claim 1, characterized in that, The drawing thread includes the UI thread and the rendering thread. The method according to claim 1 or 2, characterized in that, The second grouping includes: a foreground group, a critical background group, and a non-critical background group; the foreground group includes threads of the foreground application other than the drawing thread, the critical background group includes perceptible background tasks, and the non-critical background group includes other background tasks other than the perceptible background tasks. The IO resource quotas for the front-end group and the critical back-end group are both higher than the IO resource quotas for the non-critical back-end group. The method according to claim 3, characterized in that, The IO resource quota of the key backend group is lower than or equal to the IO resource quota of the frontend group. The method according to claim 3 or 4, characterized in that, The method further includes: When the running status of the first application changes, update the group to which the application task corresponding to the first application belongs. The first application can be any application. The method according to claim 5, characterized in that, The step of updating the group to which the application task corresponding to the first application belongs when the running state of the first application changes includes: When the first application switches to the foreground running state, the drawing thread of the first application is assigned to the first group, and the non-drawing thread of the first application is assigned to the foreground group. The method according to claim 6, characterized in that, The method further includes: When the first application switches to background running state, if the first application is a perceptible background application, then the first application is assigned to the critical background group; if the first application is not a perceptible background application, then the first application is assigned to the non-critical background group. or, When the first application switches to background running state, if the first application includes a target task, the target task of the first application is assigned to the critical background group, and the non-target tasks of the first application are assigned to the non-critical background group; if the first application does not include a target task, the first application is assigned to the non-critical background group; the target task includes a perceptible background process or thread. The method according to any one of claims 1-7, characterized in that, The preemptive scheduling method for scheduling the IO requests of the first group includes: Before scheduling each IO request of the second group, if there is an IO request in the first group, then the IO request of the first group is scheduled. The method according to any one of claims 1-8, characterized in that, The second group includes multiple subgroups, each subgroup has a corresponding IO resource quota, and the IO requests of each subgroup are stored in the group queue corresponding to the subgroup; The step of scheduling IO requests for the second group according to the IO resource quota of the second group includes: In each scheduling cycle, the group queues of each subgroup are traversed in descending order of IO resource quota; For the group queue of the traversed subgroup, when there is an IO request in the group queue and the subgroup has remaining IO resource quota, the IO request in the group queue is scheduled and the remaining IO resource quota of the subgroup is updated. An electronic device, characterized in that, include: A memory and a processor, wherein the memory is used to store computer programs; The processor is configured to perform the method as described in any one of claims 1-9 when the computer program is invoked. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-9. A computer program product, characterized in that, When the computer program product is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1-9. A chip system, characterized in that, The chip system includes a processor coupled to a memory, the processor executing a computer program stored in the memory to implement the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Virtual desktop oriented VCPU (Virtual Central Processing Unit) scheduling method

    CN106020980A

  • Resource scheduling method and electronic equipment

    CN110489228A

  • Resource scheduling method and device, electronic equipment and storage medium

    CN111338785A

  • Resource allocation method, device and equipment

    CN117130773A

  • Terminal resource scheduling method and device, terminal and computer readable storage medium

    CN117389711A