Thread scheduling method and related device
Patent Information
- Application Number
- CN202510229631.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2026-08-28
AI Technical Summary
最后对该线程的优先级进行设置的模块所设置的优先级可能不能满足系统中其他模块该线程的优先级的需求,导致关键任务无法及时获得处理器的处理资源,而次要任务却占用了过多资源,从而影响整个系统的性能
Smart Images

Figure CN122653760A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and more specifically, to a thread scheduling method and related devices. Background Technology
[0002] Electronic devices assign different priorities to threads based on their nature and needs. Higher-priority threads typically indicate more urgent or important tasks that require immediate execution. When a high-priority thread becomes ready, the operating system immediately suspends the currently executing lower-priority thread and allocates processor resources to the high-priority thread. This preemptive scheduling ensures that important tasks are processed promptly. Multiple modules within an electronic device can set thread priorities. In some cases, conflicting priority settings may exist between different modules.
[0003] Thread priority is a key factor determining the execution order of threads in a multithreaded environment. When multiple modules have conflicting priority settings for the same thread, the thread's final priority is the one set by the module that last set its priority. The priority set by the module that last set the thread's priority may not meet the priority requirements of other modules in the system, causing critical tasks to miss processor resources while less important tasks consume excessive resources, thus impacting the overall system performance. Summary of the Invention
[0004] This application provides a thread scheduling method and related devices, which can make the priority of the target thread more in line with the requirements and improve system performance.
[0005] Firstly, a thread scheduling method is provided, applied to an electronic device. The method includes: during the execution of a target thread in the electronic device, acquiring multiple importance information configured for the target thread by multiple modules in the electronic device, each importance information indicating whether to increase the importance of the target thread to or de-increase it to one of at least one preset importance level; determining a target parameter value corresponding to each preset importance level based on the multiple importance information, the target parameter value indicating whether it is necessary to increase the importance of the target thread to the corresponding preset importance level; and determining a target importance level for the target thread based on the target parameter value corresponding to each preset importance level, the target importance level indicating the priority of the target thread.
[0006] The thread scheduling method provided in this application determines target parameter values indicating whether the target thread's importance needs to be increased to each preset importance level based on multiple importance information configured for the target thread by different modules. Then, based on the target parameter values, it determines the target importance level indicating the priority of the target thread. Thus, the setting of the target importance level comprehensively considers the importance requirements of different modules for the target thread, making the determined target importance level more in line with system requirements.
[0007] In some possible implementations, for any one of the at least one preset importance level, if the first importance information is not included in the plurality of importance information, the target parameter value corresponding to the preset importance level is 0, and the first importance information indicates whether to increase or cancel the increase of the importance of the target thread to the preset importance level; if the plurality of importance information includes at least one first importance information, the target parameter value corresponding to the preset importance level is positively correlated with a target difference, where the target difference is the difference between the increase quantity and the cancellation quantity, the increase quantity is the number of first importance information obtained before the current time indicating that the importance of the target thread should be increased to the preset importance level, and the cancellation quantity is the number of times the at least one first importance information indicates that the importance of the target thread should be canceled to the preset importance level before the current time. Where the target parameter value corresponding to any preset importance level is greater than or equal to 1, the target parameter value corresponding to any preset importance level indicates that the importance of the target thread needs to be increased to the preset importance level.
[0008] For any preset importance level, the target parameter value is positively correlated with the target difference. The target difference is the difference between the number of information indicating improvement among multiple importance level information and the number of times the improvement was canceled before the current time. This makes the target parameter value more accurately reflect whether the need to improve to the preset importance level exists, and makes the determined target importance level more in line with the needs, thereby improving system performance.
[0009] In some possible implementations, the number of cancellation promotions is determined based on a first number and / or a second number. The first number is the number of pieces of information in the at least one first importance information that indicate the cancellation of promotion of the target thread to any one of the preset importance levels. The second number is the number of pieces of information in the at least one first importance information that satisfy the duration condition. Any first importance information in the at least one first importance information that satisfies the duration condition means that: any first importance information includes a first duration, and the duration elapsed after obtaining any first importance information is greater than or equal to the first duration included in any first importance information. The first duration in any first importance information represents the duration for promoting the target thread to the preset importance level.
[0010] The number of cancellations for promotion can be a first number, a second number, or the sum of the first and second numbers. For example, when none of the first importance indication information includes a first duration, the number of cancellations can be the first number. When all of the first importance indication information includes a first duration, the number of cancellations can be the second number. When some of the first importance indication information includes a first duration and some does not, the number of cancellations can be the sum of the first and second numbers. Therefore, the method provided in this application is applicable to scenarios where the module indicates cancellation of promotion to a preset importance level through different methods of importance information, and has wider applicability and flexibility.
[0011] In some possible implementations, determining the target parameter value corresponding to each of the at least one preset importance level based on the plurality of importance information includes: when any first importance information is obtained, if the first importance information indicates that the importance of the target thread should be increased to any one of the preset importance levels and excluding the first duration, then the target parameter value corresponding to the any one preset importance level is incremented by 1; if the first importance information indicates that the importance of the target thread should be increased to any one of the preset importance levels and excluding the first duration, then the target parameter value corresponding to the any one preset importance level is incremented by 1, and after the first duration, the target parameter value corresponding to the any one preset importance level is decremented by 1; if the first importance information indicates that the importance of the target thread should be canceled from being increased to any one of the preset importance levels, then the target parameter value corresponding to the any one preset importance level is decremented by 1.
[0012] Based on the importance information, the target parameter value can be updated by adding 1 and / or subtracting 1 for each preset importance level. This eliminates the need to separately count the number of increases and decreases, making the determination of the target parameter value simpler and more efficient.
[0013] In some possible implementations, upon acquiring any first importance information, if the arbitrary first importance information indicates that the importance of the target thread should be increased to any preset importance, and the arbitrary first importance information does not include a first duration, then a marking time is determined. The first duration represents the duration for increasing the importance of the target thread to any preset importance, and the marking time is after the acquisition time of the arbitrary first importance information and between the acquisition time and the acquisition time is a time interval threshold. If the arbitrary first importance information indicates that the importance of the target thread should be canceled from being increased to any preset importance, then the marking time determined after the current time is deleted. If the current time is a marking time, the target parameter value corresponding to any preset importance is decremented by 1.
[0014] Based on updating the target parameter values corresponding to each preset importance level according to the "promotion" and "depromotion" indications of importance information, a marker time with a duration threshold is set between the time interval of receiving the importance information used to promote the target thread to the preset importance level and the time interval of this importance information not including a first duration. This marker time is deleted when the importance information indicating cancellation of promotion to the preset importance level is received. This allows for the identification of anomalies at the marker time, and recovery from anomalies by decrementing the target parameter value corresponding to any of the preset importance levels by 1 at the marker time. Even if an anomaly occurs after the module is configured to indicate promotion to the preset importance level, it also prevents the target thread from monopolizing processing resources for an extended period, improving system stability. Furthermore, by setting and deleting the marker time, and decrementing the target parameter value by 1 at the marker time, the method of updating the target parameter value based on the duration threshold is simplified.
[0015] In some possible implementations, determining the target importance of the target thread based on the target parameter value corresponding to each preset importance level includes: when there is at least one candidate importance level among multiple preset importance levels, determining the target importance level as the highest importance level among the at least one candidate importance level, wherein the target parameter value corresponding to each candidate importance level indicates that the importance level of the target thread needs to be increased to the corresponding preset importance level; when there is no candidate importance level among multiple preset importance levels, determining the target importance level as the initial importance level, wherein the initial importance level is lower than each preset importance level.
[0016] The target thread's importance level is the highest level of importance required, which better aligns with the importance requirements of various modules in electronic devices for the target thread.
[0017] In some possible implementations, the method further includes: determining a target mapping relationship corresponding to a target load range based on the correspondence between load range and mapping relationship, wherein the target load range is the load range to which the current load of the electronic device belongs, and each mapping relationship represents a correspondence between importance and priority, wherein the highest priority in the first mapping relationship is lower than the highest priority in the second mapping relationship, and the load value of the load range corresponding to the first mapping relationship is less than the load value of the load range corresponding to the second mapping relationship; and determining the priority corresponding to the target importance based on the target mapping relationship.
[0018] Under high load, to ensure that high-priority threads can process data promptly, the highest priority thread can be configured with the highest priority preset in the electronic device. However, under low load, when processing resources are sufficient, the highest priority thread can be left out of the electronic device's preset priority, allowing other threads to execute smoothly and reducing interference from the highest-priority thread. In other words, under high load, high-priority threads can respond quickly, while under low load, lower-priority threads can also be allocated processing resources, resulting in more rational resource allocation and improved overall system performance.
[0019] In some possible implementations, obtaining multiple importance information configured by multiple modules in the electronic device for the target thread includes: whenever initial information configured by a module for the target thread is received, if the module is a module located in the local layer and / or the application layer, determining whether the module belongs to the target module set; if the module belongs to the target module set, using the initial information configured by the module as the importance information of the target thread.
[0020] In the local layer and application layer, many modules are provided by third parties rather than by the system designers. By verifying whether the modules configuring initial information in the local layer and / or application layer belong to the target module set, we can prevent some modules in the local layer and / or application layer from maliciously setting certain threads to a higher importance level, which could affect the normal operation of the system, improve the stability and security of the system, and avoid unnecessary interference with the core parts of the system.
[0021] In some possible implementations, each importance information includes first indication information and second indication information. The first indication information is used to indicate whether to promote or cancel the promotion of the target thread's importance, and the second indication information is used to indicate the thread type of the target thread. The thread type is used to determine the preset importance level to which to promote or cancel the promotion.
[0022] By introducing thread types, the priority of each thread can be adjusted based on its type. When a new preset importance level emerges, adjusting the correspondence between thread types and preset importance levels allows each module to set the new preset importance level without being aware of it, thus enhancing the flexibility, scalability, and compatibility of the solution.
[0023] Secondly, a thread scheduling device is provided, including a unit for executing the method of the first aspect. This device may be a terminal device or a chip within the terminal device.
[0024] Thirdly, an electronic device is provided, including a memory and a processor, the memory for storing a computer program, and the processor for calling and running the computer program from the memory, causing the electronic device to perform the method of the first aspect.
[0025] Fourthly, a chip is provided, including a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface to implement the method of the first aspect.
[0026] Fifthly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer program code for implementing the method of the first aspect.
[0027] In a sixth aspect, a computer program product is provided, the computer program product comprising: computer program code, the computer program code being used to implement the method of the first aspect. Attached Figure Description
[0028] Figure 1 This is a schematic diagram of a software system applicable to an electronic device of this application;
[0029] Figure 2 This is a schematic diagram of the software system of another electronic device;
[0030] Figure 3 This is a schematic flowchart of a thread scheduling method provided in an embodiment of this application;
[0031] Figure 4 This is a schematic flowchart of another thread scheduling method provided in an embodiment of this application;
[0032] Figure 5 This is a schematic diagram of a software system for an electronic device provided in an embodiment of this application;
[0033] Figure 6 This is a schematic flowchart of a target parameter value update method provided in an embodiment of this application;
[0034] Figure 7 This is a schematic flowchart of another target parameter value update method provided in the embodiments of this application;
[0035] Figure 8 This is a schematic diagram illustrating the changes in the target parameter values provided in the embodiments of this application;
[0036] Figure 9 This is a schematic diagram of a hardware system for an electronic device applicable to this application. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0038] It should be understood that "at least one" in this application refers to one or more items, and "more than one" refers to two or more items. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. In the description of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., do not necessarily imply differences.
[0039] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0040] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties (e.g., the user has given explicit consent, the user has been notified, etc.), and the collection, use and processing of the relevant data must comply with the relevant regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0041] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0042] Figure 1 This is a software structure block diagram of an electronic device provided in an embodiment of this application.
[0043] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses the layered architecture Android system as an example to illustrate the software structure of an electronic device.
[0044] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into multiple layers, from top to bottom: the application layer, the application framework layer, the Android Runtime and system libraries, and the kernel layer.
[0045] The application layer can include a series of application packages. Applications (apps) can include camera, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, photo album, freeze control, games, etc.
[0046] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0047] like Figure 1 As shown, the application framework layer may include a window manager, content providers, a view system, a phone manager, a resource manager, and a notification manager. The window manager manages window programs. It can obtain the screen size, determine if a status bar is present, lock the screen, and capture the screen. The content provider stores and retrieves data, making this data accessible to applications. The view system includes visual controls, such as controls for displaying text and controls for displaying images. The view system can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon may include a view for displaying text and a view for displaying images. The phone manager provides communication functionality for the electronic device 100. The resource manager provides various resources for the application. The notification manager allows the application to display notification information in the status bar, which can be used to convey informational messages and can disappear automatically after a short pause without user interaction.
[0048] The Android Runtime consists of core libraries and a virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.
[0049] The core library consists of two parts: one part contains the functionalities that Java calls, and the other part is the Android core library. The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0050] The system library can include multiple functional modules, such as a surface manager, media libraries, a 3D graphics processing library, and a 2D graphics engine. The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media libraries support playback and recording of various audio and video formats, as well as still image files. The media libraries support multiple audio and video encoding formats. The 3D graphics processing library can be used to implement 3D graphics drawing, image rendering, compositing, and layer processing. The 2D graphics engine is the drawing engine for 2D graphics.
[0051] The kernel layer is the layer between hardware and software. The kernel layer can include driver modules. Driver modules can include display drivers, camera drivers, audio drivers, sensor drivers, access control modules, priority setting modules, etc.
[0052] In the Android Runtime and system libraries, the system libraries and the native parts of the Android Runtime (such as the native implementation of the virtual machine) can be understood as residing in the native layer. In other words, the multi-layered structure of the Android system can also be understood as follows, from top to bottom: application layer, application framework layer, native layer, and kernel layer.
[0053] A thread is the smallest unit that an operating system can schedule. It is contained within a process and is the actual unit of operation within a process. A process can contain multiple threads, which can execute concurrently to improve program efficiency and responsiveness.
[0054] In electronic devices, processor resources are limited. To ensure timely processing of critical threads, electronic devices can assign priorities to threads based on their nature and needs. Higher-priority threads typically indicate more urgent or important tasks that require swift execution. When a high-priority thread becomes ready, the operating system immediately suspends the currently executing lower-priority thread and allocates CPU resources to the high-priority thread. This preemptive scheduling ensures that critical tasks are processed promptly.
[0055] like Figure 2 As shown, the application layer of the electronic device includes application (APP) 211, APP 212, and APP 213, and the application framework layer includes a very important process (VIP) interface 221, a real-time (RT) interface 222, and a native interface 223. The VIP interface 221, RT interface 222, and native interface 223 can all be understood as API interfaces.
[0056] APP 211 can use VIP interface 221 to promote or de-promote a thread's priority to VIP at the driver layer. APP 212 can use RT interface 222 to promote or de-promote a thread's priority to RT type at the driver layer. VIP type priority is lower than RT type priority. Both VIP and RT type priorities are higher than the initial type priority. The initial type priority can be understood as the operating system's default thread priority type. After de-promoting a thread's priority, the thread's priority can be set to the lowest priority among the initial types.
[0057] APP 213 can use the native interface 223 of the application framework layer to promote or depromote the priority of a thread to the priority of type RT, or promote or depromote the priority of a thread to a priority of a different initial type than the lowest priority among the initial types.
[0058] In electronic devices, multiple modules can set thread priorities. In some cases, different modules may have conflicting thread priority settings.
[0059] For example, when an electronic device displays a desktop interface, the system user interface (systemUI) thread can run in the foreground. Upon detecting a user click on an app icon on the desktop, the systemUI thread switches from the foreground to the background, and its priority changes from high to low. However, since the systemUI thread is currently rendering the app's startup effects, its high priority needs to be maintained. The settings for switching the systemUI thread's priority from high to low and maintaining its high priority can be performed by the same or different modules.
[0060] When there are conflicting priority settings for the same thread, the final priority set for that thread may be the priority indicated by the last information transmitted to the driver layer. This could result in the final priority set for that thread failing to meet the priority requirements of various modules in the system. As a result, the critical tasks executed by that thread cannot obtain processor resources in a timely manner, while secondary tasks consume too many resources, thereby affecting the performance and responsiveness of the entire system.
[0061] To address the aforementioned issues, this embodiment provides a thread scheduling method.
[0062] Figure 3This is a schematic flowchart illustrating a thread scheduling method provided in an embodiment of this application. The execution subject of the method provided in this application can be an electronic device or a software / hardware module in an electronic device capable of image acquisition. For ease of explanation, the following embodiments use an electronic device as an example. Figure 3 The method shown includes steps S310 to S330.
[0063] Step S310: During the operation of the target thread in the electronic device, multiple importance information configured by multiple modules in the electronic device for the target thread is obtained. Each importance information indicates whether the importance of the target thread is increased to or de-increased to one of at least one preset importance level.
[0064] The at least one preset importance level is a predefined series of importance levels.
[0065] An electronic device can run multiple threads. Each thread in the electronic device can be considered a target thread. The acquired importance information can be all or part of the information configured by various modules after the target thread starts running, used to adjust the importance of the target thread. This importance information can be acquired at multiple points in time.
[0066] For example, the information configured by each module to adjust the importance of the target thread can be called initial information. After receiving the initial information, the electronic device can determine whether the initial information meets preset conditions. If the preset conditions are met, the electronic device can use the initial information as importance information for subsequent processing steps. If the preset conditions are not met, the electronic device can delete the initial information and stop further processing. The preset conditions may be that the module configuring the initial information belongs to the target module set.
[0067] The target module set can be predefined. For example, the target module set may include system applications but exclude third-party applications. System applications are developed by the operating system or device manufacturer and pre-installed on the device. These applications are typically closely related to the core functions of the device, providing basic services to the user. Third-party applications are applications developed by third-party developers other than the operating system or device manufacturer. These applications are typically available for download and use by users through app stores or other channels. Due to the complex origins and developer backgrounds of third-party applications, there are certain security risks, such as malware and privacy breaches. Compared to third-party applications, system applications are relatively secure. System applications can have permissions to set the importance of threads, while third-party applications may not have such permissions.
[0068] Alternatively, users can configure and manage the modules in the target module collection. For example, users can add one or more third-party applications or other modules to the target module collection. Or, users can remove one or more modules from the target module collection.
[0069] For initial information regarding adjusting the importance of target threads, electronic devices can perform permission verification on the module configuring this information to determine if the module has the authority to adjust the importance of target threads. If some modules maliciously set certain threads to a higher importance level, those threads may preempt excessive processing resources, reducing resource allocation for other threads and impacting their execution efficiency and response speed. Furthermore, some modules may execute malicious code by setting certain threads to a higher importance level, posing a threat to user data security and privacy. Permission verification can improve the stability and security of system operation.
[0070] Kernel-level modules are core components of the operating system, responsible for providing basic system services and hardware abstractions. Kernel-level modules are typically closely related to system stability and security. Performing permission checks on kernel-level modules can increase system complexity and introduce additional risks. Electronic devices can also perform permission checks on information sent by modules located in other layers outside the kernel layer, but not on information sent by kernel-level modules. Besides the kernel layer, other modules used to configure importance information can reside in the local layer and / or the application layer.
[0071] For example, whenever initial configuration information for a target thread is received from a module, if that module is located in the local layer and / or application layer, it is determined whether that module belongs to the target module set. If the module belongs to the target module set, the initial configuration information of that module is used as the importance information of the target thread. Information sent by the kernel layer in an electronic device to indicate whether to promote or de-promote the target thread's importance to a preset importance level can also be used as importance information.
[0072] In the local and application layers, many modules are provided by third parties rather than by the system designers. Therefore, implementing access control for information sent by modules in these layers, and scheduling threads based on module configurations only when the module belongs to the target module set, improves system stability and security. Furthermore, performing permission verification on modules located in the application and / or local layers can ensure security while avoiding unnecessary interference with the core system components.
[0073] Each importance level information may include a first indication and a second indication. The first indication indicates whether to promote or depromote. The second indication indicates the thread type of the target thread. The thread type is used to determine the preset importance level for promotion or depromoting. For example, multiple thread types may correspond to multiple preset importance levels. Different thread types may correspond to different preset importance levels. Alternatively, one preset importance level may correspond to one or more thread types.
[0074] In other words, based on the correspondence between thread type and preset importance, the preset importance corresponding to the thread type indicated by the second instruction information can be determined.
[0075] By introducing thread types, the priority of each thread can be adjusted based on its type. When a new preset importance level emerges, adjusting the correspondence between thread types and preset importance levels allows each module to set the new preset importance level without being aware of it, thus enhancing the flexibility, scalability, and compatibility of the solution.
[0076] Step S320: Based on multiple importance information, determine the target parameter value corresponding to each preset importance level. The target parameter value indicates whether the importance of the target thread needs to be increased to the corresponding preset importance level.
[0077] For any one of at least one preset importance level, the multiple importance information may or may not include first importance information. For any one preset importance level, the first importance information indicates whether the importance of the target thread should be increased or decreased to that preset importance level. That is, the first importance information can be importance information that indicates that one preset importance level.
[0078] If the information of first importance is not included among multiple pieces of information on importance, the target parameter value can be determined to be 0. However, if at least one piece of information of first importance is included among multiple pieces of information on importance, the target parameter value can be determined based on at least one piece of information of first importance.
[0079] The target parameter value can be positively correlated with the target difference. The target difference can be the difference between the number of promotions and the number of cancellations. The number of promotions can be the number of importance information indicating that the importance of the target thread should be promoted to any preset importance level in the first importance information. The number of cancellations can be the number of times the target thread has been cancelled from being promoted to any preset importance level before the current time indicated by at least one first importance information.
[0080] In some embodiments, the number of promotions and the number of promotions to be cancelled can be determined based on at least one first importance information. The target parameter value can be expressed as the target difference between the number of promotions and the number of promotions to be cancelled. The number of promotions to be cancelled can be determined based on a first quantity and / or a second quantity.
[0081] The number of cancellations can be a first number. The first number is the number of importance information messages in the at least one first importance information that indicate the target thread's importance should be cancelled and upgraded to any of the preset importance messages.
[0082] When the first importance information indicates that the importance of the target thread should be increased to a preset importance level, the first importance information may further include a first duration. The first duration in the first importance information indicates the length of time required to increase the target thread to the preset importance level. That is, when the first importance information includes a first duration, the first importance information indicates the time at which the importance of the target thread is increased or decreased. The time at which the importance of the target thread is increased, as indicated by the first importance information, is the time at which the first importance information is obtained. The time at which the importance of the target thread is decreased, as indicated by the first importance information, is the time interval of the first duration after the time at which the first importance information is obtained.
[0083] The cancellation promotion quantity can also be a second quantity. The second quantity is the number of pieces of information that satisfy the duration condition among the at least one piece of first importance information. The duration condition is: including the first duration, and the elapsed time after acquisition is greater than or equal to the included first duration. That is to say, any piece of first importance information satisfying the duration condition means that: the any piece of first importance information includes the first duration, and the elapsed time after acquisition of the any piece of first importance information is greater than or equal to the first duration included in the any piece of first importance information.
[0084] For example, for any preset importance level, if none of the first importance level indication information includes the first duration, the number of canceled promotions can be a first number. If all of the first importance level indication information includes the first duration, the number of canceled promotions can be a second number. If some of the first importance level indication information includes the first duration and some of the first importance level information does not include the first duration, the number of canceled promotions can be the sum of the first number and the second number.
[0085] In other words, if the module obtains importance information configured to instruct the target thread to cancel its importance promotion to a preset importance level, this can be understood as the module instructing a cancellation of promotion through the importance information. If the module obtains importance information configured to instruct the target thread to increase its importance to a preset importance level, and this importance information includes a first duration, then if the time elapsed after receiving this importance information exceeds the first duration, this can also be understood as the module instructing a cancellation of promotion through the importance information.
[0086] For each piece of first importance information including a first duration, the moment when the time interval between obtaining the first importance information and the moment when the time interval is the first duration of the first importance information can be recorded as a time when the first importance information indicates a cancellation of the target thread's importance from being promoted to a preset importance. This cancellation of promotion indicated by the first importance information, at and after this moment, can be within a second statistical range.
[0087] When the target parameter value is less than 1, the target parameter value indicates that it is not necessary to increase the importance of the target thread to the corresponding preset importance level, meaning that the requirement for the preset importance level corresponding to the target parameter value does not exist. When the target parameter value is greater than or equal to 1, the target parameter value indicates that it is necessary to increase the importance of the target thread to the corresponding preset importance level, meaning that the requirement for the preset importance level corresponding to the target parameter value exists. It should be understood that the target parameter value is an integer, a target parameter value less than 1 means the target parameter value is less than or equal to 0, and a target parameter value greater than or equal to 1 means the target parameter value is greater than 0.
[0088] For example, for each preset importance level, the target parameter value of the preset importance level can be determined based on the target difference between the number of increases and the number of decreases corresponding to each preset importance level in the multiple importance level information. The target parameter value of each preset importance level indicates whether there is a need to increase the target thread to the preset importance level. Thus, the target importance level is determined based on whether there is a need to increase the target thread to each preset importance level, so that the target importance level is more in line with the importance requirements of each module for the target thread.
[0089] For example, for any preset importance level, the number of increases and the number of decreases can be statistically analyzed separately. The target difference obtained by subtracting the number of decreases from the number of increases can be used as the target parameter value.
[0090] For example, if the first importance information indicates that the importance of the target thread should be increased to any preset importance level and the first importance information does not include a first duration, then the target parameter value corresponding to that preset importance level is incremented by 1. If the first importance information indicates that the importance of the target thread should be increased to any preset importance level and the first importance information includes a first duration, then the target parameter value corresponding to that preset importance level is incremented by 1, and after the first duration, the target parameter value corresponding to that preset importance level is decremented by 1. If the first importance information indicates that the importance of the target thread should not be increased to any preset importance level, then the target parameter value corresponding to that preset importance level is decremented by 1.
[0091] For any preset importance level, upon acquiring each piece of first importance information, if the first importance information indicates an increase to a preset importance level, the target parameter value corresponding to that preset importance level can be incremented by 1. If the first importance information indicates an increase, it can also be determined whether to decrement the target parameter value by 1 based on whether the first importance information includes a first duration. If the first importance information includes a first duration, the target parameter value is decremented by 1 after the first duration, that is, after the acquisition time of the first importance information and within a time interval equal to the first duration. If the first importance information does not include a first duration, and the first importance information does not indicate cancellation of the increase, the target parameter value is not decremented by 1.
[0092] Following the instructions of the first priority information, the target parameter value is incremented or decremented by 1, thus eliminating the need to separately count the number of increases and the number of decreases, making the determination of the target parameter value simpler and more efficient.
[0093] When the target thread starts running, the target parameter values corresponding to each preset importance level can be set to 0. Therefore, for any preset importance level, if the first importance information is not included among the multiple importance information, the target parameter value corresponding to any preset importance level is 0. However, if the multiple importance information includes at least one first importance information, the target parameter value corresponding to any preset importance level can be the target difference between the increase and decrease amounts.
[0094] In some cases, electronic devices may not support using the first duration in the importance information to indicate the duration for raising the importance to a preset level. Instead, they may support modules that can be configured to indicate whether to cancel the promotion of the target thread's importance to a preset level. In this case, after obtaining any first importance information, if the first importance information indicates that the target thread's importance should be raised to a preset level, the target parameter value corresponding to the preset level indicated by the first importance information is incremented by 1; conversely, if the first importance information indicates that the target thread's importance should be canceled from being raised to a preset level, the target parameter value corresponding to the preset level is decremented by 1.
[0095] Step S330: Determine the target importance of the target thread based on the target parameter value corresponding to each preset importance level. The target importance level indicates the priority of the target thread.
[0096] After determining the target parameter value corresponding to each preset importance level, it can be used to determine whether that preset importance level is a candidate importance level. In other words, for each preset importance level, its corresponding target parameter value determines whether it can be considered a candidate importance level. The target parameter value corresponding to each preset importance level indicates whether there is a demand for that preset importance level.
[0097] If a target parameter value corresponding to a certain preset importance level indicates that a requirement exists, then that preset importance level can be used as a candidate importance level. Conversely, if a target parameter value corresponding to a certain preset importance level indicates that a requirement does not exist, then that preset importance level can be excluded from the list of candidate importance levels.
[0098] When candidate importance levels exist among multiple preset importance levels, the target importance level can be determined as the highest importance level among at least one candidate importance level. The definition of "highest" depends on the ranking of the preset importance levels. When no candidate importance levels exist among multiple preset importance levels, the target importance level can be determined as the initial importance level. The initial importance level is lower than each preset importance level. The initial importance level is a base or default importance level outside of multiple preset importance levels.
[0099] Therefore, the target thread's target importance is the highest priority among existing requirements, which better aligns with the needs of each module. In other words, the initial importance can be understood as the requirement consistently existing. When there are candidate importance levels—that is, requirements with a preset importance higher than the initial importance—the target thread's target importance is the highest preset importance among existing requirements.
[0100] Different levels of importance can represent different priorities. Alternatively, the priority of a target thread can be determined based on the current load and the target thread's objective importance.
[0101] System load refers to the average number of processes in a system that are either running or in an uninterruptible sleep state over a specific time interval (typically 1 minute, 5 minutes, or 15 minutes). System load is calculated by counting the length of the task queues in the processor's scheduler. These task queues include processes waiting for processor time and processes waiting for input / output (I / O) operations. The average load can be calculated based on the number of these tasks and the time intervals between them. When the system load is higher than the number of processor cores, the system may be overloaded, leading to slower response times and performance degradation. Conversely, if the load value is significantly lower than the number of processor cores, it indicates that the system resources are sufficient and the system is idle.
[0102] For example, different load ranges can correspond to different mapping relationships. Each mapping relationship represents a correspondence between importance and priority. Based on the correspondence between load ranges and mapping relationships, the target mapping relationship corresponding to the target load range is determined. The target load range is the load range to which the current load of the electronic device belongs. Based on the target mapping relationship, the priority corresponding to the target importance can be determined.
[0103] In different mapping relationships, the highest priority in the mapping relationship corresponding to the load range with a smaller load value is lower than the highest priority in the mapping relationship corresponding to the load range with a larger load value. That is, for a first mapping relationship corresponding to a first load range with a smaller load value, and a second mapping relationship corresponding to a second load range with a larger load value, the highest priority in the first load range is lower than the highest priority in the second mapping relationship. The fact that the load value of the first load range is less than the load value of the second load range can be understood as every load value in the first load range being less than the load value in the second load range.
[0104] In a multithreaded environment, thread priority is a crucial factor, determining the priority at which a thread is scheduled for execution by the operating system. Higher-priority threads are more likely to receive processing resources and thus complete their tasks faster than lower-priority threads. Furthermore, higher-priority threads are likely to receive more processing resources.
[0105] When a thread has a high priority, it may frequently preempt processing resources, causing lower-priority threads to not get enough execution time. This can result in lower-priority threads being unable to run for extended periods. In extreme cases, if a high-priority thread continuously occupies a large amount of processing resources, it may cause the system to slow down, as other important but lower-priority threads may not get enough execution time.
[0106] Therefore, under high load conditions, to ensure that high-importance threads can process data promptly, the highest priority thread can be configured with the highest priority preset in the electronic device. However, under low load conditions, when processing resources are sufficient, the highest priority thread can be left out of the electronic device's preset priority setting, thus ensuring the smooth execution of other threads and reducing interference from the highest-importance thread. In other words, under high load conditions, high-importance threads can respond quickly, while under low load conditions, other lower-importance threads can also be allocated processing resources, resulting in a more rational allocation of processing resources and improved overall system performance.
[0107] Generally, during the execution of a task, a module can configure importance information for a target thread to indicate that the target thread should be promoted to a preset importance level. After the task is completed, the module can configure importance information for the target thread to indicate that the promotion to the preset importance level should be cancelled. In other words, when a module indicates that the priority of a target thread has been promoted to a preset importance level through importance information, it can include a first duration less than a duration threshold in that importance information, or, within the duration threshold, use another importance information to indicate that the priority of the target thread should be cancelled. Therefore, the duration for a module to promote the priority of a target thread is less than or equal to the duration threshold. The duration threshold can be preset.
[0108] However, the module may malfunction, causing it to fail to configure the information to cancel the promotion of the target thread to a preset importance level. Consequently, the target thread's importance level may remain at that preset level for an extended period, leading to the target thread monopolizing processing resources and preventing other threads from functioning correctly.
[0109] To avoid a situation where a module malfunctions and the target thread monopolizes processing resources for an extended period, after step S330, if the duration for which the target importance level is maintained at any preset importance level is greater than or equal to a duration threshold, the importance level of the target thread is set to an initial importance level, and the target parameter value for each preset importance level is set to indicate that the importance level of the target thread does not need to be increased to each preset importance level.
[0110] In some embodiments, based on counting the target parameters corresponding to a preset importance level according to importance information, and upon receiving importance information configured by each module to increase the importance of the target thread to a preset importance level, and provided that this importance information does not include a first duration, it is monitored whether, within a time period equal to a duration threshold after receiving the importance information, importance information sent by the module to cancel the increase in the importance of the target thread to the preset importance level is received. If no importance information canceling the increase in importance to the preset importance level is received, the value of the target parameter corresponding to the preset importance level can be decremented by 1.
[0111] Verifying modules that configure importance information is a relatively complex process.
[0112] In other embodiments, to simplify processing, for any preset importance level, the target parameter value corresponding to that preset importance level can also be negatively correlated with a first difference. The target parameter value can be represented as the difference between the target difference and the first difference. The first difference can be understood as the difference between the number of historical increases and decreases before a first moment. The first moment is the moment before the current moment, where the time interval between the current moment and the current moment is a duration threshold. The number of increases before the first moment represents the number of first importance level information messages obtained before the first moment indicating that the target thread's importance should be increased to that preset importance level. The number of decreases is the number of times that at least one first importance level information message indicated that the target thread's importance should be decreased before the current moment.
[0113] In other words, at the marker time after the acquisition of the instruction to upgrade the target thread's importance to the first importance level of any preset importance, the first difference may change, causing a change in the target parameter value. For any preset importance, if the acquisition instruction upgrades the target thread's importance to the first importance level of any preset importance, at the marker time after the acquisition of that first importance information, it can be determined whether to update the target parameter value corresponding to that preset importance. At the marker time, if the first difference increases, the target parameter value is updated at the marker time; otherwise, if the first difference does not increase, the target parameter value does not need to be updated at the marker time. Updating the target parameter value based on the duration threshold can be understood as timeout management.
[0114] For example, for any preset importance level, based on incrementing the preset importance level by 1 according to the first importance level information indicated by "increase" and decrementing the preset importance level by 1 according to the first importance level information indicating cancellation of increase, the target parameter value can be decremented by 1 if the first difference is increased by 1. Normally, the first difference will not decrease. If the first difference remains unchanged, the target parameter value is not updated based on the first difference.
[0115] If the importance information for each instruction that raises the importance of the target thread to any preset importance level is obtained, a timing module can start timing. If the importance information for each instruction that cancels the raising of the target thread's importance to any preset importance level is obtained, or if the importance information for each instruction that raised the target thread's importance to any preset importance level for a duration of a first time interval has been obtained and the first time interval has elapsed, the timing of the earliest started timing module can be canceled. If the timing duration of any timing module is greater than or equal to a duration threshold, the target parameter value corresponding to any preset importance level can be decremented by 1.
[0116] When the first importance information indicates that the importance of the target thread should be increased to a preset importance level, and the first importance information includes a first duration, the first importance information indicates the moment when the increase to the preset importance level should be cancelled through the first duration. Therefore, when the first importance information includes a first duration, the moment when the interval between the moment when the first importance information is obtained and the moment when the interval is a duration threshold may not be used as the marker moment.
[0117] For example, when any first importance information is acquired, if the arbitrary first importance information indicates that the importance of the target thread should be increased to any preset importance level, and the arbitrary first importance information does not include a first duration, then a marking time can be determined. The marking time is after the acquisition time of the arbitrary first importance information and between the acquisition time and a duration threshold. The first duration represents the duration for increasing the importance of the target thread to that preset importance level. Generally, the first duration is less than or equal to the duration threshold.
[0118] If any first importance information indicates that the target thread's importance should be reduced to any preset importance, then the earliest determined marker time no earlier than the current time can be deleted. The earliest determined marker time no earlier than the current time can also be understood as the earliest marker time no earlier than the current time.
[0119] If the current time is the marked time, the target parameter value corresponding to any preset importance level can be reduced by 1.
[0120] By setting and deleting marker times, the target parameter value is decremented by 1 when the marker time is reached, making the update method of the target parameter value based on the duration threshold simpler.
[0121] In some cases, electronic devices may not support modules that can configure importance information to indicate whether to cancel the promotion of a target thread to a preset importance level. Instead, electronic devices can support indicating the duration to the preset importance level by specifying a first duration in the importance information, and then instructing cancellation after that first duration. In this case, timeout management based on a duration threshold is no longer necessary.
[0122] The thread scheduling method provided in this application determines, based on multiple importance information configured for the target thread by different modules, whether the importance of the target thread needs to be increased to a target parameter value for each preset importance level, and determines the target importance level indicating the priority of the target thread based on the target parameter value. Therefore, the setting of the target importance level comprehensively considers the importance requirements of different modules for the target thread, making the determination of the target thread's target importance level more in line with system requirements.
[0123] It should be understood that the execution entity of the thread scheduling method provided in this application can be an electronic device, or at least one software / hardware module in an electronic device capable of data processing. For ease of explanation, the following will be combined with... Figure 4 , to have as Figure 1 Taking the electronic device with the software architecture shown as an example, the thread scheduling method provided in the embodiments of this application will be described.
[0124] Figure 4 This is a schematic flowchart of a thread scheduling method provided in an embodiment of this application.
[0125] An electronic device may include multiple modules, target threads, and priority setting modules. Each of the multiple modules is used to configure importance information. Different modules can perform different tasks.
[0126] The priority setting module is used to acquire multiple importance information configured for the target thread by multiple modules during the target thread's execution. Each importance information indicates whether to increase the target thread's importance to or de-increase it to one of at least one preset importance level. The priority setting module is also used to determine, based on the multiple importance information, the target parameter value corresponding to each of the at least one preset importance level. The target parameter value indicates whether the target thread's importance needs to be increased to the corresponding preset importance level. Furthermore, the priority setting module is used to determine the target importance level of the target thread based on the target parameter value corresponding to each preset importance level. The target importance level indicates the priority of the target thread.
[0127] Electronic devices may also include an access control module and a priority setting module. These modules can reside in the kernel layer.
[0128] Any one of the multiple modules can act as a triggering module to perform steps S411 to S412, configuring the importance information of the target thread. The triggering module's configuration of the importance information can be understood as the business layer module's requirement for the importance of the target thread.
[0129] Step S411: The trigger module generates importance information for the target thread.
[0130] The importance information of the target thread is used to indicate whether to promote the importance of the target thread to the i-th importance among a plurality of preset importance levels, or to cancel the promotion to the i-th importance level, where i is a positive integer.
[0131] The triggering module can reside at the application layer or the kernel layer. For example... Figure 5 As shown, the triggering module can be a first application located in the application layer or a first module located in the local layer. For example, the triggering module can also be a second module located in the kernel layer.
[0132] In step S412, the triggering module sends importance information to the access control module.
[0133] When the triggering module is the first module located in the local layer, it can transmit importance information to the kernel-level permission control module through the kernel-level input / output control (ioctl). I / O control is a system call used by device drivers, providing a general interface for other modules to interact with modules in the kernel layer.
[0134] When the triggering module is the first application in the application layer, it can send importance information to the permission control module in the kernel layer via the application framework layer. The first application can send importance information to the application framework layer, which can then transmit the importance information to the kernel layer.
[0135] The application framework layer can interact with the input / output control (ioctl) in the kernel layer through some indirect means to transmit information of importance. For example, the application framework layer can communicate with the kernel layer through other mechanisms (such as system services, Java Native Interface (JNI), etc.) and encapsulate ioctl calls within these mechanisms.
[0136] Alternatively, the application framework layer can transmit importance information to the kernel layer via sockets.
[0137] After receiving the importance information, the access control module can proceed to steps S421 to S422.
[0138] Access control modules can be Security-enhanced Linux (SELinux). SELinux uses tags to identify the security context of each object (such as files, processes, network services, etc.). Security policy rules specify the relationships between various tags and determine which objects each module can access and which operations it can perform. As a security-enhancing Linux mechanism, SELinux plays a crucial role in improving system security.
[0139] Step S421: The access control module determines whether the triggering module that sends the importance information belongs to the target module set.
[0140] The target module set can include tags for modules that allow adjustment of thread importance.
[0141] If the triggering module does not belong to the target module set, the access control module may skip the subsequent steps. If the triggering module belongs to the target module set, the access control module may proceed to step S422.
[0142] In step S422, the access control module sends importance information to the priority setting module.
[0143] In other words, the permission control module is used to receive initial information sent by triggering modules in the application layer, system libraries, and Android runtime (e.g., the native layer) or kernel layer. The permission control module can determine whether the module sending the initial information belongs to the target module set. That is, the permission control module can determine whether the source of the initial information is a module in the target module set.
[0144] If the module that triggers the initial information transmission belongs to the target module set, the access control module can send the information to the priority setting module. However, if the module sending the initial information does not belong to the preset set, the access control module may choose not to send the information to the priority setting module.
[0145] When the triggering module is a second module located in the kernel layer, it may choose not to send importance information to the permission control module, but instead send it to the priority setting module. For example, the importance information sent by the triggering module located in the local layer or application layer to the permission control module can also be called initial information. The permission control module can use the initial information sent by the triggering module belonging to the target module set as importance information and send it to the priority setting module.
[0146] By performing permission checks on modules located in the application layer and / or the local layer, while not performing permission checks on second modules in the kernel layer, security can be ensured while avoiding unnecessary interference with the core parts of the system kernel layer.
[0147] After receiving the importance information, the priority setting module can perform steps S431 to S436 to determine the priority of the target thread based on the importance information sent by the permission control module.
[0148] In step S431, the priority setting module counts based on the importance information to obtain the target parameter value for each preset importance level.
[0149] The priority setting module can also be called the unified priority setting interface (UPSI).
[0150] The priority setting module records the target parameter value for each of the multiple preset importance levels. When the target thread starts running, the priority setting module can set the target parameter value for each preset importance level to 0. Upon obtaining importance information, the priority setting module updates the target parameter value for the i-th importance level as indicated by the importance information in each preset importance level.
[0151] like Figure 6As shown, the priority setting module can perform steps S601 to S604 to count according to importance information.
[0152] Importance information can include a first indication and a second indication. The first indication can indicate whether to promote or depromote, and the second indication can indicate the thread type of the target thread. Multiple thread types correspond to multiple preset importance levels.
[0153] Step S601: Determine the importance level of the i-th component based on the second instruction information.
[0154] For example, the i-th importance level corresponding to the second indication information in the importance information is determined based on the correspondence between thread type and preset importance level. Alternatively, different thread types can represent different preset importance levels. The i-th importance level can be understood as the preset importance level indicated by the importance information.
[0155] The types of threads recorded in electronic devices can include animation, audio, logic, and interface types. Animations and audio are multimedia elements that can intuitively attract users' attention and enhance the interactivity and fun of the user interface. Animations and audio have high real-time requirements; if they are delayed or ignored, it will directly affect the user's perception and experience. Logic types typically involve background processing and data operations, which are invisible to the user. Based on a comprehensive consideration of user experience and system response efficiency, the priority of animation and audio representations can be higher than that of interface representations, and the priority of interface representations can be higher than that of logic representations.
[0156] If the first indication in the importance information indicates an increase, that is, if the importance information indicates that the importance of the target thread should be increased to the i-th importance among multiple preset importance levels, the priority setting module can proceed to step S602.
[0157] Step S602: Increment the target parameter value Ni of the i-th importance level by 1.
[0158] If the first indication in the importance information indicates cancellation of promotion, that is, if the importance information indicates that the importance of the target thread should be promoted to the i-th importance level, the priority setting module can proceed to step S603.
[0159] Step S603: Decrement the target parameter value Ni for the i-th importance level by 1. The target parameter values for other preset importance levels remain unchanged.
[0160] When the first indication in the importance information indicates an increase, the priority setting module can also determine whether the importance information includes the corresponding first duration.
[0161] If the importance information does not include the corresponding first duration, the priority setting module ends the update of the target parameter value based on the importance information. If the importance information includes the corresponding first duration, the priority setting module may also proceed to step S604.
[0162] Step S604: After the first duration, decrease the target parameter value Ni of the i-th importance by 1.
[0163] The operation of decrementing the target parameter value Ni of the i-th importance level in steps S603 and S604 by 1 can be understood as being performed according to the indication of the importance level information.
[0164] Generally, each module can cancel the indication of upgrading to a preset importance level either through the first duration in the importance information configured for that module, or through importance information configured after the indication of upgrading to that preset importance level. Therefore, the target parameter value can be a natural number. If the target parameter value is 0, and the importance information indication decrements the target parameter value by 1, the decrementing operation may not be performed.
[0165] Through steps S601 to S604, the priority setting module can update the target parameter value Ni of the i-th importance level. After performing step S602 or S603, the priority setting module can proceed to step S432.
[0166] To avoid a situation where a module malfunctions and the target thread monopolizes processing resources for an extended period, if the first indication information indicates "promotion", after step S602, if the importance information includes the first duration, step S604 can be performed; otherwise, if the importance information does not include the first duration, steps S701 to S702 can be performed.
[0167] Step S701: The time interval between the current time and the time threshold is used as the marked time.
[0168] The current moment can be understood as the moment when information of this importance is obtained.
[0169] Step S702: At the marking time, decrease the target parameter value Ni of the i-th importance by 1.
[0170] If the first instruction indicates "elevation", in addition to performing step S603, step S703 can also be performed.
[0171] Step S703: Delete the earliest marked time after the current time.
[0172] In other words, if there is at least one marked time after the current time, the earliest marked time among those marked times can be deleted. If there are no marked times after the current time, no further processing is required, i.e., the marked times are not updated.
[0173] In other words, for importance information indicating that the importance of a target thread should be increased to the i-th importance level, if the importance information includes a first duration, the first duration can be understood as the effective duration of the "increase" indicated by the importance information. If the importance information does not include a first duration, then the duration threshold can be used as the maximum effective duration of the "increase" indicated by the importance information.
[0174] The duration threshold can be preset. Generally, the duration threshold is greater than or equal to the first duration. For different preset importance levels, the duration threshold can be the same or different.
[0175] Over a period of time, the priority setting module can receive multiple importance information and update the target parameter values for each preset importance level based on the multiple importance information.
[0176] For example, such as Figure 8 As shown in (a), before time t0, the target parameter Ni for the i-th importance level is 0. Time points t0, t1, t2, t3, t4, and t5 are multiple time points arranged in chronological order. At each of these times, the priority setting module receives an instruction to either promote or depromote the target thread to the i-th importance level. At time t0, the priority setting module has not recorded a marker time.
[0177] At time t0, in the importance information received by the priority setting module, the first indication information indicates "promotion". For example... Figure 8 As shown in (a), the priority setting module increments the target parameter value Ni of the i-th importance by 1, resulting in a value of 1 for the target parameter value Ni of the i-th importance.
[0178] Furthermore, the importance information received by the priority setting module at time t0 does not include the first duration. Therefore, the priority setting module uses time t0', which is the time interval between time t0 and time t0 and the duration threshold T, as the marked time.
[0179] At time t0, in the importance information received by the priority setting module, the first indication information indicates "promotion". For example... Figure 8 As shown in (a), the priority setting module increments the target parameter value Ni of the i-th importance by 1, resulting in a value of 1 for the target parameter value Ni of the i-th importance.
[0180] Time t1 is earlier than time t0'. At time t1, the priority setting module receives importance information, and the first indication indicates "cancel promotion". For example... Figure 8 As shown in (b), the priority setting module subtracts 1 from the target parameter value Ni of the i-th importance level, resulting in a value of 0 for Ni of the i-th importance level. Furthermore, the priority setting module deletes the earliest marked time after the current time (i.e., time t1). In other words, the earliest marked time after time t0, i.e., time t0', is no longer used as a marked time.
[0181] At time t2, in the importance information received by the priority setting module, the first indication information indicates "promotion". For example... Figure 8 As shown in (c), the priority setting module increments the target parameter value Ni of the i-th importance by 1, resulting in a value of 1 for the target parameter value Ni of the i-th importance.
[0182] Furthermore, the importance information received by the priority setting module at time t2 does not include the first duration. Therefore, the priority setting module uses time t2', which is the time interval between time t2 and time t2 and the duration threshold T, as the marked time.
[0183] Time t3 is earlier than time t2'. At time t3, in the importance information received by the priority setting module, the first indication information indicates "promotion". For example... Figure 8 As shown in (d), the priority setting module increments the target parameter value Ni of the i-th importance by 1, resulting in a value of 2 for the target parameter value Ni of the i-th importance.
[0184] Furthermore, the importance information received by the priority setting module at time t3 does not include the first duration. Therefore, the priority setting module also uses time t3', which is the time interval between time t3 and time t3 and the duration threshold T, as the marked time.
[0185] At time t4, between time t3 and time t2', the priority setting module did not receive importance information. Of the importance information received by the priority setting module, the first indication was "Cancel Promotion". For example... Figure 8 As shown in (e), the priority setting module subtracts 1 from the target parameter value Ni of the i-th importance level, resulting in a value of 0 for Ni of the i-th importance level. Furthermore, the priority setting module deletes the earliest marked time after the current time (i.e., time t4). In other words, the earliest marked time after time t4, i.e., time t2', is no longer used as a marked time.
[0186] During the period from time t4 to time t3', the priority setting module did not receive importance information. Upon reaching time t3', time t3' is still the marked time. For example... Figure 8 As shown in (f), at time t3', the priority setting module subtracts 1 from the target parameter value Ni of the i-th importance level, resulting in a value of 0 for the target parameter value Ni of the i-th importance level.
[0187] At time t5, after time t3', the priority setting module receives importance information, and the first indication indicates "promotion". For example... Figure 8 As shown in (g), the priority setting module increments the target parameter value Ni of the i-th importance by 1, resulting in a value of 1 for the target parameter value Ni of the i-th importance.
[0188] Furthermore, the importance information received by the priority setting module at time t5 includes the first duration Δ. During the time period after time t5 but before time t5', the priority setting module does not receive importance information. Time t5' is a time later than time t5 and with a time interval of the first duration Δ between it and time t5. At time t5', the priority setting module subtracts 1 from the target parameter value Ni of the i-th importance level, resulting in a value of 0 for the target parameter value Ni of the i-th importance level.
[0189] In steps S701 to 703, by setting and deleting marker times, based on counting the target parameters corresponding to the preset importance level according to the importance information, and when receiving importance information for raising the importance of the target thread to the preset importance level, and this importance information does not include a first duration, a marker time is set to determine whether an instruction to cancel the promotion of the target thread's importance to the preset importance level is received within a time period of a duration threshold after receiving the information. If an instruction to cancel the promotion is received, the marker time is deleted. If no instruction to cancel the promotion is received within the time period of the duration threshold after receiving the information, the value of the target parameter corresponding to the preset importance level is decremented by 1 at the marker time. This prevents the target thread from monopolizing processing resources for an extended period, even if the module configuring the importance information malfunctions, thus improving system stability.
[0190] In step S432, the priority setting module determines whether there is at least one target parameter value with a preset importance level that is greater than 0.
[0191] If there is no preset importance level with a target parameter value greater than 0 in at least one preset importance level, the priority setting module can proceed to step S436.
[0192] In step S436, the priority setting module sets the target thread to the initial priority.
[0193] If at least one target parameter value with a preset importance level is greater than 0, the priority setting module can proceed to steps S433 to S435.
[0194] In step S433, the priority setting module selects the highest priority among the preset importance levels where the target parameter value is greater than 0 as the target importance level.
[0195] In other words, the target importance level is the highest among at least one preset importance level where the target parameter value is greater than 0.
[0196] In step S434, the priority setting module determines the target priority corresponding to the importance of the target based on the mapping relationship corresponding to the current load range.
[0197] The current load range can be understood as the load range to which the electronic device's current load belongs. The priority setting module can obtain the current load and determine the current load range before proceeding to step S434. The priority setting module can record multiple mapping relationships corresponding to multiple load ranges. Each mapping relationship represents the correspondence between importance and priority.
[0198] For different load ranges, the highest priority in the mapping relationship corresponding to the load range with higher load value is higher, while the highest priority in the mapping relationship corresponding to the load range with lower load value is lower.
[0199] For example, the priority of the RT type is higher than that of the VIP type. Both the priority of the VIP type and the priority of the RT type are higher than the priority of the initial type. When the system load is very low, the highest priority in the mapping relationship corresponding to the system load can be the priority of the initial type. When the system load is moderate, the highest priority in the mapping relationship corresponding to the system load can be the priority of the VIP type. When the system load is very high, the highest priority in the mapping relationship corresponding to the system load can be the priority of the RT type.
[0200] When the load is low and processing resources are sufficient, the highest priority thread can be left unconfigured in the electronic device's default settings. This ensures the smooth execution of other threads and reduces interference from the highest-priority thread. In other words, under high load, this ensures that high-priority threads can respond quickly, while under low load, other lower-priority threads can also be allocated processing resources. This results in a more rational allocation of processing resources and improves the overall performance of the system.
[0201] The highest priority in the mapping relationship belongs to the supported priority set. The supported priority set includes multiple priorities currently supported by the electronic device. The priorities supported by the electronic device can be preset, meaning the priorities supported by the electronic device can remain fixed during use. Alternatively, the priorities supported by the electronic device can be determined based on user operations or usage status. In other words, the priorities supported by the electronic device may change during use. For example, the electronic device may determine whether to support VIP type priorities and / or RT type priorities based on the current usage status.
[0202] If the priority supported by the electronic device can be determined based on user operation or usage status, the priority setting module can also obtain a set of supported priorities before proceeding to step S434. For example, the priority setting module can obtain the set of supported priorities before each step S434; or, the priority setting module can obtain the set of supported priorities periodically or non-periodically.
[0203] The mapping relationship for the same load can be different depending on the priority supported by the electronic device.
[0204] The priority setting module can determine the mapping relationship corresponding to the priority set based on the correspondence between the priority set and the mapping relationship, and determine the target priority corresponding to the importance of the target based on the mapping relationship.
[0205] Alternatively, the priority setting module can determine the mapping relationship between the current load range and the supported priority set based on the correspondence between the combination and mapping relationship between the load range and the priority set, and determine the target priority corresponding to the importance of the target based on the mapping relationship.
[0206] The solution obtains a set of support priorities representing the priorities supported by electronic devices, determines a mapping relationship based on the set of support priorities, and determines the target priority corresponding to the importance of the target based on the mapping relationship. This makes the solution of this application still applicable when the priority supported by electronic devices changes, and has a wider range of applications.
[0207] In step S435, the priority setting module sets the target thread to the target priority.
[0208] A thread's priority is set to a target priority, which can be achieved by adding the thread to a thread queue of that target priority. Different priorities can correspond to different thread queues. A thread queue is an important concept in concurrent programming, used to manage the scheduling and execution of threads. In a multithreaded environment, thread queues are typically used to store threads waiting to be executed, allowing the operating system or thread pool to allocate processor resources to these threads on demand.
[0209] After step S435 or step S436, the priority setting module finishes processing based on an importance information.
[0210] It should be understood that multiple threads can run in an electronic device. The priority setting module can record target parameter values for each thread, each with a preset importance level. The importance information may include the identifier of the target thread. Based on the identifier of the target thread, the priority setting module determines the target thread indicated by the importance information and performs steps S431 to S436 on the target thread.
[0211] The thread scheduling method provided in this application can avoid interference between different modules in setting the importance of the target thread, so that the priority set for the target thread meets the priority requirements of each module for the target thread.
[0212] It should be understood that the above examples are provided to help those skilled in the art understand the embodiments of this application, and are not intended to limit the embodiments of this application to the specific values or scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of this application.
[0213] Electronic devices can be used to perform Figure 3 or Figure 4 The thread scheduling method shown below. (Followed by...) Figure 9 The structure of the electronic device is explained.
[0214] Figure 9 A hardware system for an electronic device applicable to this application is shown.
[0215] The method provided in this application can be applied to various electronic devices capable of image acquisition, such as mobile phones, tablets, wearable devices, laptops, netbooks, personal digital assistants (PDAs), and in-vehicle devices. This application does not impose any restrictions on the specific type of electronic device.
[0216] Figure 9A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 151, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0217] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0218] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0219] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0220] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0221] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0222] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0223] Electronic device 100 can implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0224] The display screen 194 can be used to display images or videos. 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 flexible light-emitting diode (FLED), a mini light-emitting diode (Mini LED), a micro light-emitting diode (Micro LED), a micro OLED, or a quantum dot light-emitting diode (QLED). In some embodiments, the electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0225] This application provides a thread scheduling apparatus, including various functional units for executing the thread scheduling method provided in this application. The term "unit" here can be implemented in software and / or hardware, and is not specifically limited thereto.
[0226] For example, a "unit" can be a software program, a hardware circuit, or a combination of both that implements the above functions. The hardware circuit may include an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components that support the described functions.
[0227] Therefore, the units of the various examples described in the embodiments of this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0228] This application also provides a chip, which includes a data interface and one or more processors. When the one or more processors execute instructions, they read instructions stored in memory through the data interface to implement the thread scheduling method described in the above method embodiments.
[0229] The one or more processors can be general-purpose processors or special-purpose processors. For example, the one or more processors can be central processing units (CPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, such as discrete gate, transistor logic devices, or discrete hardware components.
[0230] The chip can be used as a component of a terminal device or other electronic device. For example, the chip can be located in electronic device 100.
[0231] Processors and memory can be configured separately or integrated together. For example, processors and memory can be integrated onto a system-on-a-chip (SoC) in a terminal device. That is, the chip can also include memory.
[0232] The memory can store programs, which can be run by the processor to generate instructions, causing the processor to execute the thread scheduling method described in the above method embodiments according to the instructions.
[0233] Optionally, the memory may also store data. Optionally, the processor may also read data stored in the memory, which may be stored at the same memory address as the program, or the data may be stored at a different memory address than the program.
[0234] This chip can be installed in electronic devices.
[0235] For example, the memory can be used to store the relevant program of the thread scheduling method provided in the embodiments of this application, and the processor can be used to call the relevant program of the thread scheduling method stored in the memory to implement the thread scheduling method of the embodiments of this application.
[0236] For example, during the execution of a target thread in an electronic device, multiple importance information configured for the target thread by multiple modules in the electronic device is obtained. Each piece of importance information is used to indicate whether the importance of the target thread should be increased to or de-increased to one of at least one preset importance level. Based on the multiple importance information, a target parameter value corresponding to each of the at least one preset importance level is determined. The target parameter value is used to indicate whether the importance of the target thread needs to be increased to the corresponding preset importance level. Based on the target parameter value corresponding to each preset importance level, a target importance level of the target thread is determined. The target importance level indicates the priority of the target thread.
[0237] This application also provides a computer program product that, when executed by a processor, implements the thread scheduling method described in any of the method embodiments of this application.
[0238] The computer program product can be stored in memory, for example, it is a program. The program is eventually converted into an executable object file that can be executed by the processor after processes such as preprocessing, compilation, assembly and linking.
[0239] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, implements the thread scheduling method described in any of the method embodiments of this application. The computer program may be a high-level language program or an executable object program.
[0240] The computer-readable storage medium is, for example, memory. Memory can be volatile or non-volatile, or it can include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0241] In the description of this application, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance, or a specific order or sequence. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0242] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0243] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0244] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0245] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0246] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0247] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0248] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A thread scheduling method, characterized in that, Applied to electronic devices, the method includes: During the execution of the target thread in the electronic device, multiple importance information configured for the target thread by multiple modules in the electronic device is obtained. Each importance information is used to indicate whether the importance of the target thread is increased to or de-increased to one of at least one preset importance level. Based on the multiple importance information, a target parameter value is determined for each of the at least one preset importance levels. The target parameter value is used to indicate whether the importance of the target thread needs to be increased to the corresponding preset importance level. The target importance of the target thread is determined based on the target parameter value corresponding to each preset importance level, and the target importance level indicates the priority of the target thread.
2. The method according to claim 1, characterized in that, For any one of the at least one preset importance level, if the first importance level information is not included in the plurality of importance level information, the target parameter value corresponding to any one preset importance level is 0, and the first importance level information indicates whether to increase or cancel the importance level of the target thread to any one preset importance level; When the plurality of importance information includes at least one first importance information, the target parameter value corresponding to any preset importance is positively correlated with the target difference, the target difference being the difference between the number of increases and the number of decreases, the number of increases being the number of first importance information obtained before the current time indicating that the importance of the target thread should be increased to any preset importance, and the number of decreases being the number of times the importance of the target thread should be decreased to any preset importance before the current time, as indicated by the at least one first importance information. Where the target parameter value corresponding to any preset importance is greater than or equal to 1, the target parameter value corresponding to any preset importance indicates that the importance of the target thread needs to be increased to any preset importance.
3. The method according to claim 2, characterized in that, The cancellation promotion quantity is determined based on a first quantity and / or a second quantity, wherein the first quantity is the number of information in the at least one first importance information that indicates that the importance of the target thread should be cancelled and promoted to any one of the preset importance, and the second quantity is the number of information in the at least one first importance information that meets the duration condition; The fact that any first importance information in at least one first importance information satisfies the duration condition means that: any first importance information includes a first duration, and the duration elapsed after obtaining any first importance information is greater than or equal to the first duration included in any first importance information, wherein the first duration in any first importance information represents the duration for which the target thread is promoted to a preset importance level.
4. The method according to claim 2 or 3, characterized in that, The multiple importance information is acquired at multiple times. Determining the target parameter value corresponding to each of the at least one preset importance level based on the multiple importance information includes: If, upon obtaining any first importance information, the first importance information indicates that the importance of the target thread should be increased to any preset importance level and does not include the first duration, then the target parameter value corresponding to any preset importance level is incremented by 1. If any first importance information indicates that the importance of the target thread should be increased to any preset importance and include the first duration, then the target parameter value corresponding to any preset importance is incremented by 1, and after the first duration, the target parameter value corresponding to any preset importance is decremented by 1. If any of the first importance information indicates that the importance of the target thread should be canceled and promoted to any of the preset importance levels, then the target parameter value corresponding to any of the preset importance levels should be decremented by 1.
5. The method according to claim 4, characterized in that, The method further includes: If, upon obtaining any first importance information, the first importance information indicates that the importance of the target thread should be increased to any preset importance, and the first importance information does not include a first duration, then a marking time is determined. The first duration represents the duration for which the importance of the target thread is increased to any preset importance. The marking time is after the time when the first importance information is obtained and is a time interval threshold between the time when the first importance information is obtained and the time when the first importance information is obtained. If any of the first importance information indicates that the importance of the target thread should be canceled and promoted to any of the preset importance levels, then the earliest marked time after the current time is deleted; If the current time is the marked time, decrement the target parameter value corresponding to any preset importance level by 1.
6. The method according to any one of claims 1-5, characterized in that, The step of determining the target importance of the target thread based on the target parameter value corresponding to each preset importance level includes: When there is at least one candidate importance among multiple preset importance levels, the target importance level is determined to be the highest importance level among the at least one candidate importance level, and the target parameter value corresponding to each candidate importance level indicates that the importance level of the target thread needs to be increased to the corresponding preset importance level; If no candidate importance is found among multiple preset importance levels, the target importance level is determined as the initial importance level, which is lower than each preset importance level.
7. The method according to any one of claims 1-6, characterized in that, The method further includes: Based on the correspondence between load range and mapping relationship, the target mapping relationship corresponding to the target load range is determined. The target load range is the load range to which the current load of the electronic device belongs. Each mapping relationship represents the correspondence between importance and priority. The highest priority in the first mapping relationship is lower than the highest priority in the second mapping relationship. The load value of the load range corresponding to the first mapping relationship is less than the load value of the load range corresponding to the second mapping relationship. Based on the target mapping relationship, the priority corresponding to the importance of the target is determined.
8. The method according to any one of claims 1-7, characterized in that, The step of obtaining multiple importance information configured for the target thread by multiple modules in the electronic device includes: Whenever initial information configured for the target thread by a module is received, if the module is located in the local layer and / or the application layer, it is determined whether the module belongs to the target module set. If a module belongs to the target module set, the initial configuration information of that module will be used as the importance information of the target thread.
9. The method according to any one of claims 1-8, characterized in that, Each importance level information includes a first indication information and a second indication information. The first indication information is used to indicate whether to increase or decrease the importance level of the target thread, and the second indication information is used to indicate the thread type of the target thread. The thread type is used to determine the preset importance level to which to increase or decrease the importance level.
10. An electronic device, characterized in that, The device includes a processor and a memory, the memory being used to store a computer program, and the processor being used to retrieve and run the computer program from the memory, causing the electronic device to perform the method of any one of claims 1 to 9.
11. A chip, characterized in that, It includes a processor and a data interface, wherein the processor reads instructions stored in memory through the data interface to implement the method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program for implementing the method of any one of claims 1 to 9.
13. A computer program product, characterized in that, When the computer program product is run on an electronic device, the electronic device is used to perform the method of any one of claims 1-9.