Thread control method and electronic equipment
By obtaining the scene and status information of the electronic device and determining the QoS level in combination with thread control strategies, the problem of mismatch between thread priority and operation characteristics is solved, and the optimization allocation of resources and efficiency improvement is achieved.
Patent Information
- Application Number
- CN202311865361.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-12-29
AI Technical Summary
The thread priority and operation characteristics in electronic devices do not match, resulting in waste of resources, especially in different scenarios, high-priority threads perform non-critical functions, affecting efficiency.
By obtaining the scene information and status information of electronic devices, combining different types of thread control strategies, the quality of service (QoS) level of the target thread is determined, and the target thread is controlled according to the QoS level, including thread control strategies of resident characteristics, dynamic characteristics and third-party characteristics, so as to achieve the matching of thread priority and device characteristics.
Optimize the resource allocation of electronic devices, improve the efficiency of thread management and the matching of equipment operation, and reduce resource waste.
Smart Images

Figure CN120276809A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software, and in particular, to a thread control method and an electronic device. Background Art
[0002] The control of threads in electronic devices such as mobile phones is very complex. The priorities of different threads may be different, and the higher-priority threads occupy more resources. During the user's use of the electronic device, the characteristics (or functions) of the electronic device's operation may not match the priorities of the threads, resulting in resource waste. For example, the high-priority InputReader thread is used to quickly respond to touch events on the touch screen. However, if the knuckle recognition feature that can be dynamically activated (selectively activated or deactivated) is implemented through the InputReader thread, the InputReader thread will frequently detect whether there is a knuckle tapping event on the touch screen with high priority. Summary of the Invention
[0003] Embodiments of this application provide a thread control method and an electronic device for matching the characteristics of the electronic device's operation with the priorities of the threads.
[0004] To achieve the above object, the embodiments of this application adopt the following technical solutions:
[0005] In a first aspect, a thread control method is provided, including: obtaining the scenario information and status information of the electronic device, where the scenario information is used to describe the usage scenario of the electronic device, and the status information is used to describe the operating state of the electronic device; obtaining the QoS level corresponding to the target thread according to the scenario information, status information, and thread control policies of different types of characteristics; and controlling the target thread according to the QoS level.
[0006] The thread control method provided by the embodiments of this application obtains the QoS level of the target thread to be controlled according to the scenario information (usage scenario) and status information (operating state) of the electronic device, as well as the thread control policies of different types of characteristics, and then controls the target thread according to the QoS level. Since the QoS level represents the priority of the target thread, and the determination of the QoS level is not only based on different types of characteristics but also combines the scenario information and status information of the electronic device, the characteristics of the electronic device's operation are matched with the priorities of the threads.
[0007] In a possible implementation manner, according to the scenario information, status information, and thread control policies of different types of characteristics, the QoS level corresponding to the target thread is obtained, including: according to the scenario information, status information, and thread control policy of the resident characteristic, the data pair corresponding to the first target thread is obtained. The data pair corresponding to the first target thread includes the first QoS level and the first hook function. The first target thread is a thread with the resident characteristic; controlling the target thread according to the QoS level includes: calling the first hook function to control the first target thread according to the first QoS level. For the first target thread that belongs to the resident characteristic of the system native, the thread control policy of the resident characteristic configures the data pair corresponding to the first target thread (the first QoS level and the first hook function). Finding this data pair enables the first target thread to be controlled by the first hook function according to the first QoS level.
[0008] In a possible implementation manner, when the first hook function corresponds to multiple different QoS levels, the first QoS level is the lowest QoS level. This can ensure that the first target thread is controlled properly according to the resource requirements of the first target thread.
[0009] In a possible implementation manner, it further includes: according to the status information, the call frequency of the activated dynamic characteristic, and the thread control policy of the dynamic characteristic, the data pair corresponding to the second target thread is obtained. The data pair corresponding to the second target thread includes the second QoS level and the second hook function. The second target thread is a thread with the dynamic characteristic; calling the second hook function to control the second target thread according to the second QoS level. For the second target thread that belongs to the dynamic characteristic of the system native, the thread control policy of the dynamic characteristic configures the data pair corresponding to the second target thread (the second QoS level and the second hook function). Finding this data pair enables the second target thread to be controlled by the second hook function according to the second QoS level.
[0010] In a possible implementation manner, when the second hook function corresponds to multiple different QoS levels, the second QoS level is the lowest QoS level. When the same hook function corresponds to multiple different QoS levels, retaining the lowest QoS level can ensure that the second target thread is controlled properly according to the resource requirements of the second target thread.
[0011] In a possible implementation manner, obtaining the QoS level corresponding to the target thread according to the scenario information, status information, and thread control policies of different types of characteristics includes: obtaining the data pair corresponding to the third target thread according to the scenario information, status information, and thread control policy of the third-party characteristic, where the data pair corresponding to the third target thread includes the third QoS level and the thread identifier TID, and the third target thread is a thread of the third-party characteristic; controlling the target thread according to the QoS level includes: calling the system scheduling thread to control the third target thread corresponding to the TID according to the third QoS level. For the third target thread belonging to the third-party characteristic, the thread control policy of the third-party characteristic configures the data pair corresponding to the third target thread (the third QoS level and the TID), and finding this data pair enables the system scheduling thread to control the first target thread corresponding to the TID according to the first QoS level.
[0012] In a possible implementation manner, when the TID corresponds to multiple different QoS levels, the third QoS level is the lowest QoS level. When the same hook function corresponds to multiple different QoS levels, retaining the lowest QoS level can ensure that the third target thread is controlled properly according to the resource requirements of the third target thread.
[0013] In a possible implementation manner, it further includes: comparing the data pair corresponding to the target thread obtained in this round with the data pair that has taken effect before this round of search to obtain the same data pair; subtracting the same data pair from the data pair corresponding to the target thread obtained in this round to obtain the data pair corresponding to the target thread that takes effect in this round. This can avoid the repeated effect of data pairs.
[0014] In a possible implementation manner, it further includes: subtracting the same data pair from the data pair that has taken effect before this round of search to obtain the data pair corresponding to the target thread to be rolled back; controlling the target thread to be rolled back to roll back according to the QoS level in the data pair corresponding to the target thread to be rolled back. This is equivalent to rolling back the target thread that does not meet the thread control target of this round to the initial state.
[0015] In a second aspect, an electronic device is provided, including a processor and a memory. Instructions are stored in the memory, and when the processor executes the instructions, the method described in the first aspect and any of its implementation manners is executed.
[0016] In a third aspect, a computer-readable storage medium is provided, including instructions, and when the instructions run on an electronic device, the electronic device is enabled to execute the method described in the first aspect and any of its implementation manners.
[0017] In a fourth aspect, a computer program product containing instructions is provided, and when the instructions run on the above-mentioned electronic device, the electronic device is enabled to execute the method described in the first aspect and any of its implementation manners.
[0018] In a fifth aspect, a chip system is provided. The chip system includes a processor for supporting an electronic device to implement the functions involved in the first aspect above. In a possible design, the device further includes an interface circuit, which can be used to receive signals from other devices (such as a memory), or to send signals to other devices (such as a communication interface). The chip system may include chips and may also include other discrete devices.
[0019] For the technical effects of the second aspect to the fifth aspect, reference may be made to the technical effects of the first aspect and any of its embodiments, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of an air gesture recognition feature provided by an embodiment of the present application;
[0021] Figure 2 A schematic diagram of a video call scenario provided by an embodiment of the present application;
[0022] Figure 3 A schematic diagram of different priority threads provided by an embodiment of the present application;
[0023] Figure 4 A schematic diagram of a three-finger swipe up feature provided by an embodiment of the present application;
[0024] Figure 5 A schematic diagram of a thread control strategy for a persistent feature provided by an embodiment of the present application;
[0025] Figure 6 A schematic diagram of a thread control strategy for a dynamic feature provided by an embodiment of the present application;
[0026] Figure 7 A schematic diagram of a thread control strategy for a third-party feature provided by an embodiment of the present application;
[0027] Figure 8 A schematic diagram of a thread control system provided by an embodiment of the present application;
[0028] Figure 9 A schematic diagram of a software architecture of an electronic device provided by an embodiment of the present application;
[0029] Figure 10 Another schematic diagram of a software architecture of an electronic device provided by an embodiment of the present application;
[0030] Figure 11 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application;
[0031] Figure 12Schematic flowchart of a thread control method provided by an embodiment of the present application;
[0032] Figure 13 Schematic flowchart of another thread control method provided by an embodiment of the present application;
[0033] Figure 14 Schematic diagram of an example of a thread control strategy provided by an embodiment of the present application;
[0034] Figure 15 Schematic structural diagram of a chip system provided by an embodiment of the present application. Detailed implementation manners
[0035] First, some concepts related to the present application are described.
[0036] Terms such as "first" and "second" involved in the embodiments of the present application are only used for the purpose of distinguishing features of the same type, and cannot be understood as indicating relative importance, quantity, order, etc.
[0037] Terms such as "exemplary" or "for example" involved in the embodiments of the present application are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Exactly, using terms such as "exemplary" or "for example" aims to present relevant concepts in a specific manner.
[0038] Terms such as "coupled" and "connected" involved in the embodiments of the present application should be understood in a broad sense. For example, it may refer to a direct physical connection, or may refer to an indirect connection implemented through electronic devices, such as a connection implemented through resistors, inductors, capacitors or other electronic devices.
[0039] When users daily use electronic devices such as mobile phones, common features (such as calls, games, short video applications, shopping applications, chat applications) only account for a very small part of mobile phone applications, and the usage rate of the remaining features (such as memos, calendars, etc.) is relatively low. Moreover, even the usage rate of the same feature may be different in different scenarios.
[0040] Take Figure 1Take the air gesture recognition feature shown as an example: In the scenario where both hands are wet and inconvenient to operate the mobile phone, the usage rate is relatively high; in the scenario where both hands can conveniently control the mobile phone, the usage rate is relatively low; in the scenarios of cycling and driving navigation, in scenarios that require strong interaction with the touch screen such as playing games, and in scenarios where the ambient light is very dim, the usage rate is extremely low; after the novelty of some users for the air gesture recognition feature has passed, the usage rate may decrease or they may not use it at all; in scenarios where the air gesture recognition feature is incompatible or not supported, such as horizontal screen, lock screen, text input method, split screen or floating window, mobile phone and laptop collaboration, single - hand operation mode, screen reader, etc., air gesture operation is not supported.
[0041] In addition, the specifications of the same feature in different scenarios (such as the display interface and resource occupancy) may also be different. Take Figure 2 the video call scenario shown as an example. As Figure 2 shown in A in it, when starting a video call, both parties focus on the video call interface, and at this time, the full - screen video call specification can be adopted. As Figure 2 shown in B in it, after a period of time, one party no longer needs to focus on the video call interface but needs to browse the web, then it switches to the small - window video call specification. As Figure 2 shown in C in it, after another period of time, one party feels that the small - window video call interface still blocks the web page and is troublesome to move, then it switches to the hidden voice call specification. After another period of time, one party needs to rest the eyes, then the screen is turned off and it switches to the screen - off voice call specification.
[0042] In addition, when the feature is running, the system load is very heavy and the thread priority allocation may not be reasonable. The features running on the electronic device may not match the thread priorities, resulting in resource waste. For example, taking the overall machine thread load as an example, after the mobile phone is turned on, more than 6000 threads are running, and in some scenarios, even more than 8000 threads are running, and some of these threads are active threads with a higher load. Taking the scenario of the above - mentioned video call plus browsing the web as an example, the number of active threads exceeds 2000 within 10 seconds.
[0043] As Figure 3 shown in A in it, high - priority threads (such as thread A) are usually used to execute critical functions, and low - priority threads (such as thread B) are usually used to execute non - critical functions, such as functions for executing certain features. However, in some scenarios, in order to enable the feature to be quickly responded to, the function of this feature (non - critical function) is added to the high - priority thread, but this will cause the high - priority thread to be very bloated and may not execute high - priority services, resulting in a lower execution efficiency. The ideal state is as Figure 3 shown in B in it, where high - priority threads execute critical functions and low - priority threads execute non - critical functions.
[0044] For example, a high-priority InputReader thread is used to quickly respond to touch events on the touch screen. However, if a function (non-critical function) for a knuckle recognition feature that can be dynamically activated (selectively activated or deactivated) is added to the InputReader thread, that is, implemented through the InputReader thread, the InputReader thread will frequently detect whether a knuckle tap event occurs on the touch screen with high priority. Another example is that a high-priority desktop thread is used to quickly respond to icon click operations. However, if a function (non-critical function) for the three-finger swipe-up feature shown in Figure 4 is added to the desktop thread, that is, implemented through the desktop thread, the desktop thread will frequently detect whether a three-finger swipe-up event occurs with high priority.
[0045] The thread control method and electronic device provided in the embodiments of the present application combine the scenario information and status information of the electronic device, as well as the thread control strategies for different types of features, to obtain the QoS level of the target thread to be controlled. The target thread is a thread for at least one of different types of features, and the QoS level represents the priority of the target thread. Then, the target thread is controlled according to the QoS level. The features of the electronic device during operation are matched with the priorities of the threads. Regarding the scenario information and status information of the electronic device, refer to the relevant description of S101 in Figure 12 , which will not be elaborated here.
[0046] The thread control strategies in the embodiments of the present application include the thread control strategy for resident features, the thread control strategy for dynamic features, and the thread control strategy for third-party threads. Resident features refer to the system-native, relatively critical, and resident-running features. For example, resident features include touch on the touch screen, display on the display screen, etc. Dynamic features refer to the system-native, non-critical, and dynamically activated (selectively activated or deactivated) features of the electronic device system. For example, dynamic features include air gesture recognition, knuckle recognition, etc. Third-party features refer to non-system-native features, such as chat applications, short video applications, etc.
[0047] Since the resident characteristics and dynamic characteristics are native to the system, the target threads of these characteristics can be controlled through hook functions. A hook function is code used to control a thread, and it can be loaded into the system to run through a system call to the thread. The hook function controls the target thread according to the quality of service (QoS) level corresponding to the target thread to be controlled. The hook function corresponding to the target thread and the QoS level can form a data pair. The QoS level of a thread is used to represent the priority (or importance) of the target thread. The higher the QoS level of a thread, the higher the priority (or importance); the lower the QoS level of a thread, the lower the priority (or importance).
[0048] The correspondence between the hook function and the target thread can include one-to-many and one-to-one.
[0049] One-to-many: When a process includes multiple threads, one hook function can control all the threads within a process. The main thread and other threads of the process are all target threads corresponding to the hook function. There is no need for each thread to correspond to one hook function, which can reduce the call frequency and implementation complexity of the hook function.
[0050] One-to-one: When the target thread is a kernel thread or a process includes only one main thread (as the target thread), one hook function corresponds to one target thread.
[0051] Since the third-party characteristics are not native to the system and it is impossible to design hook functions in advance, the target thread can be determined through the thread identifier (TID). The system scheduling thread controls the target thread corresponding to the TID according to the QoS level corresponding to the target thread. The TID corresponding to the target thread and the QoS level can also form a data pair.
[0052] As Figures 5 - 7 shown in A, the data structure of the thread control strategy includes the starting address of the scenario lookup table for resident characteristics, the starting address of the characteristic lookup table for dynamic characteristics, and the starting address of the scenario lookup table for third-party characteristics. The scenario lookup table for resident characteristics, the characteristic lookup table for dynamic characteristics, and the scenario lookup table for third-party characteristics are stored independently, and the starting address is equivalent to a pointer used to index these lookup tables.
[0053] Among them, the scenario lookup table for the resident feature is used to control the first target thread of the resident feature, that is, the scenario lookup table for the resident feature represents the thread control strategy of the resident feature. The feature lookup table for the dynamic feature is used to control the second target thread of the dynamic feature, that is, the feature lookup table for the dynamic feature represents the thread control strategy of the dynamic feature. The scenario lookup table for the third-party feature is used to control the third target thread of the third-party feature, that is, the scenario lookup table for the third-party feature represents the thread control strategy of the third-party feature.
[0054] 1. The scenario lookup table for the resident feature includes the mapping relationship between the scenario information, status information of the electronic device and the data pair (hook function and QoS level).
[0055] As Figure 5 shown in B, the scenario lookup table for the resident feature includes the addresses of each scenario (such as Scenario 1, Scenario 2) and the status type lookup tables of each scenario (such as the status type lookup table of Scenario 1, the status type lookup table of Scenario 2). By querying the scenario in the scenario lookup table for the resident feature through the scenario information of the electronic device, the address of the status type lookup table of this scenario can be determined, and then the status type lookup table of this scenario can be determined. Exemplarily, Scenario 1 is a full-screen video call, and Scenario 2 is a voice call.
[0056] As Figure 5 shown in C, the status type lookup tables of each scenario (such as the status type lookup table of Scenario 1) include the number of levels, the first-level parameter. Optionally, it can also include the second-level parameter and higher-level parameters. The number of levels indicates how many levels of parameters there are. The first-level parameter is the address of the default basic lookup table of the resident feature. The second-level parameter and other-level parameters include the status type (such as Status Type 1, Status Type 2) and the address of the value lookup table of the status type of the resident feature (such as the value lookup table of Status Type 1, the value lookup table of Status Type 2). So the number of levels is equal to the number of status types plus 1. By querying the status type in the status type lookup table of each scenario through the status type in the status information of the electronic device, the address of the value lookup table of the status type of the resident feature can be determined, and then the value lookup table of the status type of the resident feature can be determined. Exemplarily, the status type 1 of the second-level parameter is temperature, and the status type 2 of the third-level parameter is the battery life level, and so on.
[0057] As Figure 5As shown in Figure D, the default basic lookup table of the resident feature includes multiple table entries. Each table entry includes a hook function and a QoS level that form a data pair corresponding to a first target thread, and the first target thread is the thread of the resident feature. The result of querying the default basic lookup table of the resident feature is all the table entries (i.e., data pairs) of this lookup table. The meaning of the default basic lookup table of the resident feature is that in the absence of level 2 parameters and higher-level parameters, these table entries in the default basic lookup table of the resident feature can take effect simultaneously, so as to control all the first target threads of the resident features involved in this scenario to run in the default state. It should be noted that QoS level 1, QoS level 2, etc. in this application are only used to distinguish QoS levels, and do not mean that the QoS level values are 1 or 2.
[0058] As Figure 5 As shown in Figure E, the value lookup table of the status type of the resident feature includes different values of this status type, and the address of the basic lookup table of the values of the status type of the resident feature. By querying the values in the value lookup table of the status type through the value of the status type in the status information of the electronic device, the address of the corresponding basic lookup table can be determined, and then the corresponding basic lookup table can be determined. The basic lookup table of the values of the status type of the resident feature includes multiple table entries. Each table entry includes a hook function and a QoS level that form a data pair corresponding to a first target thread. The result of querying the basic lookup table of the values of the status type of the resident feature is all the table entries (i.e., data pairs) of this lookup table. Taking status type 1 as temperature as an example, when the value 1 of status type 1 is 37 degrees, the basic lookup table of the value 1 of status type 1 of the resident feature is queried, and when the value 1 of status type 1 is 42 degrees, the basic lookup table of the value 2 of status type 1 of the resident feature is queried. It should be noted that value 1 and value 2 of the status type in this application are only used to distinguish different values of the same status type, and do not mean that the values are 1 or 2.
[0059] It should be noted that the same table entries in different basic lookup tables of the resident feature (such as the default basic lookup table of the resident feature, the value lookup table of the status type of the resident feature) can share storage space to save the occupied storage space.
[0060] After querying the entire scenario lookup table of the resident feature, from the data pairs of different basic lookup tables of the resident feature obtained, a set of data pairs that are non-repetitive and have the lowest QoS level is obtained. The specific steps are as follows.
[0061] First, take the union of the data pairs of different basic lookup tables of the resident characteristics retrieved to obtain an initial set. For example, two data pairs in one basic lookup table are (hook function 1, QoS level value is 1) and (hook function 1, QoS level value is 2), and two data pairs in another basic lookup table are (hook function 1, QoS level value is 2) and (hook function 5, QoS level value is 3). Then the initial set includes the data pairs (hook function 1, QoS level value is 1), (hook function 1, QoS level value is 2), and (hook function 5, QoS level value is 3).
[0062] Then, for each hook function in the initial set, retain the data pair with the lowest QoS level (i.e., the first QoS level and the first hook function), that is, obtain a set of data pairs without duplicates and with the lowest QoS level. That is to say, when the first hook function corresponds to multiple different or identical QoS levels, the first QoS level is the lowest QoS level. For example, the data pairs in the initial set can be sorted twice. The first time is sorted according to the hook function, and the second time the data pairs with the same hook function are sorted according to the QoS level. For each hook function, select the data pair with the lowest QoS level, that is, obtain a set of data pairs without duplicates and with the lowest QoS level. It can ensure that the first target thread is controlled in place according to the resource requirements of the first target thread. For example, if there are two data pairs (hook function 1, QoS level value is 1) and (hook function 1, QoS level value is 2) in the initial set, then retain the data pair (hook function 1, QoS level value is 1).
[0063] For each data pair finally retained, the first hook function controls the first target thread corresponding to the data pair according to the first QoS level.
[0064] Second, the characteristic lookup table of the dynamic characteristics includes the mapping relationship between the call frequency of the characteristics, the status information of the electronic device, and the data pairs (hook function and QoS level). The characteristic lookup table of the dynamic characteristics does not distinguish the scenario information, that is, the characteristic lookup table of the dynamic characteristics can be traversed in any scenario.
[0065] As Figure 6 shown in B, the characteristic lookup table of the dynamic characteristics includes the addresses of each characteristic (such as characteristic 1, characteristic 2) and the frequency level lookup tables of each characteristic (such as the frequency level lookup table of characteristic 1, the frequency level lookup table of characteristic 2). Traverse each characteristic in the characteristic lookup table of the dynamic characteristics. If the characteristic is activated, query the usage frequency of the characteristic from the system. According to the usage frequency of the characteristic, the address of the frequency level lookup table of the characteristic can be determined, and then the frequency level lookup table of the characteristic can be determined. Exemplarily, characteristic 1 is the air gesture recognition characteristic, and characteristic 2 is the knuckle recognition characteristic.
[0066] As shown Figure 6 in C, the frequency level look-up table for each characteristic (e.g., the frequency level look-up table for characteristic 1) includes the addresses of the status type look-up tables for multiple frequency levels. Each frequency level is used to represent the frequency of invocation of the characteristic. For example, frequency levels 1-4 correspond to the frequencies of invocation of the characteristic as never, extremely low frequency, very low frequency, and low frequency in sequence. By querying the frequency levels of each characteristic, the address of the status type look-up table for the corresponding frequency level can be determined, and then the status type look-up table for the frequency level can be determined.
[0067] As shown Figure 6 in D, the status type look-up table for the frequency level includes the addresses of each status type (e.g., status type 1, status type 2) and the value look-up tables for the status types of dynamic characteristics (e.g., the value look-up table for status type 1 of the dynamic characteristic, the value look-up table for status type 2 of the dynamic characteristic). By querying the status types in the status type look-up table for each frequency level through the status types in the status information of the electronic device, the address of the value look-up table for the status type of the dynamic characteristic can be determined, and then the value look-up table for the status type of the dynamic characteristic can be determined. Exemplarily, status type 1 is temperature, status type 2 is battery life level, etc.
[0068] Figure 6 As shown in E, the value look-up table for the status type of the dynamic characteristic includes different values of the status type, and the address of the basic look-up table for the values of the status type of the dynamic characteristic. By querying the values in the value look-up table for the status type through the values of the status type in the status information of the electronic device, the address of the basic look-up table for the values of the status type of the dynamic characteristic can be determined, and then the basic look-up table for the values of the status type of the dynamic characteristic can be determined. Similar to the basic look-up table for the values of the status type of the resident characteristic in Figure 5 , the basic look-up table for the values of the status type of the dynamic characteristic includes multiple entries, and each entry includes a hook function and a QoS level that form a data pair corresponding to a second target thread, and the second target thread is the thread of the dynamic characteristic. The result of querying the basic look-up table for the values of the status type of the dynamic characteristic is all the entries (i.e., data pairs) of the look-up table.
[0069] It should be noted that the same entries in different basic look-up tables of the dynamic characteristic (e.g., the basic look-up table for the values of the status type of the dynamic characteristic) can share the storage space to save the occupied storage space.
[0070] After querying the entire characteristic look-up table of the dynamic characteristic, a set of data pairs that are non-repetitive and have the lowest QoS level is obtained from the data pairs in different basic look-up tables of the queried dynamic characteristic. Similar to the resident characteristic, the specific steps are as follows:
[0071] First, take the union of the data pairs of different basic lookup tables of the queried dynamic characteristics to obtain an initial set. Then, for each hook function in the initial set, retain the data pair with the lowest QoS level (i.e., the second QoS level and the second hook function), that is, obtain a set of data pairs without duplicates and with the lowest QoS level. That is to say, when the second hook function corresponds to multiple different or identical QoS levels, the second QoS level is the lowest QoS level. It can ensure that the second target thread is controlled in place according to the resource requirements of the second target thread.
[0072] For each of the finally retained data pairs, the second hook function controls the second target thread corresponding to the data pair according to the second QoS level.
[0073] Third, the scenario lookup table of the third-party characteristics includes the mapping relationship between the scenario information, status information of the electronic device, and the data pairs (TID and QoS level).
[0074] Such as Figure 7 As shown in B, the scenario lookup table of the third-party characteristics includes the addresses of each scenario (such as Scenario 1, Scenario 2) and the status type lookup tables of each scenario (such as the Scenario 1 lookup table, the Scenario 2 lookup table). By querying the scenario in the scenario lookup table of the third-party characteristics through the scenario information of the electronic device, the address of the status type lookup table of this scenario can be determined, and then the status type lookup table of this scenario can be determined. Exemplarily, Scenario 1 is a full-screen video call, and Scenario 2 is a voice call.
[0075] Such as Figure 7 As shown in C, the status type lookup tables of each scenario (such as the status type lookup table of Scenario 1) include the number of levels, the first-level parameters. Optionally, it can also include the second-level parameters and higher-level parameters. The number of levels indicates how many levels of parameters there are. The first-level parameter is the address of the default basic lookup table of the third-party characteristics. The second-level parameters and other-level parameters include the status types (such as Status Type 1, Status Type 2) and the addresses of the value lookup tables of the status types of the third-party characteristics (such as the value lookup table of the status type 1 of the third-party characteristics, the value lookup table of the status type 2 of the third-party characteristics). So the number of levels is equal to the number of status types plus 1. By querying the status type in the status type lookup table of each scenario through the status type in the status information of the electronic device, the address of the value lookup table of the status type of the third-party characteristics can be determined, and then the value lookup table of the status type of the third-party characteristics can be determined. Exemplarily, the status type 1 of the second-level parameter is temperature, and the status type 2 of the third-level parameter is the battery life level, etc.
[0076] Such as Figure 7As shown in Figure D, the default basic lookup table for third-party features includes multiple table entries. Each table entry includes the QoS level corresponding to a third target thread and the address of the thread context. The third target thread is a thread of a third-party feature. The thread context includes the process name, thread name, number of process identifiers (PID), and the address of PID information. Here, the number of PIDs indicates how many addresses of PID information there are. The same PID information includes the number of TIDs and the TID list. The number of TIDs indicates how many TIDs are in the TID list. The threads represented by the TIDs in the TID list are the third target threads. The result of querying the default basic lookup table for third-party features is all the table entries of this lookup table. By querying the address of PID information through the address of the thread context, and then querying the PID and the TID list corresponding to each PID from the system according to the process name and thread name, the PID and TID are filled into the reserved address space in the table entry. Each TID in the TID list and the corresponding QoS level form a data pair. The meaning of the default basic lookup table for third-party features is that in the absence of second-level parameters and higher-level parameters, these table entries in the default basic lookup table for third-party features can take effect simultaneously, so as to control the third target threads of all third-party features involved in this scenario to run in the default state.
[0077] As Figure 7 As shown in Figure E, the value lookup table for the status type of third-party features includes different values of this status type and the address of the basic lookup table for the values of the status type of third-party features. By querying the value of the status type in the status information of the electronic device in the value lookup table for the status type, the address of the basic lookup table for the values of the corresponding status type of third-party features can be determined, and then the basic lookup table for the values of the status type of third-party features can be determined. The result of querying the basic lookup table for the values of the status type of third-party features is all the table entries of this lookup table. By querying the address of PID information through the address of the thread context, and then querying the TID list, each TID in the TID list and the corresponding QoS level form a data pair.
[0078] It should be noted that the same table entries in different basic lookup tables for third-party features (such as the default basic lookup table for third-party features, the basic lookup table for the values of the status type of third-party features) can share storage space to save the occupied storage space.
[0079] After querying the entire scenario lookup table for third-party features, from the data pairs of different basic lookup tables for third-party features obtained, a set of data pairs that are non-repetitive and have the lowest QoS level is obtained. The specific steps are as follows:
[0080] First, take the union of the data pairs of different basic lookup tables of the queried third-party features to obtain an initial set. For example, two data pairs in one basic lookup table are (TID1, QoS level value is 1) and (TID1, QoS level value is 2), and two data pairs in another basic lookup table are (TID1, QoS level value is 2) and (TID5, QoS level value is 3). Then the initial set includes the data pairs (TID1, QoS level value is 1), (TID1, QoS level value is 2), and (Hook function 5, QoS level value is 3).
[0081] Then, for each TID in the initial set, retain the data pair with the lowest QoS level (i.e., the third QoS level and TID), that is, obtain a set of data pairs without duplicates and with the lowest QoS level. That is to say, when a TID corresponds to multiple different or the same QoS levels, the third QoS level is the lowest QoS level. For example, the data pairs in the initial set can be sorted twice. The first time is sorted according to TID, and the second time the data pairs with the same TID are sorted according to QoS level. For each TID, select the data pair with the lowest QoS level, that is, obtain a set of data pairs without duplicates and with the lowest QoS level. It can ensure that the third target thread is controlled in place according to the resource requirements of the third target thread. For example, if there are two data pairs (TID1, QoS level value is 1) and (TID1, QoS level value is 2) in the initial set, then retain the data pair (TID1, QoS level value is 1).
[0082] Send the composed data pair TID and the third QoS level to the system scheduler, and the system scheduler controls the third target thread corresponding to TID according to the third QoS level.
[0083] As Figure 8 shown, the embodiment of the present application provides a thread control system, including an electronic device 101 and a server 102.
[0084] At the software level, the electronic device 101 includes a scene recognition module 1011, a scene-based control middleware 1012, a policy customization module 1013 for third-party features, a thread control policy management module 1014, a policy customization module 1015 for the resident features and dynamic features of the system native, a thread control policy database 1016, and a thread control effect evaluation and feedback module 1017.
[0085] The policy customization module 1013 for third-party features is used to send the thread control policy of third-party features to the thread control policy management module 1014, and the policy customization module 1015 for the resident features and dynamic features of the system native is used to send the thread control policies of the resident features and dynamic features to the thread control policy management module 1014.
[0086] The thread control policy database 1016 stores thread control policies, which include thread control policies for third-party features as well as those for resident features and dynamic features. On the one hand, R & D personnel can preset thread control policies in the thread control policy database 1016. On the other hand, the thread control policy management module 1014 can update the thread control policies stored in the thread control policy database 1016 according to the thread control policies for third-party features as well as those for resident features and dynamic features.
[0087] The scenario recognition module 1011 is used to send the scenario information and status information of the electronic device to the scenario-based control middleware 1012. For the scenario information and status information of the electronic device, refer to Figure 12 the relevant description in S101, which will not be elaborated here. The scenario-based control middleware 1012 obtains the thread control policy from the thread control policy database 1016 through the thread control policy management module 1014, and executes the thread control policy in combination with the scenario information and status information of the electronic device. The thread control specifically includes methods such as scheduling control, freezing control, service level control, bypass control, start-stop control, and delay avoidance control. For these thread control methods, refer to Figure 12 the relevant description in S103, which will not be elaborated here.
[0088] The thread control effect evaluation and feedback module 1017 is used to evaluate the thread control effect (such as the positive gain and negative gain of thread control), and is also used to synchronize the thread control policy with the server 102 and send the synchronized thread control policy to the thread control policy management module 1014. The server 102 can synchronize the thread control policy with a large number of electronic devices (not only the electronic device 101, but also other electronic devices), and can also interact with R & D personnel to help update the thread control policy in the cloud database.
[0089] As Figure 9 shown, taking the electronic device running the Android operating system as an example, the software architecture includes an application layer, a framework layer, a native layer, a hardware abstract layer (HAL) layer, and a kernel layer.
[0090] The application layer may include a series of application packages, such as applications like camera, call, game, short video application, chat application, etc. The framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The framework layer includes some predefined functions. The native layer includes native services and link libraries, etc. The HAL layer is used to abstract the hardware. The HAL layer hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, having hardware independence. The kernel layer is the layer between the hardware and the software.
[0091] Figure 8 The scene recognition module 1011 in Figure 9 may be located in the application layer in Figure 9 while the policy customization module 1013 for third-party features and the policy customization module 1015 for system-native resident features and dynamic features in Figure 9 may be located in the framework layer in Figure 9 Other modules may be distributed across multiple layers. For example, the thread control policy database 1016, the thread control policy management module 1014, and the scenario control middle platform 1012 may be distributed in
[0092] For the scenario control middle platform, in a possible implementation, as Figure 10 shown in A - D in Figure 10 the scenario control middle platform in the upper layer (non-kernel layer) can perform thread control on the target thread in the same layer. Since the target thread calls other threads layer by layer downward, the scenario control middle platform indirectly realizes thread control on the other threads called by the target thread in the lower layer through thread control on the target thread in the same layer. For example, as Figure 10 shown in A in
[0093] the scenario control middle platform in the framework layer controls the thread BB in the framework layer. Thread BB then calls thread CC in the native layer, thread DD calls thread DD in the HAL layer, and thread DD calls thread EE in the kernel layer. Then the scenario control middle platform in the framework layer controls the thread BB in the framework layer, thus controlling threads CC, DD, and EE layer by layer. In another possible implementation, as Figure 10 shown in E in
[0093] the scenario control middle platforms in each layer can also independently perform thread control on the target thread in the same layer based on the interfaces for inter-process or inter-thread communication.
[0093] The electronic device provided by the embodiments of this application can be mobile or fixed. The electronic device can be deployed on land (such as indoors or outdoors, handheld or vehicle-mounted, etc.), on water (such as a ship, etc.), or in the air (such as an airplane, balloon, satellite, etc.). This electronic device can be referred to as a user equipment (UE), access terminal, terminal unit, subscriber unit, terminal station, mobile station (MS), mobile device, terminal agent, or terminal device, etc. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, smart bracelet, smart screen, smart watch, earphone, smart speaker, virtual reality (VR) device, augmented reality (AR) device, terminal in industrial control, terminal in self-driving, terminal in remote medical, terminal in smart grid, terminal in transportation safety, terminal in smart city, terminal in smart home, etc. The embodiments of this application do not limit the specific type and structure of the electronic device. A possible structure of the electronic device will be described below.
[0094] As Figure 11 shown, taking the electronic device as a mobile phone as an example, at the hardware level, the electronic device 101 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a power management module 240, a battery 241, a wireless charging coil 242, antenna 1, antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc. Optionally, in some embodiments, it further includes an audio digital signal processor (ADSP) 243.
[0095] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 101. In some other embodiments of the present application, the electronic device 101 may include more or fewer components than those illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0096] The processor 210 may include one or more processing units. For example, the processor 210 may be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processing unit (CPU), an application processor (AP), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a baseband processor, and a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors. For example, the processor 210 may be an application processor AP. Alternatively, the above-mentioned processor 210 may be integrated in a system on chip (SoC). Alternatively, the above-mentioned processor 210 may be integrated in an integrated circuit (IC) chip. The processor 210 may include an analog front end (AFE) and a microcontroller unit (MCU) in the IC chip.
[0097] The ADSP 243 can be coupled to the audio module 270 and the sensor module 280. The ADSP 243 can be used to process audio signals and also process sensor data. When the processor is in the sleep state, the ADSP 243 can still remain working, thereby reducing the power consumption of the electronic device.
[0098] It can be understood that the interface connection relationships among the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device 101. In other embodiments of the present application, the electronic device 101 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0099] The wireless communication function of the electronic device 101 can be implemented through antenna 1, antenna 2, the mobile communication module 250, the wireless communication module 260, the modulation and demodulation processor, and the baseband processor, etc.
[0100] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 101 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: Antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0101] The mobile communication module 250 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc. applied to the electronic device 101. The wireless communication module 260 can provide solutions for wireless communications including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. applied to the electronic device 101. In some embodiments, antenna 1 of the electronic device 101 is coupled to the mobile communication module 250, and antenna 2 is coupled to the wireless communication module 260, so that the electronic device 101 can communicate with the network and other devices through wireless communication technologies.
[0102] The external memory interface 220 can be used to connect to an external memory card, such as a micro SanDisk (Micro SD) card, to implement the storage capacity expansion of the electronic device 101. The external memory card communicates with the processor 210 through the external memory interface 220 to implement the data storage function. For example, files such as music and videos are saved in the external memory card.
[0103] The internal memory 221 can be used to store computer-executable program codes, and the executable program codes include computer instructions. The processor 210 executes various functional applications and data processing of the electronic device 101 by running the computer instructions stored in the internal memory 221. In addition, the internal memory 221 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0104] The memory involved in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memories of the systems and methods described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0105] The electronic device 101 can implement audio functions through the audio module 270, speaker 270A, receiver 270B, microphone 270C, headphone jack 270D, and application processor, etc. For example, music playback, recording, etc.
[0106] The audio module 270 is used to convert digital audio information into an analog audio signal for output, and is also used to convert analog audio input into digital audio signals. In some embodiments, the audio module 270 can be disposed in the processor 210, or some functional modules of the audio module 270 can be disposed in the processor 210. The speaker 270A, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The receiver 270B, also known as the "earpiece", is used to convert an audio electrical signal into a sound signal. The microphone 270C, also known as the "microphone", "transmitter", is used to convert a sound signal into an electrical signal. The electronic device 101 can be provided with at least one microphone 270C. The headphone jack 270D is used to connect a wired headphone. The headphone jack 270D can be a USB interface 230, or a 3.5 mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0107] The keys 290 include a power-on key, volume keys, etc. The keys 290 can be mechanical keys or touch keys. The electronic device 101 can receive key inputs to generate key signal inputs related to the user settings and function controls of the electronic device 101. The motor 291 can generate vibration prompts. The motor 291 can be used for incoming call vibration prompts or touch vibration feedback. The indicator 292 can be an indicator light, which can be used to indicate the charging state, battery level change, or can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 295 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 295 to achieve contact and separation with the electronic device 101. The electronic device 101 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. In some embodiments, the electronic device 101 uses an embedded SIM (eSIM) card, and the eSIM card can be embedded in the electronic device 101 and cannot be separated from the electronic device 101.
[0108] The electronic device 101 can implement the shooting function through the ISP, camera 293, video codec, GPU, display screen 294, application processor, etc. The ISP is used to process the data fed back by the camera 293. In some embodiments, the ISP can be set in the camera 293. The camera 293 is used to capture static images or videos. In some embodiments, the electronic device 101 may include one or N cameras 293, where N is a positive integer greater than 1.
[0109] The electronic device 101 can implement the display function through the GPU, display screen 294, application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs, which execute computer instructions to generate or change display information.
[0110] The sensor module 280 may include a pressure sensor, gyroscope sensor, barometric pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, angle sensor, etc. When the display screen 294 is a foldable screen, the angle sensor can detect the folding angle of the display screen 294, and the range of the folding angle is 0 - 180 degrees.
[0111] The battery 241 may include one or more batteries to supply power to the load.
[0112] The power management module 240 is used to receive the charging input from the charger. Among them, the charger can be a wireless charger, such as a wireless charging dock, other electronic devices 101 with reverse wireless charging function, etc. The power management module 240 can receive the wireless charging input through the wireless charging coil 242 of the electronic device. The charger can also be a wired charger. For example, the power management module 240 can receive the charging input of the wired charger through the USB interface 230. The power management module 240 is also called a charging chip.
[0113] Among them, while the power management module 240 charges the battery 241, it can also supply power to the electronic device. The power management module 240 receives the input from the battery 241 and supplies power to the processor 210, internal memory 221, external memory interface 220, display screen 294, camera 293, wireless communication module 260, etc. The power management module 240 can also be used to monitor parameters such as the capacity, voltage, number of battery cycles, battery health status (leakage, impedance) of the battery 241. In some other embodiments, the power management module 240 can also be set in the processor 210.
[0114] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel. In some embodiments, the electronic device 101 may include one or more display screens 294.
[0115] A memory may also be provided in the processor 210 for storing computer instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store the computer instructions or data that the processor 210 has just used or recycled. If the processor 210 needs to use the computer instructions or data again, it can directly call them from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0116] In some embodiments, the processor 210 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a USB interface, etc.
[0117] The processor 210 executes the thread control method provided by the embodiments of the present application by executing the programs and computer instructions stored in the internal memory 221.
[0118] As Figure 12 shown, the thread control method provided by the embodiments of the present application includes:
[0119] S101. The scene recognition module obtains the scene information and status information of the electronic device.
[0120] The scenario information of an electronic device is used to describe the usage scenarios of the electronic device, such as full-screen video call scenarios, voice call scenarios, etc. The scenario information of the electronic device can be uniquely identified by encoding. The status information of the electronic device is used to describe the operating state of the electronic device. The status information of the electronic device includes a status type and corresponding values, and both the status type and the corresponding values can be uniquely identified by encoding. Exemplarily, the status type includes the temperature of the electronic device, battery life level, CPU load, battery power, charging status, etc. Correspondingly, the values corresponding to the status type include the values of temperature, the values of battery life level, the values of CPU load, the values of battery power, and whether the charging status is charging, etc.
[0121] S102. The scenario-based control middleware obtains the data pair corresponding to the target thread to be controlled (including the QoS level of the target thread) according to the scenario information, status information of the electronic device, and thread control strategies of different types of characteristics.
[0122] As described above, the thread control strategies of different types of characteristics include the thread control strategy of the system-native resident characteristics, the thread control strategy of the system-native dynamic characteristics, and the thread control strategy of the third-party characteristics. The target thread is a thread with at least one of the characteristics of resident characteristics, dynamic characteristics, and third-party characteristics.
[0123] Combined with Figure 5 , for the resident characteristics, the scenario-based control middleware obtains the data pair corresponding to the first target thread (including the first QoS level and the first hook function) according to the scenario information, status information of the electronic device, and the thread control strategy of the resident characteristics. The first target thread is a thread with resident characteristics. This process refers to the relevant description in Figure 5 and will not be elaborated here.
[0124] Combined with Figure 6 , for the dynamic characteristics, regardless of the scenario information, the scenario-based control middleware obtains the data pair corresponding to the second target thread (including the second QoS level and the second hook function) according to the status information of the electronic device, the call frequency of the activated dynamic characteristics, and the thread control strategy of the dynamic characteristics. The second target thread is a thread with dynamic characteristics. This process refers to the relevant description in Figure 6 and will not be elaborated here.
[0125] Combined with Figure 7 , for the third-party characteristics, the scenario-based control middleware obtains the data pair corresponding to the third target thread (including the third QoS level and the TID) according to the scenario information, status information of the electronic device, and the thread control strategy of the third-party characteristics. The third target thread is a thread with third-party characteristics. This process refers to the relevant description in Figure 7 and will not be elaborated here.
[0126] In addition, as Figure 13 shown in S201, if the data pair corresponding to the target thread cannot be found, the default data pair is used as the data pair of the target thread to execute the default thread control policy. The reason is that it is difficult to enumerate all scenarios for the thread control policy. For scenarios not covered by the thread control policy, the default thread control policy is executed.
[0127] As Figure 13 shown in S202, if the data pair corresponding to the target thread is found, the scenario control middle platform can compare the data pair corresponding to the target thread obtained in this round with the data pair that has taken effect before this round of search to obtain the same data pair. Subtracting the above-mentioned same data pair from the data pair corresponding to the target thread obtained in this round, the data pair corresponding to the target thread that takes effect in this round can be obtained, which can avoid the repeated effect of the data pair.
[0128] As Figure 13 shown in S203, if the data pair corresponding to the target thread is found, the scenario control middle platform can also subtract the data pair that has taken effect before this round of search from the above-mentioned same data pair to obtain the data pair corresponding to the target thread to be rolled back. Control the target thread to be rolled back according to the QoS level in the data pair corresponding to the target thread to be rolled back. It is equivalent to rolling back the target thread that does not meet the thread control target of this round to the initial state. For example, if a certain target thread is controlled to switch from the full mode to the lightweight mode before this round of search, the target thread rollback means controlling the target thread to switch from the lightweight mode to the full mode.
[0129] Steps S202 and S203 essentially implement that when the scenario information changes, the data pair corresponding to the target thread is searched from the thread control policy according to the updated scenario information, when the status information changes, the data pair corresponding to the target thread is searched from the thread control policy according to the updated status information, and when the activation status of the dynamic characteristic changes, the data pair corresponding to the target thread is searched from the thread control policy according to the updated activation status of the dynamic characteristic.
[0130] S103. The scenario control middle platform controls the target thread according to the QoS level in the data pair corresponding to the target thread.
[0131] Combined with Figure 5 , for the resident characteristic, the scenario control middle platform calls the first hook function to control the first target thread according to the first QoS level. Combined with Figure 6 , for the dynamic characteristic, the scenario control middle platform calls the second hook function to control the second target thread according to the second QoS level. Combined with Figure 7For third-party features, the scenario control middleware calls the system scheduling thread to control the third target thread corresponding to the TID according to the third QoS level.
[0132] It should be noted that for a hook function, the hook function can control the target thread according to the QoS level by itself (for example, controlling the start or exit of the target thread), or send the QoS level to the target thread, and the target thread controls itself according to the QoS level (for example, switching between the full mode and the lightweight mode).
[0133] When a process includes multiple threads, a hook function can control all the threads of the process. That is, the main thread and other threads of the process are all target threads corresponding to the hook function. In this way, there is no need for each thread to correspond to a hook function, which can reduce the call frequency and implementation complexity of the hook function. The hook function can communicate with all the threads of the process to control all the threads, or the hook function can control other threads of the process by controlling the main thread of the process. For example, the hook function can send the QoS level to all the threads of the process. Or, the hook function can send the QoS level to the main thread of the process, and the main thread sets the QoS level as a thread environment variable shared by the threads in the process. Other threads in the same process can also obtain the QoS level through the thread environment variable.
[0134] The types of control over the target thread include system capability control and thread QoS management and control.
[0135] System capability control includes scheduling control and freezing control. Among them, scheduling control means that the target thread sends the thread identifier (TID) to the system scheduling service, and the system scheduling service speeds up or suppresses the target thread in terms of core selection, frequency selection, and grouping of the target thread according to the TID of the target thread. This control method depends on the scheduling system capability. Freezing control means that the target thread adds its own TID to the control group (cgroup), and the freezer subsystem freezes or wakes up the control group at a certain period, and then freezes or wakes up the target thread in the control group periodically. The control group is a mechanism used by the Linux kernel to control system resources. The control group divides all threads into groups and controls them according to the groups. Taking the freezer subsystem as an example, this subsystem can freeze or wake up threads in batches according to the group.
[0136] Thread QoS management and control includes service level control, bypass control, start / stop control, and delay avoidance control.
[0137] Service level control includes dynamic priority adjustment, full / lightweight mode control, and operation frequency adjustment. Among them, dynamic priority adjustment means dynamically adjusting its own priority according to the QoS level, where the higher the QoS level of the thread, the higher the priority. Full / lightweight mode control means dynamically switching between the full mode and the lightweight mode according to the QoS level. When the QoS level is higher than the threshold, the full mode is adopted; otherwise, the lightweight mode is adopted. For example, the chat software thread is in the full mode in the full-screen video call scenario, and the chat software thread is in the lightweight mode in the small-window video call or voice call scenario. Operation frequency adjustment means controlling the sleep cycle or thread detection cycle according to the QoS level. The lower the QoS level, the longer the sleep cycle or the longer the thread detection cycle. Thread detection refers to counting the running status of the thread.
[0138] Bypass control means that the entire thread can be controlled not to perform operations or some functions of the thread can be controlled to stop running according to the QoS level. For example, if the QoS level of the thread is lower than the threshold, the entire thread is controlled not to perform operations or some functions of the thread are controlled to stop running; otherwise, the entire thread is not controlled not to perform operations or some functions of the thread are not controlled to stop running.
[0139] Start / stop control means setting to trigger the target thread to automatically exit or restart according to the QoS level. For example, if the QoS level of the thread is lower than the threshold, the target thread is triggered to automatically exit; otherwise, the target thread is triggered to restart.
[0140] Delay avoidance control means that for threads with dynamic characteristics, the target thread is started at off-peak times or controlled to work at off-peak times after startup according to the QoS level. For example, threads with a high QoS level are started first, and threads with a low QoS level are started with a delay. Another example is that after multiple threads are started, threads with a high QoS level work normally first, and threads with a low QoS level work with a delay.
[0141] Exemplarily, as Figure 14 shown in A, in the small-window video call scenario of the chat software on the electronic device, the media decoding thread can be controlled to reduce the frame rate (corresponding to operation frequency adjustment). For example, the frame rate is reduced by 20%. The image quality enhancement function of the video post-processing thread can also be bypassed (corresponding to bypass control), so that the image quality enhancement function stops running.
[0142] As Figure 14As shown in Figure B, when the electronic device is in a video viewing scenario, if the air gesture recognition thread detects that the user does not use the air gesture recognition feature during video viewing, it can control the air gesture recognition thread to reduce its operating frequency (corresponding to the operating frequency adjustment in service level control). For example, the operating frequency can be reduced to 20% of the original. Additionally, the user will not use the always on (AO) feature either. The AO feature is used to control the image sensor to continuously capture images and perform recognition, and it can reduce the frequency of the images output by the AO thread (corresponding to the operating frequency adjustment in service level control).
[0143] As Figure 14 As shown in Figure C, when the electronic device is in a full-screen video call scenario of a chat software, since the user rarely performs knuckle operations, the knuckle recognition thread can be controlled to run in a lightweight mode (corresponding to full-scale lightweight mode control). For example, knuckle recognition is performed only based on the capacitance value of the touch screen, rather than based on the acceleration data and the capacitance value of the touch screen in the full-scale mode. It is also possible to schedule the knuckle recognition thread to run on the microkernel (corresponding to scheduling control) to reduce power consumption.
[0144] As Figure 14 As shown in Figure D, when the electronic device is in a full-screen video call scenario of a chat software and there is no risk of operating on a large amount of memory, the CameraProvider process can be controlled to stop the operation of the memory monitoring thread (corresponding to start / stop control) to stop monitoring the memory.
[0145] The thread control method and the electronic device provided by the embodiments of the present application obtain the QoS level of the target thread to be controlled according to the scenario information (usage scenario) and status information (operating status) of the electronic device, as well as the thread control strategies of different types of features, and then control the target thread according to the QoS level. Since the QoS level represents the priority of the target thread, and the determination of the QoS level is not only based on different types of features but also combines the scenario information and status information of the electronic device, the features of the electronic device operation are matched with the priority of the thread.
[0146] As Figure 15 As shown, the embodiments of the present application also provide a chip system. The chip system 150 includes at least one processor 1501 and at least one interface circuit 1502. The at least one processor 1501 and the at least one interface circuit 1502 can be interconnected through a line. The processor 1501 is used to support the electronic device to implement each step in the above method embodiments, for example Figure 12 、 Figure 13In the method shown, at least one interface circuit 1502 can be used to receive signals from other devices (such as memories) or send signals to other devices (such as communication interfaces). The chip system may include a chip and may also include other discrete devices.
[0147] An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium includes instructions that, when running on the above-mentioned electronic device, cause the electronic device to execute each step in the above method embodiment. For example, execute Figure 12 、 Figure 13 the method shown.
[0148] An embodiment of the present application also provides a computer program product including instructions that, when running on the above-mentioned electronic device, cause the electronic device to execute each step in the above method embodiment. For example, execute Figure 12 、 Figure 13 the method shown.
[0149] Regarding the technical effects of the chip system, computer-readable storage medium, and computer program product, refer to the technical effects of the foregoing method embodiments.
[0150] It should be understood that in various embodiments of the present application, the magnitude of the sequence numbers of the above processes does not mean 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 to the implementation process of the embodiments of the present application.
[0151] Those of ordinary skill in the art can realize that the modules and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0152] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and modules described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0153] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of devices or modules can be in electrical, mechanical, or other forms.
[0154] The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical modules, that is, they may be located in one device or distributed to multiple devices. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, in each embodiment of the present application, the functional modules can be integrated in one device, or each module can exist physically alone, or two or more modules can be integrated in one device.
[0156] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that contains one or more integrated media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0157] As described above, it is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed by this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims described.
Claims
1. A thread control method, characterized in that, Including: Obtaining the scenario information and status information of an electronic device, where the scenario information is used to describe the usage scenario of the electronic device, and the status information is used to describe the operating state of the electronic device; Obtaining the QoS level corresponding to the target thread according to the scenario information, the status information, and the thread control policies of different types of characteristics; Controlling the target thread according to the QoS level.
2. The method according to claim 1, wherein the obtaining the QoS level corresponding to the target thread according to the scenario information, the status information, and the thread control policies of different types of characteristics includes: obtaining the data pair corresponding to the first target thread according to the scenario information, the status information, and the thread control policy of the resident characteristic, where the data pair corresponding to the first target thread includes the first QoS level and the first hook function, and the first target thread is the thread of the resident characteristic; the controlling the target thread according to the QoS level includes: calling the first hook function to control the first target thread according to the first QoS level.
3. The method according to claim 2, characterized in that, When the first hook function corresponds to multiple different QoS levels, the first QoS level is the lowest QoS level.
4. The method according to any one of claims 1 to 3, characterized in that, It further includes: obtaining the data pair corresponding to the second target thread according to the status information, the call frequency of the activated dynamic characteristic, and the thread control policy of the dynamic characteristic, where the data pair corresponding to the second target thread includes the second QoS level and the second hook function, and the second target thread is the thread of the dynamic characteristic; calling the second hook function to control the second target thread according to the second QoS level.
5. The method according to claim 4, wherein When the second hook function corresponds to multiple different QoS levels, the second QoS level is the lowest QoS level.
6. The method according to any one of claims 1-5, wherein the obtaining the QoS level corresponding to the target thread according to the scenario information, the status information, and the thread control policies of different types of characteristics includes: obtaining the data pair corresponding to the third target thread according to the scenario information, the status information, and the thread control policy of the third-party characteristic, where the data pair corresponding to the third target thread includes the third QoS level and the thread identifier TID, and the third target thread is the thread of the third-party characteristic; the controlling the target thread according to the QoS level includes: calling the system scheduling thread to control the third target thread corresponding to the TID according to the third QoS level.
7. The method according to claim 6, characterized in that, When the TID corresponds to multiple different QoS levels, the third QoS level is the lowest QoS level.
8. The method according to any one of claims 2-7, characterized in that, It further includes: comparing the data pair corresponding to the target thread obtained in this round with the data pair that has taken effect before this round of search to obtain the same data pair; subtracting the same data pair from the data pair corresponding to the target thread obtained in this round of search to obtain the data pair corresponding to the target thread that takes effect in this round.
9. The method according to claim 8, wherein It further includes: subtracting the same data pair from the data pair that has taken effect before this round of search to obtain the data pair corresponding to the target thread to be rolled back; Control the rollback of the target thread to be rolled back according to the QoS level in the data pair corresponding to the target thread to be rolled back.
10. An electronic device, characterized in that, It includes a processor and a memory, and instructions are stored in the memory. When the processor executes the instructions, the method according to any one of claims 1-9 is executed.
11. A computer-readable storage medium, characterized in that, It includes instructions. When the instructions are executed on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-9.
Citation Information
Patent Citations
Course handling method and device
CN102831344A
Thread scheduling method and device, electronic equipment and storage medium
CN114816748A
Application program running method and electronic equipment
CN116700818A
Resource scheduling method, electronic equipment and storage medium
CN117130771A
Method and apparatus for allocating thread shared resource
WO2015096031A1