Task scheduling method, readable storage medium, program product and electronic device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2025-05-07
- Publication Date
- 2026-06-12
Smart Images

Figure CN120670104B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a task scheduling method, a readable storage medium, a program product, and an electronic device. Background Technology
[0002] Electronic devices typically contain multiple processors, such as a central processing unit (CPU), a neural processing unit (NPU), and a graphics processing unit (GPU). Different processors have different performance levels and uses. In some scenarios, multiple processors can work together to process the same task.
[0003] If a service is processed collaboratively by multiple processors, and the scheduling methods of the processors processing the service for the corresponding tasks are not matched, it may cause electronic devices to fail to respond to the service in a timely manner or waste computing resources. Summary of the Invention
[0004] In view of this, this application provides a task scheduling method, a readable storage medium, a program product, and an electronic device.
[0005] In a first aspect, a task scheduling method is provided, applied to an electronic device. The method includes: running a first application through a first processor of the electronic device, wherein the first application is running in the foreground; detecting a request from the first application to call a first service, and executing a first task included in the first service through a second processor of the electronic device, wherein the first task has a first priority on the second processor, and the operating frequency of at least one core in the second processor used to run the first task is a first operating frequency; detecting a switch from foreground to background running of the first application, and performing scheduling processing on the first service, wherein the scheduling processing includes: adjusting the priority of the first task on the second processor from the first priority to the second priority, and / or adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency.
[0006] Based on the above method, when the first application is running in the foreground, the electronic device can configure the priority of the first task on the second processor to be the first priority and the operating frequency of the kernel running the first task on the second processor to be the first operating frequency; when the first application is switched to running in the background, the priority of the first task on the second processor can be configured to be the second priority and / or the operating frequency of the kernel running the first task on the second processor can be configured to be the second operating frequency. In other words, the electronic device can use different priorities and / or different operating frequencies on the second processor to run the first task based on whether the first application is running in the foreground or background. This avoids delays or wasted resources in responding to the first service due to a mismatch between the priority of the first task on the second processor and the running state of the first application, and / or a mismatch between the operating frequency of the kernel running the first task on the second processor and the running state of the first application.
[0007] In one possible implementation of the first aspect above, the first service further includes a second task executed by the first processor, wherein when the first application is running in the foreground, the priority of the second task on the first processor is a third priority, and the operating frequency of one or more cores of the first processor used to execute the second task is a third operating frequency; the scheduling process further includes: adjusting the priority of the second task on the first processor from the third priority to the fourth priority; and / or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency.
[0008] In this implementation, the priorities of the first task executed by the first service on the second processor and the second task executed on the first processor can be dynamically adjusted according to changes in the running state of the first application. This avoids delays in the electronic device's response to the first service or wasted resources due to a mismatch between the priorities of the first task and the second task on the first processor. Furthermore, the operating frequency of the kernel executing the second task in the first processor can also be dynamically adjusted according to changes in the running state of the first application. This avoids delays in the electronic device's response to the first service or wasted resources due to a mismatch between the operating frequencies of the kernel executing the second task on the first processor and the kernel executing the first task on the second processor.
[0009] In one possible implementation of the first aspect above, when the first application is running in the foreground, the electronic device distributes the first task to the second processor based on the first priority; and the scheduling process further includes: adjusting the priority of the electronic device distributing the first task to the second processor from the first priority to the second priority.
[0010] In this implementation, the priority of the electronic device distributing the first task to the second processor can also change with the running state of the first application. This can avoid delaying the execution of the first task by distributing it to the second processor too late, or waste resources or affect the execution of other tasks in the second processor by distributing it to the second processor too early.
[0011] In one possible implementation of the first aspect above, the electronic device includes a first functional unit and a second functional unit, wherein the first functional unit is used to distribute a first task to the second functional unit, and the second functional unit is used to distribute the first task to a second processor. When the running state of the first application is in the foreground, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. The scheduling process further includes: distributing the first task to the second functional unit by the first functional unit based on a second distribution priority.
[0012] In this implementation, the distribution priority of the first task from the first functional unit to the second functional unit can also change with the running status of the first application. This can avoid delaying the execution of the first task by distributing it to the second functional unit too late, or waste resources or affect the second functional unit from distributing other higher priority tasks by distributing it to the second functional unit too early.
[0013] In one possible implementation of the first aspect above, the first priority, third priority, first distribution priority, first operating frequency, and third operating frequency are related to foreground operation, or to foreground operation and the device status of the electronic device; the second priority, fourth priority, second distribution priority, second operating frequency, and fourth operating frequency are related to background operation, or to background operation and the device status of the electronic device; wherein, the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0014] In one possible implementation of the first aspect above, the second priority is lower than the first priority, and / or the fourth priority is lower than the second priority, and / or the second distribution priority is lower than the first distribution priority, and / or the second operating frequency is lower than the first operating frequency, and / or the fourth operating frequency is lower than the second operating frequency.
[0015] In one possible implementation of the first aspect above, the foreground operation includes foreground operation and being the focus, and / or foreground operation and not being the focus; the background operation includes background operation and being perceptible to the user and / or background operation and not perceptible to the user.
[0016] In one possible implementation of the first aspect above, the method further includes: after detecting a request from the first application to call the first service, establishing a first association between the first application and the first task, wherein the first association includes the association between the first session identifier of the first session and the first application, and the association between the first session identifier and the first task.
[0017] In this implementation, the electronic device can, in response to a request from the first application to invoke the first service, establish a first association relationship between the first session identifier, the first application, and the first task. This first association relationship can be used by the electronic device to determine the priority of the first task on the second processor and / or the operating frequency of the kernel running the first task on the second processor based on the running state of the first application.
[0018] In one possible implementation of the first aspect above, the detection of switching the running state of the first application from foreground to background and scheduling the first service includes: in response to the switching of the running state of the first application from foreground to background, determining the first session identifier based on the first application and the first association relationship, and configuring the first service quality level corresponding to the background running for the first session corresponding to the first session identifier.
[0019] In this implementation, when the running state of the first application is switched from foreground to background, the electronic device can determine the first service quality level (e.g., L2, L4, L6 or L8) corresponding to the background operation based on the correlation between the running state and the service quality level (e.g., the correlation shown in columns 1 and 2 of Table 4 below, or the correlation shown in columns 1, 2 and 3 of Table 5 below).
[0020] In one possible implementation of the first aspect above, the detection of switching the running state of the first application from foreground to background and scheduling the first service further includes: adjusting the priority of the first task on the second processor from the first priority to the second priority based on the first service quality level, the association between the service quality level and the priority, and the first association; and / or, adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency based on the first service quality level, the association between the service quality level and the operating frequency, and the first association.
[0021] In this implementation, the electronic device can first determine the task priority (second priority) on the second processor corresponding to the first quality of service level based on the first quality of service level and the correlation between the quality of service level and priority (e.g., the correlation shown in columns 2 and 5 of Table 4 below); and / or determine the operating frequency (second operating frequency) corresponding to the core operating frequency level of the second processor based on the first quality of service level, the correlation between the quality of service level and core operating frequency (e.g., the correlation shown in columns 2 and 6 of Table 4 below). Then, the electronic device can adjust the priority of the first task on the second processor from the first priority to the second priority, and / or adjust the operating frequency of at least one core running the first task from the first operating frequency to the second operating frequency.
[0022] In one possible implementation of the first aspect above, the method further includes: deleting the first session in response to the completion of the first service execution or the first application stopping operation.
[0023] In one possible implementation of the first aspect above, the first quality of service level is related to background operation, or the first quality of service level is related to background operation and the device status of electronic devices, wherein the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0024] In one possible implementation of the first aspect above, the method further includes: after detecting a request from the first application to call the first service, establishing a second association relationship between the first application, the first task, and the second task, wherein the second association relationship includes the association relationship between the second session identifier of the second session and the first application, the association relationship between the second session identifier and the first task, and the association relationship between the second session identifier and the second task.
[0025] In one possible implementation of the first aspect above, the detection of switching the running state of the first application from foreground to background and scheduling the first service includes: in response to the switching of the running state of the first application from foreground to background, determining a second session identifier based on the first application and the second association relationship, and configuring a second service quality level corresponding to the background running for the second session corresponding to the second session identifier.
[0026] In this implementation, the electronic device can determine the second service quality level corresponding to the background operation based on the correlation between the operating status and the service quality level (such as the correlation shown in columns 1 and 2 of Table 4 below), or determine the second service quality level corresponding to the current device status level of the background operation and the electronic device based on the correlation between the operating status, device status level and service quality level (such as the correlation shown in columns 1 to 3 of Table 5 below).
[0027] In one possible implementation of the first aspect described above, the detection of switching the running state of the first application from foreground to background and scheduling the first service further includes: adjusting the priority of the first task on the second processor from the first priority to the second priority, adjusting the priority of the second task on the first processor from the third priority to the fourth priority, and adjusting the priority of the second functional unit to distribute the first task to the second processor from the third priority to the fourth priority, based on the second service quality level, the association between the service quality level and the priority, and the second association; and / or, adjusting the priority of the first functional unit to distribute the first task to the second functional unit from the first distribution priority to the second distribution priority, based on the second service quality level, the association between the service quality level and the distribution priority, and the second association; and / or, adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency, or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency, based on the second service quality level, the association between the service quality level and the operating frequency, and the second association.
[0028] In this implementation, the electronic device can first determine the task priority (second priority) on the second processor corresponding to the second quality of service level based on the second quality of service level and the relationship between the quality of service level and priority (e.g., the relationship shown in columns 3 and 6 of Table 5 below); and / or determine the task priority (fourth priority) on the first processor corresponding to the second quality of service level based on the second quality of service level and the relationship between the quality of service level and priority (e.g., the relationship shown in columns 3 and 4 ...6 of Table 5 below). The operating frequency (second operating frequency) corresponding to the core operating frequency level of the second processor is determined based on the correlation shown in columns 3 and 7; and / or the operating frequency (fourth operating frequency) corresponding to the core operating frequency level of the first processor is determined based on the correlation between the second quality of service level and the quality of service level and the core operating frequency (e.g., the correlation shown in columns 3 and 5 of Table 5 below); and / or the distribution priority (second distribution priority) corresponding to the second quality of service level is determined based on the correlation between the second quality of service level and the quality of service level and the distribution priority (e.g., the correlation shown in columns 3 and 4 of Table 6). Then, the electronic device can adjust the priority of the first task on the second processor from the first priority to the second priority, and / or adjust the priority of the second task on the first processor from the second priority to the fourth priority, and / or adjust the operating frequency of at least one core running the first task from the first operating frequency to the second operating frequency, and / or adjust the operating frequency of one or more cores running the second task from the third operating frequency to the fourth operating frequency, and / or adjust the priority of the first functional unit distributing the first task to the second functional unit from the first distribution priority to the second distribution priority.
[0029] In one possible implementation of the first aspect above, the method further includes: deleting the second session in response to the completion of the first service execution or the cessation of the first application.
[0030] In one possible implementation of the first aspect above, the second quality of service level is related to background operation, or the second quality of service level is related to background operation and the device status of electronic devices, wherein the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0031] In one possible implementation of the first aspect described above, the first processor is a central processing unit, and the second processor is a graphics processing unit or a neural network processor.
[0032] In one possible implementation of the first aspect described above, the first processor is a central processing unit, and the second task includes at least one thread associated with the first task.
[0033] In one possible implementation of the first aspect described above, the first service is an artificial intelligence service, the first processor is a central processing unit (CPU), the second processor is a neural network processor, the first task is a task included in the artificial intelligence service and executed in the neural network processor based on an artificial intelligence model, and the second task is at least one thread associated with the first task and running on the CPU. For example, if the first service is a Chinese-English translation service, the first task can be one or more tasks in task 01, and the second task can be a data transmission thread and / or a Chinese-English translation execution thread. Secondly, this application provides a task scheduling method applied to an electronic device. The method includes: running a first application through a first processor of the electronic device, the first application being in a first running state; detecting a request from the first application to call a first service, executing a first task corresponding to the first service through a second processor of the electronic device, wherein the first task has a first priority on the second processor, and the operating frequency of at least one core in the second processor used to run the first task is a first operating frequency; detecting a switch in the running state of the first application from the first running state to a second running state, and performing scheduling processing on the first service, the scheduling processing including: adjusting the priority of the first task on the second processor from the first priority to the second priority, and / or adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency; wherein the running state is used to indicate at least one of the following: the first application is running in the foreground or background, whether the first application is a focused application, and whether the first application is perceptible to the user.
[0034] Based on the above method, when the first application is in a first running state, the electronic device can configure the priority of the first task on the second processor to a first priority and the operating frequency of the kernel running the first task on the second processor to a first operating frequency. After the first application switches to a second running state, the electronic device can configure the priority of the first task on the second processor to a second priority and / or configure the operating frequency of the kernel running the first task on the second processor to a second operating frequency. In other words, the electronic device can use different priorities and / or different operating frequencies on the second processor to run the first task based on the different running states of the first application. This avoids delays or wasted resources in responding to the first service due to a mismatch between the priority of the first task on the second processor and the running state of the first application, and / or a mismatch between the operating frequency of the kernel running the first task on the second processor and the running state of the first application.
[0035] In one possible implementation of the second aspect above, the first service further includes a second task executed by the first processor. When the first application is in a first running state, the priority of the second task on the first processor is a third priority, and the operating frequency of one or more cores of the first processor used to execute the second task is a third operating frequency. The scheduling process further includes: adjusting the priority of the second task on the first processor from the third priority to the fourth priority; and / or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency. The high-low relationship between the third priority and the fourth priority is the same as the high-low relationship between the first priority and the second priority, and the magnitude relationship between the third operating frequency and the fourth operating frequency is the same as the magnitude relationship between the first operating frequency and the second operating frequency.
[0036] In one possible implementation of the second aspect above, when the first application is in a first running state, the electronic device distributes the first task to the second processor based on a first priority; and the scheduling process further includes: adjusting the priority of the electronic device distributing the first task to the second processor from the first priority to the second priority.
[0037] In one possible implementation of the second aspect above, the electronic device includes a first functional unit and a second functional unit, wherein the first functional unit is used to distribute a first task to the second functional unit, and the second functional unit is used to distribute the first task to a second processor. When the first application is running in the foreground, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. The scheduling process further includes: distributing the first task to the second functional unit by the first functional unit based on a second distribution priority.
[0038] In one possible implementation of the second aspect above, the first priority, third priority, first distribution priority, first operating frequency, and third operating frequency are related to foreground operation, or to foreground operation and the device status of the electronic device; the second priority, fourth priority, second distribution priority, second operating frequency, and fourth operating frequency are related to background operation, or to background operation and the device status of the electronic device; wherein, the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0039] In one possible implementation of the second aspect above, the running state of the first application includes multiple of the following states: running in the foreground and being the focus, running in the foreground but not the focus, running in the background and being perceptible to the user, running in the background and not perceptible to the user; or, the running state of the first application includes multiple of the following states: running in the foreground, running in the background and being perceptible to the user, running in the background and not perceptible to the user; or, the running state of the first application includes multiple of the following states: running in the foreground and being the focus, running in the foreground but not the focus, running in the background; or, the running state of the first application includes both running in the foreground and running in the background.
[0040] In one possible implementation of the second aspect above, the second priority is lower than the first priority and / or the second operating frequency is lower than the first operating frequency in the following situations: the first operating state is foreground running and is the focus, the second operating state is foreground running and is not the focus, running in the background and is perceptible to the user or running in the background and is not perceptible to the user; or, the first operating state is foreground running and is not the focus, the second operating state is background running and is perceptible to the user or running in the background and is not perceptible to the user; or, the first operating state is background running and is perceptible to the user, the second operating state is background running and is not perceptible to the user; or, the first operating state is foreground running and the second operating state is background running.
[0041] In one possible implementation of the second aspect above, the second priority is higher than the first priority and / or the second operating frequency is greater than the first operating frequency in the following situations: the first operating state is running in the background and is not perceived by the user, and the second operating state is running in the foreground and is the focus, running in the foreground and is not the focus, or running in the background and is perceived by the user; or, the first operating state is running in the background and is perceived by the user, and the second operating state is running in the foreground and is the focus or running in the foreground and is not the focus; or, the first operating state is running in the foreground and is not the focus, and the second operating state is running in the foreground and is the focus; or, the first operating state is running in the background, and the second operating state is running in the foreground.
[0042] In one possible implementation of the second aspect above, the method further includes: after detecting a request from the first application to call the first service, establishing a first association between the first application and the first task, wherein the first association includes the first session identifier of the first session, the association between the first application and the first task.
[0043] In one possible implementation of the second aspect above, the detection that the running state of the first application has switched from the first running state to the second running state, and the scheduling processing of the first service, includes: in response to the running state of the first application switching from the first running state to the second running state, determining a first session identifier based on the first application and a first association relationship, and configuring a first quality of service level corresponding to the second running state for the first session corresponding to the first session identifier; adjusting the priority of the first task on the second processor from the first priority to the second priority based on the first quality of service level, the association relationship between the quality of service level and priority, and the first association relationship; and / or, adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency based on the first quality of service level, the association relationship between the quality of service level and operating frequency, and the first association relationship.
[0044] In one possible implementation of the second aspect above, the method further includes: deleting the first session in response to the completion of the first service execution or the first application stopping operation.
[0045] In one possible implementation of the second aspect above, the first quality of service level is related to the second operating state, or to the second operating state and the device state of the electronic device, wherein the device state includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0046] In one possible implementation of the second aspect above, the method further includes: after detecting a request from the first application to call the first service, establishing a second association relationship between the first application, the second task, and the first task, wherein the second association relationship includes the second session identifier of the second session, the first application, the second task, and the association relationship between the first task.
[0047] In one possible implementation of the second aspect above, the detection that the running state of the first application has switched from the first running state to the second running state, and the scheduling processing of the first service, includes: in response to the switching of the running state of the first application from the first running state to the second running state, determining a second session identifier based on the first application and the second association relationship, and configuring a second service quality level corresponding to the second running state for the second session corresponding to the second session identifier; adjusting the priority of the first task on the second processor from the first priority to the second priority, and adjusting the priority of the second task on the first processor from the third priority to the fourth priority, based on the second service quality level, the association relationship between the service quality level and the priority and the second association relationship; and / or, adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency, or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency, based on the second service quality level, the association relationship between the service quality level and the operating frequency and the second association relationship; and / or, adjusting the priority of the first functional unit distributing the first task to the second functional unit from the first distribution priority to the second distribution priority, based on the second service quality level, the association relationship between the service quality level and the distribution priority and the second association relationship.
[0048] In one possible implementation of the second aspect above, the method further includes: deleting the second session in response to the completion of the first service execution or the cessation of the first application.
[0049] In one possible implementation of the second aspect above, the second quality of service level is related to a second operating state, or to the second operating state and the device state of the electronic device, wherein the device state includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
[0050] In one possible implementation of the second aspect above, the first processor is a central processing unit, and the second processor is a graphics processing unit or a neural network processor.
[0051] In one possible implementation of the second aspect described above, the first processor is a central processing unit, and the second task includes at least one thread associated with the first task.
[0052] Thirdly, a readable storage medium is provided, which includes one or more programs that, when executed on an electronic device, cause the electronic device to implement the task scheduling method provided in the first aspect and any possible implementation of the first aspect.
[0053] Fourthly, an electronic device is provided, comprising: a memory for storing one or more programs; and a processor for executing the one or more programs to cause the electronic device to implement the task scheduling method provided in the first aspect and any possible implementation of the first aspect.
[0054] Fifthly, a program product is provided that, when executed on an electronic device, enables the electronic device to implement the task scheduling method provided in the first aspect and any possible implementation of the first aspect.
[0055] It should be noted that the beneficial effects of the second to fifth aspects mentioned above can be referred to the content of the first aspect, and will not be repeated here. Attached Figure Description
[0056] Figure 1 According to some embodiments of this application, a schematic diagram of a Chinese-English translation service scenario is shown.
[0057] Figure 2A According to some embodiments of this application, a schematic diagram of the interaction between CPU and NPU in a Chinese-English translation business scenario is shown.
[0058] Figure 2B According to some embodiments of this application, a schematic diagram of an NPU task list is shown.
[0059] Figure 3A According to some embodiments of this application, a schematic diagram of a call application invoking a Chinese-English translation service is shown.
[0060] Figure 3B According to some embodiments of this application, a schematic diagram is shown of establishing a first association or a second association based on a session.
[0061] Figure 3C According to some embodiments of this application, a schematic diagram of tasks and threads related to English-Chinese translation services based on session scheduling is shown.
[0062] Figure 4A According to some embodiments of this application, a schematic diagram of the interactive process of an electronic device performing Chinese-English translation services is shown.
[0063] Figure 4B According to some embodiments of this application, a schematic diagram of the interactive process of another electronic device performing Chinese-English translation services is shown.
[0064] Figure 5 According to some embodiments of this application, a flowchart of a task scheduling method is shown.
[0065] Figure 6According to some embodiments of this application, a flowchart of another task scheduling method is shown.
[0066] Figure 7A According to some embodiments of this application, a schematic diagram of establishing a session corresponding to a synchronous service is shown.
[0067] Figure 7B According to some embodiments of this application, a schematic diagram of tasks and threads related to session scheduling synchronization services is shown.
[0068] Figure 8 According to some embodiments of this application, a flowchart of yet another task scheduling method is shown.
[0069] Figure 9 According to some embodiments of this application, a schematic diagram of a task scheduling device is shown.
[0070] Figure 10 According to some embodiments of this application, a schematic diagram of the structure of an electronic device 100 is shown. Detailed Implementation
[0071] The illustrative embodiments of this application include, but are not limited to, task scheduling methods, readable storage media, electronic devices, and program products.
[0072] To facilitate understanding, the terminology used in the embodiments of this application will be introduced first.
[0073] The technical solution of this application is described below with reference to the accompanying drawings.
[0074] It should be noted that the task scheduling method provided in this application embodiment can be applied to any electronic device, such as an electronic device including at least one or more processors. Exemplarily, electronic devices may include, but are not limited to, mobile stations (MS) and mobile terminals (MT), such as: mobile phones, smart TVs, wearable devices, tablets, desktop computers, laptops, virtual reality (VR) devices, augmented reality (AR) devices, terminals in industrial control, terminals in self-driving, terminals in remote medical surgery, terminals in smart grids, terminals in transportation safety, terminals in smart cities, terminals in smart homes, and in-vehicle terminals (such as vehicle infotainment systems, smart cockpits, in-vehicle tablets, etc.).
[0075] If a service is processed collaboratively by multiple processors, and the scheduling methods of the processors processing the service for the corresponding tasks are not matched, it may cause electronic devices to fail to respond to the service in a timely manner or waste computing resources.
[0076] For example, Figure 1 According to some embodiments of this application, a schematic diagram of a Chinese-English translation service scenario is shown.
[0077] like Figure 1 As shown, after receiving a call from user B's electronic device, the electronic device can display the incoming call interface U1 of the call application. The incoming call interface U1 can include user B's phone number "123456789", a reject control, an AI call control, and an accept control. The electronic device can respond to user A's click on the AI call control by displaying the AI call interface U2 to enable user A to conduct a call with user B based on artificial intelligence (AI) technology (such as Chinese-English translation, text calling, AI answering, etc.). Specifically, the Chinese-English translation service involves the electronic device converting user B's speech into text and displaying it on the interface, and converting text entered by user A into speech and sending it to user B's electronic device; the Chinese-English translation service is used to convert user A's Chinese speech into English speech and send it to user B's electronic device, and to convert user B's English speech into Chinese speech and play it; AI answering is used for the intelligent agent to conduct a call with user B.
[0078] Taking Chinese-English translation services as an example, the NPU of an electronic device can convert user B's English speech to Chinese speech and user A's Chinese speech to English speech by executing one or more tasks (hereinafter referred to as Task 01) required for the Chinese-English translation service. For example, Task 01 may include tasks such as converting user B's English speech to English text based on an automatic speech recognition (ASR) model, converting user A's Chinese speech to Chinese text, translating user A's Chinese text to English text based on a translation model, translating user B's English text to Chinese text based on a translation model, and converting translated user A's English text to English speech and translated user B's Chinese text to Chinese speech based on a text-to-speech (TTS) model. During the process of a call application invoking the Chinese-English translation service, refer to... Figure 2A The CPU of an electronic device can transmit the English voice of user B and the Chinese voice of user A to the NPU through one or more threads (hereinafter referred to as data transmission threads), and obtain the Chinese voice of user B and the English voice of user A obtained by the NPU executing task 01.
[0079] In some cases, refer to Figure 2B In addition to Task 01, which corresponds to the Chinese-English translation service, the NPU also executes Tasks 02, 03, and 04. In this scenario, if the NPU's scheduling method for Task 01 and the CPU's scheduling method for data transmission threads do not match the call service's operating state (e.g., foreground or background operation), the electronic device will be unable to respond to the Chinese-English translation service in a timely manner, thus affecting the user experience.
[0080] For example, for Figure 1 As shown, after the call application invokes the Chinese-English translation service, if the NPU prioritizes scheduling tasks 02, 03, and 04 and does not prioritize scheduling task 01, or if the CPU does not prioritize scheduling the aforementioned data transmission threads (or the processor core (hereinafter referred to as the kernel, also known as the processing core) used to run the data transmission threads runs at a lower operating frequency), the NPU may be unable to convert user B's English speech to Chinese speech in a timely manner, or convert user A's Chinese speech to English speech, resulting in a delay in user A hearing user B's Chinese speech or user B hearing user A's English speech.
[0081] Based on this, embodiments of this application provide a task scheduling method applied to an electronic device including multiple processors, wherein the multiple processors include a first processor and a second processor. During the execution of a first application by the electronic device through the first processor, the electronic device can, upon detecting that the first application calls a first service requiring the cooperation of the second processor, execute at least one task of the first service through the second processor (hereinafter, the at least one task executed by the second processor for the first service is referred to as the first task). During the execution of the first task through the second processor, the electronic device can dynamically configure the priority of the first task and / or the operating frequency of the second processor based on the running state of the first application. For example, the electronic device can adjust the priority of the first task on the second processor and adjust the operating frequency of the kernel running the first task in the second processor based on the running state of the first application. This avoids situations where the electronic device cannot execute the first service in a timely manner or causes resource waste due to a mismatch between the priority of the first task and the running state of the first application, and / or a mismatch between the operating frequency of the kernel running the first task and the running state of the first application.
[0082] It's important to note that the processor core's operating frequency (also known as clock speed, operating frequency, or frequency point) refers to the frequency at which the core operates when the processor executes instructions. The processor core's operating frequency can typically be adjusted within a certain range; the higher the processor core's operating frequency, the higher its computational performance. A processor may include one or more cores, and electronic devices can configure these cores with the same or different operating frequencies.
[0083] It's important to note that a business function can be broken down into one or more tasks, which can be executed by one or more processors. The specific form of the tasks executed on different processors can vary. For example, an NPU schedules and processes data at the task level. Tasks executed on an NPU can be tasks that process data using one or more models and obtain results, tasks that process data using one or more operators within those models, or tasks of other granularities defined by the processor based on its own operational logic. Similarly, a CPU schedules and processes data at the thread level, and tasks executed on a CPU can include one or more threads. Furthermore, an input / output (I / O) controller schedules and processes data at the I / O request level, and tasks executed on an I / O controller can be in the form of I / O requests.
[0084] For example, an electronic device can run a first application in a first operating state through a first processor. After detecting a request from the first application to call a first service, the electronic device can configure the priority of the first task corresponding to the first service on the second processor to a first priority that matches the first operating state, and schedule and execute the first task based on the first priority through the second processor.
[0085] In some embodiments, when the first application is in a first running state, the operating frequency of at least one core in the second processor used to perform the first task can also be configured to a first operating frequency that matches the first running state.
[0086] During the second processor's scheduling and execution of the first task based on the first priority, the electronic device can, after detecting a user's first operation of switching the running state of the first application from the first running state to the second running state, schedule the first service based on the second running state. This scheduling process may include: adjusting the priority of the first task on the second processor from the first priority to a second priority matching the second running state, and / or adjusting the operating frequency of at least one core from the first operating frequency to a second operating frequency matching the second running state.
[0087] Based on the above method, when the running state of the first application switches from the first running state to the second running state, the electronic device can adjust the priority of the first task corresponding to the first service from the first priority to the second priority that matches the second running state, and / or adjust the operating frequency of at least one of the kernels from the first operating frequency to the second operating frequency that matches the second running state, thereby avoiding the electronic device from being unable to execute the first service in a timely manner or causing resource waste.
[0088] In some embodiments, the first service may include one or more tasks executed by the first processor (hereinafter, the one or more tasks executed by the first processor in the first service are referred to as the second task). During the execution of the first service by the electronic device based on the second processor, the electronic device may also configure the priority of the second task on the first processor and / or the operating frequency of one or more cores running the second task based on the running state of the first application.
[0089] In some embodiments, the first processor may be a CPU, and the second task may include threads associated with the first task, such as threads that provide input data to the first task, threads that obtain the execution result of the first task, threads that schedule threads that provide input data to the first task or threads that obtain the execution result of the first task, the parent thread to which the thread that provides input data to the first task belongs, the parent thread to which the thread that obtains the execution result of the first task belongs, etc.
[0090] For example, when the first application is in a first running state, the priority of the second task can be configured to a third priority matching the first running state, and the operating frequency of the one or more cores can be configured to a third operating frequency matching the first running state. After the first application switches from the first running state to the second running state, the priority of the second task can be configured to a fourth priority matching the second running state, and the operating frequency of the one or more cores can be configured to a third operating frequency matching the second running state. In this way, the priority of the second task and the priority of the first task are both associated with the running state of the first application, and the operating frequency of the one or more cores and the operating frequency of at least one core of the second processor are also associated with the running state of the first application. This can prevent the execution of the first service from being affected by the different scheduling methods of the second task by the first processor and the second processor.
[0091] In some embodiments, when a first application invokes a first service, the electronic device can establish a first association between the first application and the first service, and a corresponding first task; or a second association between the first application, the first service, and the corresponding first task and second task. Thus, the electronic device can, when the running state of the first application changes, locate the first task to be scheduled based on the first association, or locate the first and second tasks to be scheduled based on the second association. The methods for establishing the first and second associations will be described below and will not be elaborated upon here.
[0092] In some embodiments, to balance parameters such as performance, power consumption, heat dissipation, and battery life of the electronic device, the settable range of the operating frequencies of the cores of the first and second processors can be related to the device state of the electronic device. The device state may include, but is not limited to, one or more of the following: remaining battery power, temperature, processor load, power connection status, and available memory bandwidth. For example, when the electronic device has a large remaining battery power, and / or a low temperature, and / or a low processor load, and / or the processor is connected to power, and / or the available memory bandwidth is high, the maximum operating frequency of the cores of the first and / or second processors can be configured to a higher value to improve the performance of the first and second processors. Conversely, when the electronic device has a small remaining battery power, and / or a high temperature, and / or a high processor load, and / or the processor is not connected to power, and / or the available memory bandwidth is low, the maximum operating frequency of the cores of the first and / or second processors can be configured to a lower value to improve the battery life or reduce the temperature of the electronic device. Therefore, during the scheduling and processing of the first service, the specific values of the operating frequencies of the cores of the first and second processors can also be determined based on the device state of the electronic device. This will be described in detail below and will not be elaborated upon here.
[0093] The following describes the application's running status.
[0094] It should be noted that the running state of an application is used to indicate whether the application is running in the foreground or background. In some embodiments, the running state may include the following states ST1 to ST4:
[0095] ST1, running in the foreground and being the focus, means the application is running in the foreground and is the focus application. Running in the foreground means the application is in the foreground; the focus application means the application is the currently active application, such as the last application run in the foreground, or the application whose last action was performed by the user.
[0096] ST2, running in the background and perceptible to the user. "Running in the background" means the application is active in the background; "perceptible to the user" means the application provides information to the user through a display interface, sound, vibration motor, indicator lights, etc. Examples include applications running in the background that play audio or video, applications running in the background that control the indicator lights on or off of electronic devices, applications running in the background that vibrate through the motors of electronic devices, and applications running in the background that display parts of the application's content through small windows, live windows, etc.
[0097] ST3, running in the foreground but not in focus, means the application is running in the foreground but is not the focus application.
[0098] ST4. Running in the background and imperceptible to the user. This means that the application runs in the background and does not display any content on the electronic device's screen, nor does it provide information to the user through any means other than the electronic device's screen.
[0099] It should be noted that in other embodiments, the application's running state can be divided into more or fewer states, or some states can be merged / split, without limitation here. For example, running in the foreground and being the focus, and running in the foreground but not the focus can be divided into one running state (e.g., foreground running (denoted as ST5)). Similarly, running in the background and being perceptible to the user, and running in the background and not perceptible to the user can be divided into one running state (e.g., background running (denoted as ST6)). For another example, state ST3 (foreground running but not the focus) can be divided into multiple running states based on whether the application's window is obscured by other application windows or the degree of obscuration, such as: running in the foreground and not the focus, and the window is not obscured; running in the foreground and not the focus, and the window is partially obscured; running in the foreground and not the focus, and the obscured area of the window is less than a first threshold; running in the foreground and not the focus, and the obscured area of the window is greater than a second threshold; running in the foreground and not the focus, and the obscured area of the window is between the first and second thresholds, etc.
[0100] It should be noted that the running state of the first application may include some or all of states ST1 to ST6, such as states ST1 to ST4, states ST5, ST2 and ST4, states ST1, ST3 and ST6, states ST5 and ST6, etc. This application embodiment does not limit the method of dividing the running state of the first application.
[0101] Below, based on the aforementioned operating states, we will introduce the scheme for prioritizing electronic device configuration tasks and the kernel's operating frequency.
[0102] For example, the electronic device can first establish a correlation between operating state and task priority, and / or a correlation between operating state and processor kernel operating frequency (hereinafter referred to as kernel operating frequency). Then, during the operation of the first application, the electronic device can determine, based on the operating state of the first application and the above correlations, the task priority of the first task corresponding to the first service called by the first application, the task priority of the second task, the operating frequency of the kernel of the second processor used to execute the first task, and the kernel operating frequency of the kernel of the first processor used to run the second task. Then, the electronic device can schedule and process the first service based on the task priority and kernel operating frequency obtained from the above correlations.
[0103] It should be noted that task priority can be the priority at which software modules in an electronic device (such as processor drivers, application programming interfaces, etc.) distribute tasks to the processor, or it can be the priority at which the processor executes tasks.
[0104] In some embodiments, the association between running state and task priority may include the association between the running state of the application and the task priority of the task running on the first processor, and the association between the running state and the task priority of the task running on the second processor.
[0105] In some embodiments, the relationship between the running state and the kernel operating frequency may include the relationship between the running state and the kernel operating frequency of the first processor, and the relationship between the running state and the kernel operating frequency of the second processor.
[0106] It should be noted that the relationship between running status and task priority, and the relationship between running status and kernel operating frequency, can be a direct relationship or an indirect relationship based on intermediate parameters (which can be one or more). When the relationship between running status and priority / kernel operating frequency is direct, the electronic device can directly determine the task priority of the first or second task, and the operating frequency of the kernel running the first or second task, based on the running status of the first application. When the relationship between running status and priority / kernel operating frequency is indirect (e.g., the relationship between running status and intermediate parameters, or the relationship between intermediate parameters and priority / kernel operating frequency), the electronic device can determine the intermediate parameters based on the running status of the first application and the relationship between running status and intermediate parameters, and then determine the task priority of the first or second task, and the kernel operating frequency of the kernel running the first or second task, based on the relationship between the intermediate parameters and priority / kernel operating frequency.
[0107] The following are some examples of establishing relationships between running status and priority, and between running status and kernel operating frequency.
[0108] Method 1: Directly establish the association between running status and task priority, and the association between running status and kernel operating frequency.
[0109] For example, Table 1 shows an example of the relationship between running status and task priority.
[0110] Table 1 shows the relationship between running status and task priority.
[0111]
[0112] As shown in Table 1, the running state of the first application can include states ST1 to ST4. The task priorities of the tasks executed by the first processor corresponding to states ST1 to ST4 can be arranged from high to low as task priority P1, task priority P2, task priority P3, and task priority P4. The task priorities of the tasks executed by the second processor corresponding to states ST1 to ST4 can be arranged from high to low as task priority P1', task priority P2', task priority P3', and task priority P4'.
[0113] Based on Table 1 above, the electronic device can configure the task priority of the first task to P1' and the task priority of the second task to P1 when the first application is running in ST1. Alternatively, the electronic device can configure the task priority of the first task to P2' and the task priority of the second task to P2 when the first application is running in ST2. Alternatively, the electronic device can configure the task priority of the first task to P3' and the task priority of the second task to P3 when the first application is running in ST3. Alternatively, the electronic device can configure the task priority of the first task to P4' and the task priority of the second task to P4 when the first application is running in ST4.
[0114] It should be noted that the specific names of task priorities P1 to P4 can be determined based on the supplier of the first processor or the operating system of the electronic device. For example, task priority P1 can be a real-time priority higher than task priority P2, task priority P2 can be a real-time priority lower than task priority P1, task priority P3 can be a non-real-time priority higher than task priority P4, and task priority P4 can be a non-real-time priority lower than task priority P3, wherein real-time priority is higher than non-real-time priority. Optionally, task priorities P1 to P4 are all lower than the priority corresponding to the thread / process / task used for drawing the display interface in the electronic device.
[0115] It should be noted that the specific names of task priorities P1' to P4' can be determined based on the supplier of the second processor or the operating system of the electronic device.
[0116] It should be noted that in other embodiments, more or fewer task priorities may be assigned. The number of task priorities of the first processor and the number of task priorities of the second processor may be the same or different, and this is not limited here.
[0117] It should be noted that the task priority relationships corresponding to the running states shown in Table 1 are only an example. In other embodiments, the task priorities corresponding to the running states can also be adjusted, and this application does not limit this. For example, the task priority relationship between state ST2 and state ST3 can be interchanged, such as state ST2 corresponding to the first processor having a task priority of P3 and state ST3 corresponding to the first processor having a task priority of P2, and / or state ST2 corresponding to the second processor having a task priority of P3' and state ST3 corresponding to the second processor having a task priority of P2'.
[0118] In some embodiments, multiple core operating frequency levels can be configured for the processor, with each core operating frequency level corresponding to a specific operating frequency of a processor core. A correspondence can then be established between the running state of an application and the core operating frequency level.
[0119] For example, Table 2 shows a correlation between operating state and kernel operating frequency level.
[0120] Table 2. Relationship between operating status and kernel operating frequency level
[0121]
[0122] As shown in Table 2, the operating states of the first application can include states ST1 to ST4. The core operating frequency levels of the first processor corresponding to states ST1 to ST4 can be arranged from high to low as the highest frequency, high frequency, medium frequency, and lowest frequency. The core operating frequency levels of the second processor corresponding to states ST1 to ST4 can be arranged from high to low as the highest frequency, high frequency, medium frequency, and lowest frequency. Among them, the frequency values or the maximum (or minimum, or median) of the frequency range corresponding to the highest frequency, high frequency, medium frequency, and lowest frequency decrease sequentially.
[0123] It should be noted that a working frequency level can correspond to a specific frequency value or a frequency range. For example, the working frequency can be configured using a lower frequency threshold and / or an upper frequency threshold: when the lower and upper frequency thresholds are the same, the kernel runs at the same frequency; when the lower and upper frequency thresholds are different, the kernel can run at any frequency between the lower and upper frequency thresholds (this arbitrary frequency can be a fixed value or dynamically changing); when only the lower frequency threshold is configured, the kernel can run at any frequency between the lower frequency threshold and the kernel's highest frequency value (this arbitrary frequency can be a fixed value or dynamically changing); when only the upper frequency threshold is configured, the kernel can run at any frequency between the kernel's lowest frequency value and the upper frequency threshold (this arbitrary frequency can be a fixed value or dynamically changing).
[0124] It should be noted that the specific operating frequencies corresponding to the core operating frequency levels of the first processor and the second processor can be the same or different, and this is not limited here. For example, if the frequency range of one core in the first processor is 1000 MHz to 2000 MHz, and the frequency range of another core in the second processor is 600 MHz to 1600 MHz, then the operating frequencies corresponding to the four operating frequency levels of the first processor's core (highest, high, medium, and lowest frequencies) can be 1900 MHz to 2000 MHz, 1500 MHz to 1700 MHz, 1200 MHz to 1300 MHz, and 1000 MHz to 1100 MHz, respectively. Meanwhile, the operating frequencies corresponding to the four operating frequency levels of the second processor's other core can be 1500 MHz to 1600 MHz, 1300 MHz to 1400 MHz, 1000 MHz to 1100 MHz, and 600 MHz to 800 MHz, respectively.
[0125] It should be noted that the specific operating frequencies of different cores within the same processor at the same operating frequency level can be the same or different. For example, if one core of a first processor has a frequency range of 1000MHz to 2000MHz, and another core has a frequency range of 800MHz to 1600MHz, then the operating frequencies corresponding to the four operating frequency levels for the first core (highest, high, medium, and lowest frequencies) can be 1900MHz to 2000MHz, 1500MHz to 1700MHz, 1200MHz to 1300MHz, and 1000MHz to 1100MHz, respectively. Meanwhile, the operating frequencies corresponding to the four operating frequency levels for the other core can be 1500MHz to 1600MHz, 1300MHz to 1400MHz, 1000MHz to 1100MHz, and 800MHz to 900MHz, respectively. Based on the relationships shown in Table 1, the electronic device can determine the corresponding QoS level based on the operating status of the first application during its operation. Then, the priority of the second task is configured based on the priority on the first processor corresponding to the QoS level, the priority of the first task is configured based on the priority on the second processor corresponding to the QoS level, the operating frequency of one or more cores of the first processor is configured based on the core operating frequency level of the first processor corresponding to the QoS level, and the operating frequency of at least one core of the second processor is configured based on the core operating frequency level of the second processor corresponding to the QoS level.
[0126] Based on the relationships shown in Table 2, the electronic device can, when the first application is running in ST1, configure the first task kernel running in the second processor to operate at the frequency corresponding to the "highest frequency" kernel operating frequency level, and / or configure the second task kernel running in the first processor to operate at the frequency corresponding to the "highest frequency" kernel operating frequency level. Alternatively, when the first application is running in ST2, the electronic device can configure the first task kernel running in the second processor to operate at the frequency corresponding to the "high frequency" kernel operating frequency level, and / or configure the second task kernel running in the first processor to operate at the frequency corresponding to the "high frequency" kernel operating frequency level. Alternatively, when the first application is running in ST3, the electronic device can configure the first task kernel running in the second processor to operate at the frequency corresponding to the "medium frequency" kernel operating frequency level, and / or configure the second task kernel running in the first processor to operate at the frequency corresponding to the "medium frequency" kernel operating frequency level. The electronic device can configure the first task kernel running in the second processor to operate at the lowest frequency corresponding to the kernel operating frequency level "lowest frequency" when the first application is running in ST4, and / or configure the second task kernel running in the first processor to operate at the lowest frequency corresponding to the kernel operating frequency level "lowest frequency".
[0127] It should be noted that in some other embodiments, the kernel operating frequency levels in Table 2 can also be replaced with specific frequency values or frequency ranges, which are not limited here.
[0128] It should be noted that the kernel operating frequency levels shown in Table 2 are only an example. In other embodiments, there may be more or fewer kernel operating frequency levels, which is not limited here. For example, when the number of kernel operating frequency levels is less than the number of running states, one kernel operating frequency level can correspond to multiple running states.
[0129] It should be noted that the relationship between the kernel operating frequency levels corresponding to the operating states shown in Table 1 is only an example. In other embodiments, the kernel operating frequency levels corresponding to the operating states can also be adjusted, and this application does not limit this. For example, the relationship between the kernel operating frequency levels corresponding to state ST2 and state ST3 can be interchanged. For instance, the kernel operating frequency level of the first processor corresponding to state ST2 can be a medium frequency, and the kernel operating frequency level of the first processor corresponding to state ST3 can be a high frequency, and / or the kernel operating frequency level of the second processor corresponding to state ST2 can be a medium frequency, and the kernel operating frequency level of the second processor corresponding to state ST3 can be a high frequency.
[0130] Method 2: Directly establish the association between running status, device status and task priority, as well as the association between running status, device status and kernel operating frequency.
[0131] In some embodiments, the core operating frequency can also be related to the device state of the electronic device. For example, when the electronic device has a high remaining battery power, and / or a low temperature, and / or a low processor load, and / or a processor connected to power, and / or high available memory bandwidth, the device state level is high, and the operating frequency of the cores of the first processor and / or the second processor can be configured to a higher value; when the electronic device has a low remaining battery power, and / or a high temperature, and / or a high processor load, and / or a processor not connected to power, and / or low available memory bandwidth, the device state level is low, and the operating frequency of the cores of the first processor and / or the second processor can be configured to a lower value.
[0132] Based on the aforementioned device status levels, the electronic device can first establish a correlation between device status level (or device status), operating status, and task priority, and / or a correlation between device status level (or device status), operating status, and kernel operating frequency. Then, during the execution of the first application, the electronic device can determine the task priority of the first task / second task corresponding to the first service called by the first application, as well as the operating frequency of the kernel used by the second processor to execute the first task and the operating frequency of the kernel used by the first processor to run the second task, based on the operating status of the first application, the device status level of the electronic device, and the correlations. The electronic device can then schedule and process the first service based on the task priority and operating frequency obtained from the aforementioned correlations.
[0133] For example, Table 3 shows an example of the relationship between running status, device status level, task priority, and kernel operating frequency level.
[0134] Table 3 shows the relationship between running status, device status level, task priority, and kernel operating frequency level.
[0135]
[0136] As shown in Table 3, when the device state level is DS1, the task priorities of the tasks executed by the first processor corresponding to states ST1 to ST4 can be task priorities P1, P2, P3, and P4, respectively. The task priorities of the tasks executed by the second processor corresponding to states ST1 to ST4 can be task priorities P1', P2', P3', and P4', respectively. When the device state level is DS2, the task priorities of the tasks in the first processor corresponding to states ST1 to ST4 can be task priorities P1, P2, P3, and P4, respectively. The task priorities of the tasks in the second processor corresponding to states ST1 to ST4 can be task priorities P1', P2', P3', and P4', respectively. When the device status level is DS3, the task priority on the first processor is task priority P5, and the task priority on the second processor is task priority P5'. Task priority P5 can be lower than or the same as task priority P4, and task priority P5' can be lower than or the same as task priority P4'.
[0137] Referring back to Table 3, when the device state level is DS1, the core operating frequency levels of the first processor corresponding to states ST1 to ST4 can be, in descending order: highest frequency, high frequency, medium frequency, and lowest frequency. The core operating frequency levels of the second processor corresponding to states ST1 to ST4 can also be, in descending order: highest frequency, high frequency, medium frequency, and lowest frequency. When the device state level is DS2, the core operating frequency levels of the first processor corresponding to states ST1 to ST4 can be, in descending order: medium frequency, medium frequency, lowest frequency, and lowest frequency. The core operating frequency levels of the second processor corresponding to states ST1 to ST4 can also be, in descending order: medium frequency, medium frequency, lowest frequency, and lowest frequency. When the device state level is DS3, the core operating frequency level of both the first and second processors can be the lowest frequency.
[0138] Based on Table 3 above, the electronic device can determine the task priority of the first processor, the task priority of the second processor, the core operating frequency level of the first processor, and the core operating frequency level of the second processor, all matching the operating state of the first application and the device state level of the electronic device. Then, the electronic device can schedule the second task based on the determined task priority of the first processor, schedule the first task based on the determined task priority of the second processor, configure the operating frequency of the kernel running the second task based on the determined core operating frequency level of the first processor, configure the operating frequency of the kernel running the first task and the second task based on the determined core operating frequency level of the second processor, or configure the second task based on the determined core operating frequency level. For example, if the operating state of the first application is ST3 and the device state level of the electronic device is DS1, the electronic device can schedule the second task based on task priority P3, schedule the first task based on task priority P3', configure the operating frequency of the kernel running the second task in the first processor to the operating frequency corresponding to the core operating frequency level "medium frequency," and configure the operating frequency of the kernel running the first task in the second processor to the operating frequency corresponding to the core operating frequency level "medium frequency."
[0139] It should be noted that in other embodiments, the device status level may include more or fewer levels, which is not limited here.
[0140] Method 3 indirectly establishes the correlation between running status and priority, and the correlation between running status and kernel operating frequency.
[0141] In some embodiments, the association between the Quality of Service (QoS) level (as an intermediate parameter) matching the running state of the application can be pre-configured (hereinafter referred to as the running state-QoS level association), and the association between the QoS level and the task priority of each processor's scheduled tasks can be configured (hereinafter referred to as the QoS level-priority association), and the association between the QoS level and the kernel operating frequency level of each processor can be configured (hereinafter referred to as the QoS level-operating frequency level association). During the operation of the first application, the electronic device can determine the QoS level corresponding to the running state of the first application based on the running state of the first application and the running state-QoS level association; then, the electronic device can adjust the task priority of the first task and the second task related to the first service based on the determined QoS level and the QoS-priority association, and / or adjust the operating frequency of the kernel executing the first task and the kernel executing the second task based on the determined QoS level and the QoS-operating frequency level association.
[0142] It should be noted that in some embodiments, some or all of the relationships between operating status and QoS level, QoS level and priority, and QoS level and operating frequency level can be merged into a single relationship. This application does not limit this aspect.
[0143] For example, Table 4 illustrates a relationship between operating state, QoS level, task priority, and kernel operating frequency level according to some embodiments of this application.
[0144] Table 4 shows the relationship between running status, QoS level, task priority, and kernel operating frequency level.
[0145]
[0146] As shown in Table 4, the operating states of the first application can include states ST1 to ST4, and the QoS levels corresponding to states ST1 to ST4 can be QoS levels L1 to L4, respectively. The task priorities of the tasks executed by the first processor corresponding to QoS levels L1 to L4 can be task priority P1, task priority P2, task priority P3, and task priority P4, respectively. The task priorities of the tasks executed by the second processor corresponding to QoS levels L1 to L4 can be task priority P1', task priority P2', task priority P3', and task priority P4', respectively. The core operating frequency levels of the first processor corresponding to QoS levels L1 to L4 can be the highest frequency, high frequency, medium frequency, and lowest frequency, respectively. The core operating frequency levels of the second processor corresponding to QoS levels L1 to L4 can be the highest frequency, high frequency, medium frequency, and lowest frequency, respectively.
[0147] In some embodiments, the association between the running status column (column 1) and the QoS level column (column 2) in Table 4 can be a running status-QoS level association. The association between the QoS level column and the task priority column (column 3) of the first processor and the task priority column (column 5) of the second processor in Table 4 can be a QoS level-priority association. The association between the QoS level column and the core operating frequency level column (column 4) of the first processor and the core operating frequency level column (column 6) of the second processor in Table 3 can be a QoS level-operating frequency level association.
[0148] Optionally, in some embodiments, Table 4 can be split into multiple tables to indicate different relationships. For example, the first and second columns of Table 4 can be split to obtain the operating status-QoS level relationship; the second, third, and fifth columns of Table 4 can be split to obtain the QoS level-priority relationship; and the second, fourth, and sixth columns of Table 4 can be split to obtain the QoS level-operating frequency level relationship. This application does not limit the scope of the embodiments.
[0149] Based on the relationships shown in Table 4, during the execution of the first service, the electronic device can first determine the QoS level associated with the running state of the first application in Table 4. Then, the electronic device can schedule the corresponding task based on the task priority associated with the determined QoS level, and configure the kernel operating frequency for executing the first or second task based on the kernel operating frequency level associated with the determined QoS level.
[0150] For example, when the first application is running in state ST4, the electronic device can determine the QoS level corresponding to state ST4 as L4 based on Table 4; then, the electronic device can determine the task priority on the first processor corresponding to QoS level L4 as P4, the task priority on the second processor corresponding to QoS level L4 as P4', the kernel operating frequency level of the first processor corresponding to QoS level L4 as the lowest frequency, and the kernel operating frequency level of the second processor corresponding to QoS level L4 as the lowest frequency; finally, the electronic device can configure the priority of the first task on the second processor as task priority P4, configure the priority of the second task on the first processor as task priority P4', configure the operating frequency of the kernel running the first task in the second processor as the operating frequency corresponding to the kernel operating frequency level "lowest frequency", and configure the operating frequency of the kernel running the second task in the first processor as the operating frequency corresponding to the kernel operating frequency level "lowest frequency".
[0151] Method 4: Indirectly establish the relationship between running status, device status and task priority, as well as the relationship between running status, device status and kernel operating frequency.
[0152] For example, Table 5 illustrates, according to some embodiments of this application, the relationship between the running state of an application, the device state level of an electronic device, the QoS level, the task priority, and the kernel operating frequency level.
[0153] Table 5 shows the relationship between operating status, device status level, QoS level, task priority, and kernel operating frequency level.
[0154]
[0155] As shown in Table 5, QoS levels include QoS levels L1 to L9, respectively for state ST1 and device state level DS1, state ST2 and device state level DS1, state ST3 and device state level DS1, state ST4 and device state level DS1, state ST1 and device state level DS2, state ST2 and device state level DS2, state ST3 and device state level DS2, state ST4 and device state level DS2, and device state level DS3 (in the case of device state level DS3, any operating state corresponds to QoS level L9).
[0156] Referring again to Table 5, the task priorities of the tasks executed by the first processor corresponding to QoS levels L1 to L9 can be task priority P1, task priority P2, task priority P3, task priority P4, task priority P1, task priority P2, task priority P3, task priority P4, and task priority P5, respectively. The task priorities of the tasks executed by the second processor corresponding to QoS levels L1 to L9 can be task priority P1', task priority P2', task priority P3', task priority P4', task priority P1', task priority P2', task priority P3', task priority P4', and task priority P5', where task priority P5' can be lower than or the same as task priority P4'. The core operating frequency levels of the first processor corresponding to QoS levels L1 to L9 can be the highest frequency, high frequency, medium frequency, lowest frequency, highest frequency, high frequency, medium frequency, lowest frequency, and lowest frequency, respectively. The core operating frequency levels of the second processor corresponding to QoS levels L1 to L9 can be arranged from high to low as follows: highest frequency, high frequency, medium frequency, lowest frequency, highest frequency, high frequency, medium frequency, lowest frequency, and lowest frequency.
[0157] Based on the relationships shown in Table 5, the electronic device can determine the corresponding QoS level during the operation of the first application, based on the running status of the first application and the device status level of the electronic device. Then, based on the task priority on the first processor corresponding to the QoS level, the task priority on the second processor corresponding to the QoS level is configured; based on the task priority on the second processor corresponding to the QoS level, the task priority on the first processor is configured; based on the core operating frequency level of the first processor corresponding to the QoS level, the operating frequency of one or more cores of the first processor is configured; and based on the core operating frequency level of the second processor corresponding to the QoS level, the operating frequency of at least one core of the second processor is configured.
[0158] For example, when the first application is running in state ST4 and the device state level is DS1, the electronic device can determine the QoS level corresponding to state ST4 and device state level DS1 as L4 based on Table 4. Then, the electronic device can determine the task priority on the first processor corresponding to QoS level L4 as P4, the task priority on the second processor corresponding to QoS level L4 as P4', the kernel operating frequency level of the first processor corresponding to QoS level L4 as the lowest frequency, and the kernel operating frequency level of the second processor corresponding to QoS level L4 as the lowest frequency. Finally, the electronic device can configure the task priority of the first task on the second processor as task priority P4, configure the task priority of the second task on the first processor as task priority P4', configure the operating frequency of the kernel running the first task in the second processor as the operating frequency corresponding to the kernel operating frequency level "lowest frequency", and configure the operating frequency of the kernel running the second task in the first processor as the operating frequency corresponding to the kernel operating frequency level "lowest frequency".
[0159] It should be noted that the device status levels, QoS level division methods, priority division methods, and operating frequency level division methods shown in Table 5 above are only examples. In other embodiments, more or fewer QoS levels may be divided based on the running status of the first application, or the running status of the first application and the device status of the electronic device; this is not limited here. For example, multiple QoS levels in Table 5 may correspond to the same task priority and / or the same kernel operating frequency level, and one task priority or kernel operating frequency level may also correspond to multiple QoS levels; this is not limited here.
[0160] In some embodiments, where the first task of the first service needs to pass through one or more functional units during the process of being distributed from the first processor to the second processor, the one or more functional units can also be configured with a distribution priority corresponding to the running state and device status level (or QoS level) of the first application. Any one of the one or more functional units can also distribute the first task based on the running state of the first application and the device status level of the electronic device during the distribution process.
[0161] It should be noted that distribution priority can refer to the priority of task transfer between software modules of an electronic device.
[0162] For example, Table 6 shows an example of the association between the QoS level and distribution priority of a first functional unit configured in one or more of the above functional units.
[0163] Table 6 shows the relationship between operating status, device status level, QoS level, and distribution priority.
[0164]
[0165] As shown in Table 6, the distribution priorities, from high to low, can include distribution priority DP1, distribution priority DP2, distribution priority DP3, distribution priority DP4, and distribution priority DP5. Among them, distribution priorities DP1, distribution priority DP2, distribution priority DP3, and distribution priority DP4 correspond to operating states ST1 to ST4, respectively, and the distribution priority corresponds to the device status level DS3.
[0166] based on Figure 6 As shown in the diagram, during the distribution of the first task, the first functional unit can distribute the first task to other functional units (such as the second functional unit) based on the running state of the first application and the device level of the electronic device, or based on the QoS level, using the corresponding distribution priority. For example, if the first functional unit obtains a QoS level of L3, it can distribute the first task to the second functional unit based on the distribution priority DP3 corresponding to L3. As another example, if the first functional unit obtains a running state of ST2 and a device status level of DS2 for the first application, it can distribute the first task to the second functional unit based on the distribution priority DP2 corresponding to state ST2 and device status level DS2.
[0167] It should be noted that the first functional unit may also configure only some of the relationships in Table 6, which is not limited here. For example, the first functional unit may configure the correspondence between QoS level and distribution priority, such as the relationship shown in columns 3 and 4 of Table 6; it may also configure the relationship between operating status, device status and distribution priority, such as the correspondence in columns 1, 2 and 4 of Table 6.
[0168] It should be noted that for multiple functional units involved in the same business, the tasks of the business can be configured with the same or different distribution priorities, and there is no limitation here.
[0169] It should be noted that in other embodiments, the distribution priority can also be divided in other ways, such as dividing more or fewer distribution priorities, which is not limited here.
[0170] The technical solution of this application will be introduced below, taking the first application as a call application and the first service as a Chinese-English translation service as an example.
[0171] For example, Figure 3A According to some embodiments of this application, a schematic diagram of a call application invoking a Chinese-English translation service is shown.
[0172] like Figure 3AAs shown, the electronic device detects that the user has enabled the Chinese-English translation service (e.g., it detects that the user clicks...). Figure 1 The AI call control can be operated by sending a request to the AI assistant process to invoke the Chinese-English translation service through the call process of the call application (the process used to implement the call function).
[0173] Then, in response to the call process, the AI assistant process can run the AI kit (hereinafter referred to as the AI kit) for handling the Chinese-English translation business. The Chinese-English translation AI kit can then request the AI business management service (a service for managing and coordinating AI business in electronic devices) to establish a thread in the AI business management service for executing the Chinese-English translation business (hereinafter referred to as the Chinese-English translation execution thread) and an AI task (e.g., task 01) for implementing the Chinese-English translation business.
[0174] It should be noted that an AI kit can be an interface in an electronic device used to implement AI services. One AI service can correspond to one AI kit, and one AI kit can correspond to one or more AI services.
[0175] Secondly, the Chinese-English translation execution thread can interact with the AI task executor to distribute task 01 to the AI task executor. After receiving task 01, the AI task executor can establish a thread associated with task 01 (such as a data transmission thread) in the CPU, load the AI model for executing task 01, and schedule the NPU to execute task 01.
[0176] Finally, the NPU can, based on the Chinese voice of user A sent by the data transmission thread, perform the following subtasks: Chinese speech to Chinese text (Task 01); Chinese text to English text (Task 01); and English text to English speech (Task 01). Then, through an AI task executor, AI task management service, and a Chinese-English translation AI kit, the NPU sends the English voice of user A to the call process for transmission to user B's electronic device. Similarly, the NPU can, based on the English voice of user B sent by the data transmission thread, perform the following subtasks: English speech to English text (Task 01); English text to Chinese text (Task 01); and Chinese text to Chinese speech (Task 01). Then, through an AI task executor, AI task management service, and a Chinese-English translation AI kit, the NPU sends the English voice of user B to the call process for playback.
[0177] It should be noted that, Figure 3A The process shown is just an example. In other embodiments, the first and second tasks (such as data transmission threads and Chinese-English translation execution threads) corresponding to the Chinese-English translation business can also be established in other forms, which are not limited here.
[0178] It should be noted that for other businesses, it can also be based on Figure 3A The process shown is used to create tasks corresponding to the business logic and threads associated with those tasks. For example, continue to refer to... Figure 3A The X process can run the XX process of the XX business by calling the AI assistant process, and establish the XX execution thread for executing the XX business through the XX process and the AI business management service, and establish the task corresponding to the XX business and the thread associated with the task corresponding to the XX business through the XX execution thread and the AI task executor.
[0179] Below, in conjunction with Figure 3A The process shown describes how an electronic device establishes a first association relationship between a first application and a first service called by the first application, corresponding to a first task, or establishes a second association relationship between a first application, a first service called by the first application, and a second task.
[0180] For example, when a first application calls a first service, the electronic device can establish a session related to the first application and the first service, and configure a globally unique session identifier (SID) for this session. Then, the electronic device can associate a first task corresponding to the first service with the configured SID; and when a second task of the first service is running on the CPU, it can also associate the second task with the configured SID. That is, the first application, the first service, and the corresponding first and second tasks are all associated with the same SID. In this way, a first association relationship can be established between the first application and the first task corresponding to the first service called by the first application, or a second association relationship can be established between the first application, the first task corresponding to the first service called by the first application, and the second task.
[0181] In some embodiments, the first application may invoke one or more services, each of which may correspond to a session, and the SIDs of the sessions corresponding to the one or more services are different.
[0182] In some embodiments, any process of the first application may also invoke one or more services, each of which may correspond to a session, and the SIDs of the sessions corresponding to the one or more services are different.
[0183] In some embodiments, the SID of a session can be randomly generated or generated in other ways. Different sessions correspond to different SIDs. Thus, even when multiple sessions exist in an electronic device, the device can still uniquely identify a session through a single SID, and thereby schedule tasks and threads configured with that SID, their task priorities / distribution priorities, and the kernel's operating frequency for running tasks / threads configured with that SID, based on the running state of the application corresponding to that SID. For example, Figure 3B According to some embodiments of this application, a schematic diagram of an architecture for establishing a session is shown.
[0184] For example, Figure 3B According to some embodiments of this application, a schematic diagram is shown of establishing a first association or a second association based on a session.
[0185] like Figure 3B As shown, an electronic device may include a system framework, scheduling management service, CPU scheduler, call application, AI assistant, AI subsystem and AI task executor.
[0186] The system framework may include application programming interfaces (APIs) provided by the operating system or applications of the electronic device, which allow users to obtain or view the device status (or device status level) and the running status of the applications. Applications, services, or modules within the electronic device can obtain the device status (or device status level), the running status of the applications, or the operating frequency level through the APIs provided by the system framework.
[0187] The scheduling management service can be used to establish and maintain (e.g., update, destroy) sessions, and can also determine the QoS level of the session corresponding to the application based on the application's running status (or the application's running status and the electronic device's device status).
[0188] In some embodiments, the scheduling management service may, in response to an AI assistant’s call, establish a session associated with the business to be performed by the AI assistant and configure a globally unique SID for the established session, and establish an association between the configured SID and the identifier of the entity (e.g., application, process, thread, or service, hereinafter referred to as the initiator) that calls the AI business provided by the AI assistant (hereinafter referred to as the initiator identifier).
[0189] For example, refer to Figure 3B In section ①, the Chinese-English translation AI kit can invoke the API provided by the scheduling management service for establishing a session when it detects that the call process of the call application is calling the Chinese-English translation AI kit. The scheduling management service can respond to the call of the Chinese-English translation AI kit, establish a session S1 corresponding to the Chinese-English translation service, and send the session identifier SID1 of session S1 to the Chinese-English translation AI kit.
[0190] Continue to refer to Figure 3B In section ①, for Chinese-English translation services, the initiator identifier can be the process identification (PID) of the call process. Calling the scheduling management service can establish an association between the process identification (e.g., PID1) of the call process and SID1.
[0191] It should be noted that the initiator identifier is an arbitrary identifier used to indicate the initiator of a call to a service. For example, when an application calls a service, the initiator identifier can be the application's package name, the application's unique identifier, the PID of the process calling the service within the application, or the thread identifier (TID) of the thread calling the service within the application. As another example, when a service calls a service, the initiator identifier can be the service's name, or the PID of the process calling the service within the service, the TID of the thread, etc.
[0192] In some embodiments, based on the association between the initiator identifier and the SID, the scheduling management service can also destroy all or part of the sessions corresponding to the SIDs corresponding to a certain initiator identifier when the initiator (process, thread, application, service, etc.) corresponding to a certain initiator identifier stops running.
[0193] In some embodiments, when the running state of an application changes and / or the device state of an electronic device changes, the scheduling management service can determine the QoS level of the session corresponding to the application based on the running state of the application (or the running state of the application and the device state of the electronic device), and obtain one or more SIDs associated with the application, its process, or its thread. The scheduling management service can then send the one or more SIDs and the determined QoS level to the CPU scheduler, the AI service management service in the AI subsystem, and the AI task executor.
[0194] For example, refer to Figure 3B In step ⑤, the scheduling management service can determine the initial QoS level based on the running status of the call application and / or the device status of the electronic device, and determine the session identifier SID1 of the session S1 associated with PID1 based on the process identifier (PID1) of the call process in the call application. Then, the initial QoS level and SID1 are sent to the CPU scheduler, the AI service management service in the AI subsystem, and the AI task executor.
[0195] For example, refer to Figure 3B In ⑦ and ⑧, the scheduling management service can determine the current QoS level when it detects changes in the running status of the call application and / or the device status of the electronic device, and determine the session identifier SID1 of the session S1 associated with PID1 based on the process identifier (PID1) of the call process in the call application. Then, it sends the current QoS level and SID1 to the CPU scheduler, the AI service management service in the AI subsystem, and the AI task executor.
[0196] For example, in Figure 3BIf the initiator identifier of session S0 (session identifier SID0) is also PID1, or the packet name of the call application, the scheduling management service can send the initial QoS level and SID0 to the CPU scheduler, the AI service management service in the AI subsystem, and the AI task executor after determining the initial QoS level, or send the current QoS level and SID0 to the CPU scheduler, the AI service management service in the AI subsystem, and the AI task executor after determining the current QoS level. The AI assistant may include one or more AI kits (e.g., a Chinese-English translation AI kit) to provide applications / services / modules in electronic devices with the ability to invoke AI services. The AI kit can provide an interface to the application to allow the application to invoke the AI kit to execute relevant AI services, establish AI tasks corresponding to AI services based on the application's invocation, send the AI tasks to the AI subsystem and obtain the execution results of the AI tasks from the AI subsystem, and send the execution results of the AI tasks to the application.
[0197] In some embodiments, the AI kit can respond to an application call by establishing a session corresponding to the business being handled by the scheduling management service, obtaining the SID of the established session, establishing the association between the SID and the corresponding task of the business, and sending it to the AI subsystem (e.g., sending the AI task corresponding to the business and the SID of the established session together to the AI subsystem). The AI kit can also destroy the session corresponding to the business after the business execution is completed.
[0198] For example, refer to Figure 3B In section ①, the Chinese-English translation AI kit can respond to the call application's call, establish a corresponding Chinese-English translation service session S1 through the scheduling management service, and obtain the session identifier SID1 of session S1.
[0199] For example, refer to Figure 3B In step ②, after obtaining the session identifier SID1 of session S1, the Chinese-English translation AI kit can call the AI business management service to create the corresponding Chinese-English translation business task 01 and configure the session identifier SID1 for task 01.
[0200] For example, refer to Figure 3B In section ⑥, the Chinese-English translation AI kit can destroy session S1 after the Chinese-English translation service is completed.
[0201] The AI subsystem may include AI business management services and NPU interfaces.
[0202] The AI business management service is used to receive AI tasks and their corresponding SIDs from the AI kit in the AI assistant, work with the CPU scheduler to establish the association between the SID and the thread associated with the AI task in the AI business management service, send the AI task and its corresponding SID to the AI task executor through the NPU interface, obtain the execution result of the AI task from the AI task executor and send the execution result to the corresponding AI kit in the AI assistant.
[0203] For example, refer to Figure 3B In step ③, after Task 01 is established, the AI Business Management Service can determine one or more threads associated with Task 01 (e.g., the Chinese-English translation execution thread, whose TID is TID1), and establish the association relationship between SID1, Task 01, and the thread (Chinese-English translation execution thread or TID1) associated with Task 01 in the AI Business Management Service. For example, the AI Business Management Service can store the association relationship between Task 01 and SID1, send the association relationship between TID1 and SID1 to the CPU scheduler, and send the association relationship between Task 01 and SID1 to the AI task executor, etc.
[0204] The AI service management service can also be used to convert the QoS levels sent by the scheduling management service into task priorities defined by the NPU (hereinafter referred to as NPU task priorities), such as task priorities P1' to task priorities P4' shown in the task priorities of the second processor in Table 5, and distribute AI tasks to the AI task executor based on the converted NPU task priorities. Alternatively, the AI service management service can also be used to convert the QoS levels sent by the scheduling management service into distribution priorities (such as distribution priorities DP1 to distribution priorities DP5 shown in Table 5), and distribute AI tasks to the AI task executor based on the converted distribution priorities.
[0205] For example, refer to Figure 3B In step ⑤, after receiving the initial QoS level and SID1, the AI business management service can convert the initial QoS level into an NPU task priority (or distribution priority), and distribute the task 01 corresponding to SID1 to the AI task executor based on the converted NPU task priority (or distribution priority).
[0206] For example, refer to Figure 3C In step 9, after receiving the current QoS level and SID1, the AI business management service can convert the current QoS level into an NPU task priority (or distribution priority), and distribute the task 01 corresponding to SID1 to the AI task executor based on the converted NPU task priority (or distribution priority).
[0207] The NPU interface is used to enable communication between the AI business management service and the AI task executor.
[0208] The AI task executor is used to invoke the NPU to execute AI tasks based on the NPU task priority and the NPU operating frequency of the kernel running the AI task, and then sends the execution result of the AI task to the AI service management service through the NPU interface. For example, the AI task executor can convert the QoS level sent by the scheduling management service into an NPU task priority and an NPU operating frequency. Then, the AI task executor can schedule AI tasks based on the converted NPU task priority; and / or, the AI task executor can configure the operating frequency of the kernel used to execute different AI tasks based on the converted NPU operating frequency.
[0209] For example, refer to Figure 3B In section ④, after receiving Task 01, the AI task executor can run one or more threads associated with Task 01 (e.g., a data transmission thread, with session identifier TID2 for the data transmission thread), and establish the association between SID1, Task 01, and the data transmission thread (or TID2). For example, the AI task executor can store the association between Task 01 and SID1, and send the association between TID2 and SID1 to the CPU scheduler, etc.
[0210] For example, refer to Figure 3B In step ⑤, after receiving the initial QoS level and SID1, the AI task executor can convert the initial QoS level into an NPU task priority and an NPU operating frequency. Then, the AI task executor can schedule task 01 corresponding to SID1 based on the converted NPU task priority, and configure the operating frequency of the kernel in the NPU used to run task 01 according to the converted NPU operating frequency.
[0211] For example, refer to Figure 3C In step 9, upon receiving the current QoS level and SID1, the AI task executor can convert the current QoS level into an NPU task priority and an NPU operating frequency. Then, the AI task executor can schedule task 01 corresponding to SID1 based on the converted NPU task priority, and configure the operating frequency of the kernel in the NPU used to run task 01 according to the converted NPU operating frequency.
[0212] The CPU scheduler is used to schedule the priorities of threads and processes running on the CPU, as well as to configure the operating frequency of the CPU cores.
[0213] In some embodiments, the CPU scheduler can establish an association between the threads associated with AI tasks and their corresponding SIDs in the AI business management service by interacting with the AI business management service, or it can establish an association between the threads associated with AI tasks (e.g., data transmission threads) in the AI task executor and their corresponding SIDs by interacting with the AI task executor.
[0214] For example, refer to Figure 3B In step ③, the CPU scheduler can receive the thread identifier (e.g., TID1) and SID1 of the Chinese-English translation execution thread sent by the AI business management service, and establish the association between SID1 and TID1.
[0215] For example, refer to Figure 3B In section ④, the CPU scheduler can receive the thread identifier (e.g., TID2) and SID1 of the data transmission thread sent by the AI task executor, and establish the association between SID1 and TID2.
[0216] In some embodiments, the CPU scheduler can also adjust the task priority of the thread corresponding to the SID and / or configure the operating frequency of the kernel used to run the thread corresponding to the SID based on the QoS level and SID sent by the scheduling management service. For example, after receiving the QoS level, the CPU scheduler can obtain the CPU task priority (the priority of the thread and process defined by the CPU, such as task priorities P1 to P5 shown in the task priorities of the first processor in Table 2) and the CPU operating frequency corresponding to the QoS level based on Tables 4 and 5; then, the CPU scheduler can schedule the thread corresponding to the SID based on the obtained CPU task priority and configure the operating frequency of the kernel running the thread corresponding to the SID to the obtained CPU operating frequency.
[0217] For example, refer to Figure 3B In step ⑤, after receiving the initial QoS level and SID1, the CPU scheduler can convert the initial QoS level into CPU task priorities and CPU operating frequencies. Then, the CPU scheduler can schedule the Chinese-English translation execution thread and data transmission thread corresponding to SID1 based on the converted CPU task priorities, and configure the operating frequency of the CPU kernel used to run the Chinese-English translation execution thread and data transmission thread according to the converted CPU operating frequency.
[0218] For example, refer to Figure 3CIn step 9, upon receiving the current QoS level and SID1, the CPU scheduler can convert the current QoS level into CPU task priorities and CPU operating frequencies. Then, the CPU scheduler can schedule the Chinese-English translation execution thread and data transmission thread corresponding to SID1 based on the converted CPU task priorities, and configure the operating frequency of the CPU kernel used to run the Chinese-English translation execution thread and data transmission thread based on the converted CPU operating frequency.
[0219] The following is combined with Figures 3A to 3C The content shown describes the interactive process of electronic devices performing Chinese-English translation services.
[0220] For example, Figure 4A According to some embodiments of this application, a schematic diagram of the interactive process of an electronic device performing Chinese-English translation services is shown. Figure 4A As shown, the process includes:
[0221] S401, the Chinese-English translation AI kit calls the scheduling management service to establish a session S1.
[0222] The Chinese-English translation AI kit can respond to requests from call applications to invoke Chinese-English translation services through the call process, call the scheduling management service to establish session S1 and obtain the SID1 corresponding to session S1.
[0223] In some embodiments, the Chinese-English translation AI kit can send a request to the scheduling management service to establish a session in response to a request from a call application to invoke the Chinese-English translation service through the call process. The scheduling management service can respond to the session establishment request by establishing session S1, determining a globally unique session identifier SID1 for session S1, and sending SID1 to the Chinese-English translation AI kit. Due to the global uniqueness of the SID, it can be ensured that each SID corresponds to only one session (equivalent to corresponding to one service), avoiding inaccurate scheduling due to different sessions using the same SID.
[0224] In some embodiments, the SID1 generated by the scheduling management service can be random or generated based on preset logic or algorithm.
[0225] In some embodiments, the SID1 generated by the scheduling management service can indicate the initiator. For example, part of the SID1 may include the packet name of the call application, the PID of the call process, the packet name encoding obtained by encoding the packet name of the call application, the PID encoding obtained by encoding the PID of the call process, etc., while another part may be randomly generated or generated based on preset logic or algorithm.
[0226] In some embodiments, the scheduling management service can also establish an association between SID1 and the process identifier PID1 of the communication process.
[0227] S402, The scheduling management service determines the initial QoS level based on the initial operating state and / or the initial device state.
[0228] After session S1 is established, the scheduling management service can obtain the initial operating state of the call application and / or the initial device state of the electronic device, and determine the initial QoS level based on the initial operating state and / or the initial device state.
[0229] For example, the scheduling management service can determine the initial QoS level corresponding to the initial operating state and / or initial device state based on any one of Tables 4 and 5, or based on the correlation between other device states, operating states, and QoS levels. For example, taking Table 5 as an example, when the call application's operating state is S1 and the device state level is DS1, the scheduling management service can determine the initial QoS level as L1; when the call application's operating state is S3 and the device state level is DS2, the scheduling management service can determine the initial QoS level as L7.
[0230] S403, the Chinese-English translation AI kit uses SID1 to call the AI task management service to create task 01.
[0231] After receiving SID1, the Chinese-English translation AI kit can call the AI task management service to create task 01 based on SID1.
[0232] For example, the Chinese-English translation AI kit can send a request to the AI task management service to create an AI task (which may include SID1) based on the API provided by the AI task management service. The AI task management service can respond to the request to create an AI task by creating task 01 and storing the association between the created task 01 and SID1.
[0233] S404, the AI task management service sends the association between the Chinese-English translation execution thread and SID1 to the CPU scheduler.
[0234] After creating Task 01, the AI Task Management Service can determine the execution thread for the Chinese-English translation (e.g., by creating a new Chinese-English translation execution thread or configuring an existing thread as a Chinese-English translation execution thread) and send the thread identifiers TID1 and SID1 of the Chinese-English translation execution thread to the CPU scheduler. Correspondingly, after receiving TID1 and SID1, the CPU scheduler can store the association between TID1 and SID1 (equivalent to the association between the Chinese-English translation execution thread and SID1).
[0235] The S405 CPU scheduler schedules the execution thread for Chinese-English translation based on SID1 and the initial QoS level.
[0236] After receiving the association between the Chinese-English translation execution thread and SID1, the CPU scheduler can obtain the initial QoS level from the scheduling management service and schedule the Chinese-English translation execution thread based on SID1 and the initial QoS level.
[0237] For example, with an initial QoS level of L1, the CPU scheduler can determine the CPU task priority as P1 based on Table 5 and configure the CPU task priority of the Chinese-English translation execution thread as P1; and determine the CPU operating frequency level as the highest frequency based on Table 5 and configure the operating frequency of the CPU kernel used to run the Chinese-English translation execution thread as the operating frequency corresponding to the "highest frequency" of the operating frequency level.
[0238] For example, with an initial QoS level of L7, the CPU scheduler can determine the CPU task priority as P3 based on Table 5 and configure the CPU task priority of the Chinese-English translation execution thread as P3; and determine the CPU operating frequency level as the lowest frequency based on Table 5 and configure the operating frequency of the CPU core used to run the Chinese-English translation execution thread as the operating frequency corresponding to the "lowest frequency" of the operating frequency level.
[0239] It should be noted that the initial QoS level can be sent to the CPU scheduler by the scheduling management service after executing S402, or it can be obtained by the CPU scheduler from the scheduling management service based on SID1 after receiving the association between the Chinese-English translation execution thread and SID1. This is not limited here. For example, after receiving the association between the Chinese-English translation execution thread and SID1, the CPU scheduler can send a query request to the scheduling management service to obtain the QoS level corresponding to SID1; after receiving the query request, the scheduling management service can send the initial QoS level to the CPU scheduler.
[0240] S406, the AI task management service sends task 01 and SID1 to the AI task executor based on the initial QoS level.
[0241] After creating Task 01, the AI Task Management Service can obtain the initial QoS level from the Scheduling Management Service and send Task 01 and SID1 to the AI Task Executor based on the initial QoS level.
[0242] For example, with an initial QoS level of L1, the AI task management service can determine the NPU task priority as P1' based on Table 5, configure the NPU task priority of task 01 as P1', and distribute task 01 to the AI task executor earlier than other tasks with NPU task priorities of P2', P3', and P4'. Alternatively, the AI task management service can determine the distribution priority as DP1 based on Table 6, configure the distribution priority of task 01 as DP1, and distribute task 01 to the AI task executor earlier than other tasks with distribution priorities of DP2, DP3, and DP4.
[0243] For example, with an initial QoS level of L7, the AI task management service can determine the NPU task priority as P3' based on Table 5, configure the NPU task priority of task 01 as P3', and distribute task 01 to the AI task executor earlier than other tasks with NPU task priority of P4' and later than other tasks with NPU task priority of P2' or P3'. Alternatively, the AI task management service can determine the distribution priority as DP3 based on Table 6, configure the distribution priority of task 01 as DP3, and distribute task 01 to the AI task executor earlier than other tasks with distribution priority of DP4 and later than other tasks with distribution priority of DP3 or DP4.
[0244] It should be noted that the execution order of S406, S404, and S405 can be interchanged or executed in parallel, and no restriction is made here.
[0245] It should be noted that the initial QoS level can be sent to the AI task management service by the scheduling management service after executing S402, or it can be obtained by the AI task management service from the scheduling management service based on SID1 after task 01 is established; there is no limitation here. For example, after task 01 is established, the AI task management service can send a query request to the scheduling management service to obtain the QoS level corresponding to SID1; after receiving the query request, the scheduling management service can send the initial QoS level to the AI task management service.
[0246] S407, the AI task executor sends the association between the data transmission thread and SID1 to the CPU scheduler.
[0247] After receiving Task 01 and SID1, the AI task executor can determine the data transmission thread (e.g., by creating a new data transmission thread or configuring an existing thread as a data transmission thread). Then, the AI task executor can send the association between the data transmission thread and SID1 to the CPU scheduler. For example, the AI task executor can send the thread identifiers TID2 and SID1 of the data transmission thread to the CPU scheduler. After receiving TID2 and SID1, the CPU scheduler can store the association between TID2 and SID1 (equivalent to the association between the data transmission thread and SID1).
[0248] In some embodiments, after receiving Task 01 and SID1, the AI task executor can store the association between Task 01 and SID1.
[0249] In some embodiments, task 01 can be divided into multiple subtasks, and the task executor can associate SID1 with these multiple subtasks.
[0250] S408, the AI task executor calls the NPU to execute task 01 based on SID1 and the initial QoS level.
[0251] Upon receiving Task 01, the AI Task Executor can obtain the initial QoS level from the scheduling management service and call the NPU to execute Task 01 based on SID1 and the initial QoS level.
[0252] For example, with an initial QoS level of L1, the AI task executor can determine the NPU task priority as P1' based on Table 5 and configure the NPU task priority of task 01 as P1', and call the NPU to execute task 01 earlier than other tasks with NPU task priorities of P2', P3', and P4'; and determine the NPU operating frequency level as the highest frequency based on Table 5, and reduce the operating frequency of the kernel in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "highest frequency".
[0253] For example, with an initial QoS level of L7, the AI task executor can determine the NPU task priority as P3' based on Table 5 and configure the NPU task priority of task 01 as P3', and call the NPU to execute task 01 earlier than other tasks with an NPU task priority of P4'; and determine the NPU operating frequency level as the lowest frequency based on Table 5, and reduce the operating frequency of the kernel in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "lowest frequency".
[0254] It should be noted that the initial QoS level can be sent to the AI task executor by the scheduling management service after executing S402, or it can be obtained by the AI task executor from the scheduling management service based on SID1 after receiving task 01; there is no limitation here. For example, after receiving task 01, the AI task executor can send a query request to the scheduling management service to obtain the QoS level corresponding to SID1; after receiving the query request, the scheduling management service can send the initial QoS level to the AI task executor.
[0255] S409, the CPU scheduler schedules data transmission threads based on SID1 and the initial QoS level.
[0256] After receiving the association between the data transmission thread and SID1, the CPU scheduler can schedule the data transmission thread and the Chinese-English translation execution thread based on SID1 and the initial QoS level.
[0257] For example, with an initial QoS level of L1, the CPU scheduler can determine the CPU task priority as P1 based on Table 5 and configure the CPU task priority of the data transfer thread as P1; and determine the CPU operating frequency level as the highest frequency based on Table 5 and configure the operating frequency of the CPU kernel used to run the data transfer thread as the operating frequency corresponding to the operating frequency level "highest frequency".
[0258] For example, with an initial QoS level of L7, the CPU scheduler can determine the CPU task priority as P3 based on Table 5 and configure the CPU task priority of the data transfer thread as P3; and determine the CPU operating frequency level as the lowest frequency based on Table 5 and configure the operating frequency of the CPU core used to run the data transfer thread as the operating frequency corresponding to the "lowest frequency" of the operating frequency level.
[0259] It should be noted that S409 can be executed before S408 or in parallel with S408; no restrictions are imposed here.
[0260] It should be noted that after session S1, task 01, the data transmission thread, and the Chinese-English translation execution thread are established, the electronic device can implement the Chinese-English translation service based on session S1, task 01, the data transmission thread, and the Chinese-English translation execution thread. During the implementation of the Chinese-English translation service, the electronic device can schedule task 01, the data transmission thread, and the Chinese-English translation execution thread based on the device's state and the call application's running state. For example, when the electronic device's state is the initial device state and the call application's running state is the initial running state, the electronic device can implement the Chinese-English translation service by repeatedly executing the following steps S410 to S412C.
[0261] It should be noted that the initial QoS level can be sent to the CPU scheduler by the scheduling management service after S402 is executed, or it can be obtained by the CPU scheduler in S405, or it can be obtained from the scheduling management service after receiving the association between the data transmission thread and SID1. There are no restrictions here.
[0262] S410, the Chinese-English translation AI kit sends input data and SID1 to the AI task management service.
[0263] After obtaining the input data transmitted by the call application (such as user A's Chinese voice and user B's English voice), the Chinese-English translation AI kit can send the input data and SID1 to the AI task management service.
[0264] For example, whenever an electronic device captures a segment of Chinese speech from user A, the calling application can send that segment to the Chinese-English translation AI kit. The Chinese-English translation AI kit can then send the Chinese speech segment from user A, sent by the calling application, to an AI task management service.
[0265] For example, whenever an electronic device receives a segment of English voice from user B, the calling application can send this segment of English voice to the Chinese-English translation AI kit. The Chinese-English translation AI kit can then send this voice segment and SID1 from the calling application to the AI task management service.
[0266] S411, AI Task Management Service and Chinese-English Translation AI Kit Verification SID1.
[0267] After receiving input data and SID1, the AI task management service can verify SID1. For example, it can verify whether SID1 is the session identifier of the session corresponding to the application that provided the input data.
[0268] It should be noted that S411 is optional. That is, after receiving the input data and SID1, the AI task management service can directly execute S412A without verifying SID1.
[0269] S412A, AI task management service distributes task 01 based on SID1 and initial QoS level.
[0270] After receiving the input data and SID1 (e.g., after SID1 verification passes D), the AI task management service can distribute task 01 based on SID1 and the initial QoS level. For details, please refer to S406, which will not be elaborated upon here.
[0271] The S412B AI task executor invokes the NPU to execute task 01 based on SID1 and the initial QoS level.
[0272] After receiving Task 01 distributed by the AI Task Management Service, the AI Task Executor can invoke the NPU to execute Task 01 based on SID1 and the initial QoS level. For details, please refer to S408, which will not be elaborated upon here.
[0273] The S412C CPU scheduler schedules data transmission threads and Chinese-English translation execution threads based on SID1 and the initial QoS level.
[0274] If the CPU scheduler does not receive a QoS level that corresponds to SID1 and is different from the initial QoS level, it can schedule the data transmission thread and the Chinese-English translation execution thread based on SID1 and the initial QoS level. For details, please refer to S405 and S409, which will not be elaborated here.
[0275] In some embodiments, the electronic device may destroy session S1 upon the end of the call (e.g., user A hangs up the call or user B hangs up the call) or upon completion of task 01 (e.g., user A stops the Chinese-English translation function). For example, the electronic device may destroy session S1 based on the following S413 and / or S413'.
[0276] S413, the Chinese-English translation AI kit responds to the end of the call / completion of task 01 and destroys session S1.
[0277] In some embodiments, the Chinese-English translation AI kit destroys session S1 in response to the end of the call / completion of task 01.
[0278] S413', the dispatch management service responds to the call process stopping by destroying session S1.
[0279] In some embodiments, when a call process stops running, the scheduling management service can determine the SID1 associated with the call process based on the call process's process identifier PID1. Then, the scheduling management service can destroy session S1 if the session S1 corresponding to SID1 has not been destroyed. This avoids resource waste caused by the Chinese-English translation AI kit failing to destroy session S1 due to an error.
[0280] based on Figure 4A The method shown allows electronic devices to schedule task 01, data transmission thread, and Chinese-English translation execution thread to implement Chinese-English translation services based on the electronic device's operating status and the initial QoS level corresponding to the initial operating status of the call application. This can prevent electronic devices from failing to respond to Chinese-English translation services in a timely manner or wasting resources.
[0281] In some embodiments, during the implementation of the Chinese-English translation service, the electronic device can also dynamically determine the current QoS level corresponding to session S1 based on changes in the device status of the electronic device and / or changes in the call application, and schedule task 01, data transmission thread and Chinese-English translation execution thread based on the current QoS level.
[0282] For example, Figure 4B According to some embodiments of this application, a schematic diagram of the interaction process in which another electronic device performs Chinese-English translation services is shown.
[0283] like Figure 4B As shown, the process includes S401 to S409 and S415 to S419. S401 to S409 can be referenced. Figure 4A The contents of S401 to S409 will not be repeated here. The following section introduces... Figure 4A The embodiments shown differ in S414 to S416C:
[0284] S414, The dispatch management service detects changes in device status and / or changes in the operational status of the call application, and determines the current QoS level.
[0285] The scheduling management service can periodically or non-periodically obtain the current device status of electronic devices and / or the current operating status of call applications. When the scheduling management service detects a change in device status and / or a change in the operating status of call applications, it can determine the current QoS level corresponding to the current operating status and / or the current device status based on any one of Table 4 or Table 5, or based on other correlations between device status, operating status and QoS level.
[0286] After session S1 is established, the scheduling management service can obtain the current operating status of the call application and / or the current device status of the electronic device, and determine the current QoS level based on the current operating status and / or the current device status. For example, the scheduling management service can determine the current QoS level corresponding to the current operating status and / or the current device status based on Table 4 or Table 5, or based on the correlation between other device statuses, operating statuses and QoS levels.
[0287] For example, taking Table 5 as an example, when the initial running state is S1 and the initial device state level is DS1, the scheduling management service can determine the current QoS level as L2 when the current running state of the call application is S2 (e.g., the call application is switched to background operation and is perceptible to the user) and the current device state is DS1.
[0288] For example, taking Table 5 as an example, when the initial running state is S1 and the initial device state level is DS1, the scheduling management service can determine the current QoS level as L5 when the current running state of the call application is S1 (e.g., the call application is running in the foreground and is the focus) and the current device state is DS2.
[0289] S415, the scheduling management service sends SID1 and the current QoS level to the AI task management service, the AI task executor, and the CPU scheduler.
[0290] After determining the current QoS level, the scheduling management service can send SID1 and the current QoS level to the AI task management service, the AI task executor, and the CPU scheduler.
[0291] S416A, AI task management service distributes task 01 based on SID1 and the current QoS level.
[0292] Upon receiving the current QoS level, the AI task management service can distribute task 01 based on SID1 and the current QoS level.
[0293] For example, with an initial QoS level of L1 and a current QoS level of L2, the AI task management service can determine the NPU task priority as P2' based on Table 5, configure the NPU task priority of task 01 as P2', and distribute task 01 to the AI task executor earlier than other tasks with NPU task priorities of P3' and P4'. Alternatively, the AI task management service can also determine the distribution priority corresponding to QoS level L2 as DP2 based on Table 6, configure the distribution priority of task 01 as DP2, and distribute task 01 to the AI task executor earlier than other tasks with distribution priorities of DP3 and DP4.
[0294] For example, with an initial QoS level of L1 and a current QoS level of L5, the AI task management service can determine the NPU task priority as P1' based on Table 5, maintain the NPU task priority configuration of task 01 as P1', and distribute task 01 to the AI task executor earlier than other tasks with NPU task priorities of P2', P3, and P4'. Alternatively, the AI task management service can also determine the distribution priority corresponding to QoS level L5 as L2 as DP1 based on Table 6, maintain the distribution priority of task 01 as DP1, and distribute task 01 to the AI task executor earlier than other tasks with distribution priorities of DP2, DP3, and DP4.
[0295] The S416B AI task executor invokes the NPU to execute task 01 based on SID1 and the current QoS level.
[0296] Upon receiving the current QoS level, the AI task executor can invoke the NPU to execute task 01 based on SID1 and the current QoS level.
[0297] For example, with an initial QoS level of L1 and a current QoS level of L2, the AI task management service can determine the NPU task priority as P2' based on Table 5 and configure the NPU task priority of task 01 as P2', and call the NPU to execute task 01 earlier than other tasks with NPU task priorities of P3' and P4'; and determine the NPU operating frequency level as high frequency based on Table 5, and reduce the operating frequency of the kernel in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "high frequency".
[0298] For example, with an initial QoS level of L1 and a current QoS level of L5, the AI task executor can determine the NPU task priority as P1' based on Table 5 and keep the NPU task priority configuration of task 01 as P1', and call the NPU to execute task 01 earlier than other tasks with NPU task priorities of P2', P3', and P4'; and determine the NPU operating frequency level as medium frequency based on Table 5, and reduce the operating frequency of the kernel in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "medium frequency".
[0299] The S416C CPU scheduler schedules data transmission threads and Chinese-English translation execution threads based on SID1 and the current QoS level.
[0300] Upon receiving the current QoS level, the CPU scheduler schedules the data transmission thread and the Chinese-English translation execution thread based on SID1 and the current QoS level.
[0301] For example, with an initial QoS level of L1 and a current QoS level of L2, the CPU scheduler can determine the CPU task priority as P2 based on Table 5 and reduce the CPU task priority of the data transfer thread and the Chinese-English translation execution thread to P2; and determine the CPU operating frequency level as high frequency based on Table 5 and reduce the operating frequency of the CPU core used to run the data transfer thread and the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "high frequency".
[0302] For example, with an initial QoS level of L1 and a current QoS level of L5, the CPU scheduler can determine the CPU task priority as P1 based on Table 5 and maintain the CPU task priority configuration of the data transfer thread and the Chinese-English translation execution thread as P1; and determine the CPU operating frequency level as medium frequency based on Table 5, and reduce the operating frequency of the CPU core used to run the data transfer thread and the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "medium frequency".
[0303] based on Figure 4A and Figure 4B In the illustrated embodiment, the electronic device can dynamically configure the task priority of threads in the CPU, the operating frequency of the CPU core, the task priority of tasks in the NPU, and the operating frequency of the NPU core, based on the device state and the running state of the applications within the electronic device. This avoids service execution delays or wasted resources due to mismatches in task priorities and / or core frequencies between the CPU and NPU for the same service.
[0304] Below, we introduce a task scheduling method for electronic devices.
[0305] For example, Figure 5 According to some embodiments of this application, a flowchart of a task scheduling method is shown. The execution subject of this method is an electronic device, such as... Figure 5 As shown, the method includes:
[0306] S501, the first application is run by the first processor of the electronic device, and the running state of the first application is the first running state.
[0307] For example, the first processor can be the CPU of an electronic device, which can run the first application.
[0308] In some embodiments, the running state of the first application may include at least two running states from state ST1 to state ST6, wherein the first running state can be any one of the multiple running states. For example, the running state of the first application may include states ST1 to ST4, or states ST5 and ST6, or states ST5, ST3, and ST4, or states ST1, ST2, and ST6, etc.
[0309] S502, a request from the first application to call the first service is detected, and the first task included in the first service is executed by the second processor of the electronic device, wherein the first task has a first priority on the second processor, and the operating frequency of at least one core in the second processor used to run the first task is a first operating frequency.
[0310] When an electronic device detects a request from a first application to invoke a first service, it can execute a first task corresponding to the first service through a second processor of the electronic device. The first service may be a service in which at least some tasks (e.g., the first task itself) are executed by the second processor.
[0311] It should be noted that the first processor and the second processor can be any processor, including but not limited to CPU, NPU, GPU, image signal processor (ISP), microcontroller unit (MCU), digital signal processor (DSP), field programmable gate array (FPGA), application-specific integrated circuit (ASIC) (such as input / output controller, power management chip, memory controller, security chip, display driver chip, and other processors used to implement specific functions or process specific tasks), etc. This application does not limit the specific form of the first processor and the second processor.
[0312] It should be noted that the first processor and the second processor can be independent devices or integrated into the same device (e.g., integrated into a system on chip (SoC)). The embodiments of this application do not limit the packaging form of the first processor and the second processor.
[0313] In some embodiments, when the second processor is an NPU, the first service can be any service that requires AI inference or AI training based on an AI model via the NPU; when the second processor is a GPU, the first service can be any service that requires graphics processing or AI inference / training via the GPU (e.g., text call service, Chinese-English translation service, AI call answering service, fraud detection service, other services that call the NPU for image processing / audio processing / text processing, etc.); when the second processor is an ISP, the first service can be any service that requires image signal processing by the ISP; when the second processor is a security chip, the first service can be a security verification task; when the second processor is an input / output controller, the first service can be a data access service; when the second processor is a display driver chip, the first service can be a service that refreshes image data to the display screen. This application does not limit the specific form of the first service. The AI model can be any model that needs to be run via the NPU, including but not limited to neural network models, deep learning models, large models, etc.
[0314] In some embodiments, while the second processor is executing the first task corresponding to the first service, the first processor may also run a second task related to the first service. The electronic device may also configure the CPU task priority of the second task to a third priority matching the first operating state based on the first operating state, and / or configure the operating frequency of one or more cores in the first processor used to run the second task to a third operating frequency, and / or the first processor may distribute the first task to the second processor based on the third priority (for example, an AI service management service may distribute the task to an AI executor based on the CPU task priority corresponding to the initial QoS level). For example, for Figures 3A to 4B In the embodiment shown, the first service can be a Chinese-English translation service, the first task corresponding to the Chinese-English translation service can be task 10, the second task can include a Chinese-English translation execution thread and a data transmission thread, and the first processor can be the CPU of an electronic device.
[0315] In some embodiments, when an electronic device detects a request from a first application to invoke a first service, it may establish a first association between the first application and a first task of the first service; or when there is a second task of the first service running by a first processor, it may establish a second association between the first application, the first task, and the second task.
[0316] In some embodiments, the electronic device may determine an initial QoS level based on a first operating state of the first application (and / or a device state of the electronic device). Then, the electronic device may determine a first task associated with the first application based on a first association, and configure the task priority of the first task to a first priority matching the initial QoS level based on the initial QoS level, and / or configure the operating frequency of at least one core in the second processor used to run the first task to a first operating frequency matching the initial QoS level. Alternatively, the electronic device may determine a first task and a second task associated with the first application based on a second association, and configure the task priority of the first task to a first priority matching the initial QoS level, configure the priority of the second task to a third priority matching the initial QoS level based on the initial QoS level, and / or configure the operating frequency of at least one core in the second processor used to run the first task to a first operating frequency matching the initial QoS level, and configure the operating frequency of at least one core in the first processor used to run the second task to a third operating frequency matching the initial QoS level. See details for further information. Figure 3B The contents of S402 to S409 and S412A to S412C are not elaborated here.
[0317] It should be noted that electronic devices can determine the first operating frequency, the third operating frequency, the first priority, and the third priority based on the initial QoS level, as well as the correlation between the QoS level and the operating frequency, and the correlation between the QoS level and the priority (such as the correlation shown in Tables 4 and 5).
[0318] It should be noted that electronic devices can determine the first priority corresponding to the first operating state based on the correlation between operating state and distribution priority, or the correlation between operating state, device status level and distribution priority, or the correlation between QoS level and distribution priority (such as the correlation shown in Table 6).
[0319] In some embodiments, the first association and the second association may be established based on a session.
[0320] For example, an electronic device can establish a first session with a first session identifier in response to a first application calling a first service. Based on this, the first association may include the association between the first session identifier and the first application (e.g., the first application's package name, process PID, thread TID (as the initiator identifier), etc.) and the association between the first session identifier and the first task.
[0321] For example, an electronic device can respond to a first application calling a first service by establishing a second session with a second session identifier. Based on this, the second association can include the association between the second session identifier and the first application (e.g., the package name, process PID, thread TID (as the initiator identifier) of the first application), the association between the second session identifier and the second task (e.g., the TID or other identifier corresponding to the second task), and the association between the second session identifier and the first task.
[0322] For example, for Figures 3A to 4B In the scenario shown, the second association can be the association between the session identifier SID1 of session S1, the thread identifier (TID1) of the Chinese-English translation execution thread, the thread identifier (TID2) of the data transmission thread (the Chinese-English translation execution thread and the data transmission thread are the second task), and task 01 (as the first task). The method for establishing the second association can be found in [reference needed]. Figure 3B The contents of S401 to S407 will not be elaborated here.
[0323] In some embodiments, the initial QoS level can be determined based on the initial device state of the first electronic device, the first operating state of the first application, and the correlation between the device state, the operating state of the application, and the QoS level (e.g., the correlation shown in Table 4 or Table 5). For details, please refer to S402, which will not be elaborated upon here.
[0324] In some embodiments, the priority of the first task on the second processor can be a task priority. For example, the priority of the first task on the second processor can include the priority at which the driver or management service (e.g., an AI task executor) of the second processor directly passes the first task to the second processor, or it can include the priority at which the second processor actually executes the first task.
[0325] In some embodiments, the first task is sent by a first functional unit (e.g., an AI business management service) running on a first processor of an electronic device to a second functional unit (e.g., an AI task executor), and then distributed by the second functional unit to a second processor. When the first application is in a first running state, the first functional unit may distribute the first task to the second functional unit based on a first distribution priority corresponding to the first running state. For details, please refer to S406, which will not be elaborated upon here.
[0326] It should be noted that electronic devices can determine the first and third priorities based on the correlation between operating status and task priority (such as the correlation shown in Table 1), or based on the correlation between operating status, device status level and task priority (such as the correlation shown in Table 3).
[0327] It should be noted that electronic devices can determine the first and third operating frequencies based on the correlation between operating status and kernel operating frequency (such as the correlation shown in Table 2), or determine the first and third priorities based on the correlation between operating status, device status level and kernel operating frequency (such as the correlation shown in Table 3).
[0328] S503, the running state of the first application is detected to have changed from the first running state to the second running state, and the first service is scheduled. The scheduling process includes: adjusting the priority of the first task on the second processor from the first priority to the second priority, and / or adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency.
[0329] After detecting that the running state of the first application has switched from the first running state to the second running state, the electronic device can schedule and process the first service based on the second running state. For example, the electronic device can adjust the priority of the first task on the second processor from the first priority to the second priority that matches the second running state, and / or adjust the operating frequency of at least one core from the first operating frequency to the second operating frequency that matches the second running state.
[0330] In some embodiments, the electronic device may detect that the running state of the first application has changed from the first running state to the second running state when it detects a first operation in which the user switches the running state of the first application from the first running state to the second running state.
[0331] It should be noted that the first operation can be any operation capable of switching the running state of the first application. The first operation can be applied to the window of the first application or the window of other applications, or it can be an air gesture, voice operation, etc. For example, when the first operation is the user clicking on the window of the first application, the second running state can be state ST1; when the first operation is the user clicking on other areas outside the window of the first application on the display interface of the electronic device, the second running state can be state ST3; when the first operation is the user switching the first application from the foreground to the background and the user is unaware of the first application, the second running state can be state ST4; when the first operation is the user switching the first application from the foreground to the background and the user is unaware of the first application, the second running state can be state ST2.
[0332] In some embodiments, where a second task of the first service is also running in the first processor, the scheduling process may further include: adjusting the priority of the second task on the first processor from a third priority to a fourth priority that matches the second running state, wherein the relationship between the third and fourth priorities is the same as the relationship between the first and second priorities; and / or adjusting the operating frequency of one or more cores from a third operating frequency to a fourth operating frequency that matches the second running state, wherein the relationship between the third and fourth operating frequencies is the same as the relationship between the first and second operating frequencies.
[0333] In some embodiments, the second priority is lower than the first priority and / or the second operating frequency is lower than the first operating frequency in the following situations: the first operating state is foreground running and is the focus, the second operating state is foreground running and is not the focus, running in the background and is perceptible to the user, or running in the background and is not perceptible to the user; or, the first operating state is foreground running and is not the focus, the second operating state is background running and is perceptible to the user, or running in the background and is not perceptible to the user; or, the first operating state is background running and is perceptible to the user, the second operating state is background running and is not perceptible to the user; or, the first operating state is foreground running and the second operating state is background running.
[0334] In some embodiments, the second priority is higher than the first priority and / or the second operating frequency is greater than the first operating frequency in the following situations: the first running state is running in the background and is not perceived by the user, and the second running state is running in the foreground and is the focus, running in the foreground and is not the focus, or running in the background and is perceived by the user; or, the first running state is running in the background and is perceived by the user, and the second running state is running in the foreground and is the focus or running in the foreground and is not the focus; or, the first running state is running in the foreground and is not the focus, and the second running state is running in the foreground and is the focus; or, the first running state is running in the background and the second running state is running in the foreground.
[0335] In some embodiments, the electronic device may determine a second QoS level based on a second operating state of the first application (and / or a device state of the electronic device). Then, the electronic device may determine a first task associated with the first application based on a first association, and adjust the task priority of the first task from a first priority to a second priority matching the second QoS level based on the second QoS level, and / or adjust the operating frequency of at least one core in the second processor used to run the first task from a first operating frequency to a second operating frequency matching the second QoS level. For details, please refer to S414 to S416C, which will not be elaborated upon here.
[0336] In some embodiments, the electronic device may determine a second QoS level based on a second operating state of the first application (and / or a device state of the electronic device). Then, the electronic device may, based on a second association, determine a first task and a second task associated with the first application, and adjust the task priority of the first task from a first priority to a second priority matching the second QoS level, adjust the priority of the second task from a third priority to a fourth priority matching the second QoS level, and / or adjust the operating frequency of at least one core in the second processor used to run the first task from a first operating frequency to a second operating frequency matching the second QoS level, and adjust the operating frequency of one or more cores in the first processor used to run the second task from a third operating frequency to a fourth operating frequency matching the first QoS level. For details, please refer to S414 to S416C, which will not be elaborated upon here.
[0337] For example, when the second association includes the second session identifier of the second session, the first application (e.g., the package name of the first application, the PID of the process calling the first service, the TID of the thread calling the first service, etc.), the second task (e.g., the PID of the second task), and the association between the first task, the electronic device can, after determining the second QoS level, first determine the second session identifier based on the first application and the second association, and then determine the second task and a task based on the second session identifier. Then, the electronic device can determine the second operating frequency, the fourth operating frequency, the second priority, and the fourth priority based on the second QoS level, the association between the QoS level and the operating frequency (e.g., the association shown in columns 2, 4, and 6 of Table 4, or the association shown in columns 3, 5, and 7 of Table 5), and the association between the QoS level and the task priority (e.g., the association shown in columns 2, 3, and 5 of Table 4, or the association shown in columns 3, 4, and 6 of Table 5). Finally, the electronic device may configure the priority of the first task on the second processor to the second priority, configure the priority of the second task on the first processor to the fourth priority, adjust the distribution priority of the first processor to distribute the first task to the second processor to the fourth priority, and / or configure the operating frequency of at least one core in the second processor used to run the first task to the second operating frequency, and configure the operating frequency of one or more cores in the first processor used to run the second task to the fourth operating frequency.
[0338] For example, with Figures 3A to 4B Taking the scenario shown as an example, the second running state can be the current running state. After determining the current running state, the scheduling management service can obtain the second session identifier (the session identifier SID1 corresponding to session S1) based on the process identifier PID1 of the communication process. Then, the scheduling management service can send the current running state to the AI business management service, the AI task executor, and the CPU scheduler. Next, the AI business management service and the AI task executor can schedule task 01 (as the first task) based on the current running state, and the CPU scheduler can schedule the data transmission thread and the Chinese-English translation execution thread (as the second task) based on the current running state. For details, please refer to the content of S414 to S416C, which will not be elaborated here.
[0339] In some embodiments, after the first service is completed, or the first application stops running, or the process / thread in the first application that called the first service terminates, the electronic device can delete the first association and the second association, or destroy the first session and the second session. This avoids the resource consumption associated with maintaining the first and second associations. For details, please refer to S413 and S413', which will not be elaborated upon here.
[0340] It should be noted that, in some embodiments, where the first service also includes one or more tasks executed by one or more other processors, the electronic device may, while the first application is in a first running state, configure the priority of the one or more tasks on the one or more other processors to match the priority of the first running state, and / or configure the operating frequency of the kernels running the one or more tasks on the one or more processors to match the operating state of the first running state. After the first application's running state is adjusted to a second running state, the electronic device may also configure the priority of the one or more tasks on the one or more other processors to match the priority of the second running state, and / or configure the operating frequency of the kernels running the one or more tasks on the one or more processors to match the second running state. For details, please refer to the section on configuring the priority of the first task in the second processor and the operating frequency of the kernel running the first task in the second processor; these details will not be elaborated upon here.
[0341] pass Figure 5 The method shown allows an electronic device to synchronously schedule a first task corresponding to a first service on a second processor, and a second task corresponding to the first service on the first processor, based on the running state of the first application and / or the device state. This avoids delays in the first service response or resource waste caused by mismatches in task priorities or distribution priorities between the first and second tasks, and / or mismatches in the operating frequencies of the kernel executing the first task and the kernel running the second task.
[0342] The technical solution of this application will be introduced below, taking the first running state as the foreground running and the second running state as the background running as an example.
[0343] For example, Figure 6 According to some embodiments of this application, a flowchart of a task scheduling method is shown. The execution subject of this method is an electronic device, such as... Figure 6 As shown, the method includes the following steps:
[0344] S601, the first application is run by the first processor of the electronic device, and the first application is running in the foreground.
[0345] S602, a request from the first application to call the first service is detected, and the first task included in the first service is executed by the second processor of the electronic device, wherein the first task has a first priority on the second processor, and the operating frequency of at least one core in the second processor used to run the first task is a first operating frequency.
[0346] It should be noted that the specific forms of the first business, the first task, the first processor, and the second processor, as well as the methods for determining the first priority and the first operating frequency, can be referred to the content of S502 mentioned above, and will not be repeated here.
[0347] In some embodiments, the first service further includes a second task executed by the first processor, wherein when the first application is running in the foreground, the second task has a third priority on the first processor and the operating frequency of one or more cores of the first processor used to execute the second task is a third operating frequency.
[0348] In some embodiments, when the first application is running in the foreground, the electronic device distributes the first task to the second processor based on a first priority.
[0349] In some embodiments, the electronic device includes a first functional unit and a second functional unit, wherein the first functional unit is used to distribute a first task to the second functional unit, and the second functional unit is used to distribute the first task to a second processor. When the first application is running in the foreground, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. For example, in the case where the first service is the aforementioned Chinese-English translation service or other AI services, the first functional unit can be an AI service management service, and the second functional unit can be an AI task executor.
[0350] In some embodiments, the first priority, the first operating frequency, the third operating frequency, the third priority, and the first distribution priority are related to the running state of the first application, or are related to the running state of the first application and the running state of the electronic device.
[0351] For example, when the foreground is running as ST1 (or when the foreground is running as ST1 and the device status level is DS1 or DS2): based on Table 1, Table 3, Table 4, or Table 5, the priority of the first task on the second processor can be task priority P1' (first priority), and the priority of the second task on the first processor can be task priority P1 (third priority). When the foreground is running as ST3 (or when the foreground is running as ST3 and the device status level is DS1 or DS2): based on Table 1, Table 3, Table 4, or Table 5, the priority of the first task on the second processor can be task priority P3' (first priority), and the priority of the second task on the first processor can be task priority P3 (third priority).
[0352] For example, when the foreground is running in the aforementioned state ST1: based on Table 2 or Table 4, the operating frequency of at least one core running the first task in the second processor is the operating frequency corresponding to the kernel operating frequency level "highest frequency" (first operating frequency), and the operating frequency of one or more cores running the second task in the first processor is the operating frequency corresponding to the kernel operating frequency level "highest frequency" (third operating frequency). When the foreground is running in the aforementioned state ST1 and the device state level of the electronic device is the aforementioned DS1: based on Table 3 or Table 5, the operating frequency of at least one core running the first task in the second processor is the operating frequency corresponding to the kernel operating frequency level "highest frequency" (first operating frequency), and the operating frequency of one or more cores running the second task in the first processor is the operating frequency corresponding to the kernel operating frequency level "highest frequency" (third operating frequency). When the foreground is running in the aforementioned state ST1 and the device state level of the electronic device is the aforementioned DS2: based on Table 3 or Table 5, the operating frequency of at least one core running the first task in the second processor is the operating frequency corresponding to the kernel operating frequency level "medium frequency" (first operating frequency), and the operating frequency of one or more cores running the second task in the first processor is the operating frequency corresponding to the kernel operating frequency level "medium" (third operating frequency).
[0353] For example, when the foreground is running in the aforementioned state ST1: based on Table 6, the first distribution priority can be distribution priority DP1; in this case, the first functional unit can distribute the first task to the second functional unit based on distribution priority DP1. When the foreground is running in the aforementioned state ST3: based on Table 6, the first distribution priority can be distribution priority DP3; in this case, the first functional unit can distribute the first task to the second functional unit based on distribution priority DP3.
[0354] In some embodiments, the electronic device may first determine the corresponding QoS level based on the foreground operation and the device status of the electronic device, and then determine the first priority / third priority, the first operating frequency / first operating frequency, and the first distribution priority respectively according to the association relationship between the QoS level and the task priority, kernel operating frequency, and distribution priority. For details, please refer to the above-mentioned S501, the above-mentioned Tables 1 to 6, and the above-mentioned S402, S405, S406, S408, and S409, which will not be repeated here.
[0355] S603, it is detected that the running state of the first application has been switched from foreground running to background running, and the first service is scheduled. The scheduling process includes: adjusting the priority of the first task on the second processor from the first priority to the second priority, and / or adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency.
[0356] In some embodiments, the first service further includes a second task executed by the first processor, wherein, if the first application is running in the foreground, the second task has a third priority on the first processor, and the operating frequency of one or more cores of the first processor used to execute the second task is a third operating frequency. In this case, the scheduling process further includes: adjusting the priority of the second task on the first processor from the third priority to the fourth priority; and / or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency.
[0357] In some embodiments, when the first application is running in the foreground, the electronic device distributes the first task to the second processor based on a first priority; and the scheduling process further includes: adjusting the priority of the electronic device distributing the first task to the second processor from the first priority to the second priority.
[0358] In some embodiments, the electronic device includes a first functional unit and a second functional unit, wherein the first functional unit is configured to distribute a first task to the second functional unit, and the second functional unit is configured to distribute the first task to a second processor. When the running state of the first application is in the foreground, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. Furthermore, the scheduling process further includes: distributing the first task to the second functional unit by the first functional unit based on a second distribution priority.
[0359] In some embodiments, the second operating frequency, the second priority, the fourth priority, and the second priority are related to the running state of the first application.
[0360] For example, when the foreground operation is ST1 as described above and the background operation is ST2 as described above, the electronic device can, based on Table 1 or Table 4, adjust the priority of the first task on the second processor from task priority P1' (first priority) to task priority P2' (second priority), and / or adjust the priority of the second task on the first processor from task priority P1 (third priority) to task priority P2 (fourth priority). And / or, the electronic device can, based on Table 2 or Table 4, adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the "highest frequency" kernel operating frequency level (first operating frequency) to the operating frequency corresponding to the "highest frequency" kernel operating frequency level (second operating frequency); and adjust the operating frequency of one or more cores running the second task from the operating frequency corresponding to the "highest frequency" kernel operating frequency level (first operating frequency) to the operating frequency corresponding to the "highest frequency" kernel operating frequency level (second operating frequency). And / or, the electronic device can, based on Table 6, adjust the distribution priority of the first task from the first functional unit to the second functional unit from distribution priority DP1 (first distribution priority) to distribution priority DP2 (second distribution priority). In this scenario, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority.
[0361] For example, when the foreground operation is ST3 as described above and the background operation is ST4 as described above, the electronic device can, based on Table 1 or Table 4, adjust the priority of the first task on the second processor from task priority P3' (first priority) to task priority P4' (second priority), and / or adjust the priority of the second task on the first processor from task priority P3 (third priority) to task priority P4 (fourth priority). And / or, the electronic device can, based on Table 2 or Table 4, adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the core operating frequency level "medium frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "lowest frequency" (second operating frequency); and adjust the operating frequency of one or more cores running the second task from the operating frequency corresponding to the core operating frequency level "medium frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "lowest frequency" (second operating frequency). And / or, the electronic device can, based on Table 6, adjust the distribution priority of the first task from the first functional unit to the second functional unit from distribution priority DP3 (first distribution priority) to distribution priority DP4 (second distribution priority). In this scenario, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority.
[0362] For example, when the foreground operation is ST1 as described above and the background operation is ST4 as described above, the electronic device can, based on Table 1 or Table 4, adjust the priority of the first task on the second processor from task priority P1' (first priority) to task priority P4' (second priority), and / or adjust the priority of the second task on the first processor from task priority P1 (third priority) to task priority P4 (fourth priority). And / or, the electronic device can, based on Table 2 or Table 4, adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the "highest frequency" kernel operating frequency level (first operating frequency) to the operating frequency corresponding to the "lowest frequency" kernel operating frequency level (second operating frequency); and adjust the operating frequency of one or more cores running the second task from the operating frequency corresponding to the "highest frequency" kernel operating frequency level (first operating frequency) to the operating frequency corresponding to the "lowest frequency" kernel operating frequency level (second operating frequency). And / or, the electronic device can, based on Table 6, adjust the distribution priority of the first task from the first functional unit to the second functional unit from distribution priority DP1 (first distribution priority) to distribution priority DP4 (second distribution priority). In this scenario, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority.
[0363] For example, when the foreground operation is ST3 as described above and the background operation is ST2 as described above, the electronic device can, based on Table 1 or Table 4, adjust the priority of the first task on the second processor from task priority P3' (first priority) to task priority P2' (second priority), and / or adjust the priority of the second task on the first processor from task priority P3 (third priority) to task priority P2 (fourth priority). And / or, the electronic device can, based on Table 2 or Table 4, adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the core operating frequency level "medium frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "high frequency" (second operating frequency); and adjust the operating frequency of one or more cores running the second task from the operating frequency corresponding to the core operating frequency level "medium frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "high frequency" (second operating frequency). And / or, the electronic device can, based on Table 6, adjust the distribution priority of the first task from the first functional unit to the second functional unit from distribution priority DP3 (first distribution priority) to distribution priority DP2 (second distribution priority). In this scenario, the first priority is lower than the second priority, the first operating frequency is lower than the second operating frequency, and the first distribution priority is lower than the second distribution priority.
[0364] In some embodiments, the second operating frequency, the second priority, the fourth priority, and the second priority are related to the operating state of the first application and the operating state of the electronic device.
[0365] For example, when running in the background as ST2 and the device status level as DS1, based on Table 3 or Table 5, the second task priority can be task priority P2' (second priority), the fourth priority can be task priority P2, the second operating frequency can be the operating frequency corresponding to the kernel operating frequency level "high frequency", the fourth operating frequency can be the operating frequency corresponding to the kernel operating frequency level "high frequency", and the second distribution priority can be distribution priority DP2 (second distribution priority). In this case, corresponding to the foreground running as ST1, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority; corresponding to the foreground running as ST3, the first priority is lower than the second priority, the first operating frequency is lower than the second operating frequency, and the first distribution priority is lower than the second distribution priority.
[0366] For example, when running in the background as ST2 and the device status level as DS2, based on Table 3 or Table 5, the second task priority can be task priority P2' (second priority), the fourth priority can be task priority P2, the second operating frequency can be the operating frequency corresponding to the kernel operating frequency level "medium frequency", the fourth operating frequency can be the operating frequency corresponding to the kernel operating frequency level "medium frequency", and the second distribution priority can be distribution priority DP2 (second distribution priority). In this case, corresponding to running in the foreground as ST1, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority; corresponding to running in the foreground as ST3, the first priority is lower than the second priority, the first operating frequency is lower than the second operating frequency, and the first distribution priority is lower than the second distribution priority.
[0367] For example, when the background operation is ST4 as described above and the device status level is DS1 or DS2 as described above, based on Table 3 or Table 5, the second task priority can be task priority P2' (second priority), the fourth priority can be task priority P4, the second operating frequency can be the operating frequency corresponding to the "lowest frequency" of the kernel operating frequency level, the fourth operating frequency can be the operating frequency corresponding to the "lowest frequency" of the kernel operating frequency level, and the second distribution priority can be distribution priority DP4 (second distribution priority). In this case, the first priority is higher than the second priority, the first operating frequency is higher than the second operating frequency, and the first distribution priority is higher than the second distribution priority.
[0368] In some embodiments, the electronic device may first determine the corresponding QoS level based on background operation and the device status of the electronic device, and then determine the second priority / fourth priority, second operating frequency / fourth operating frequency, and second distribution priority respectively according to the association relationship between the QoS level and task priority, kernel operating frequency, and distribution priority. For details, please refer to the above-mentioned S502, the above-mentioned Tables 1 to 6, and the above-mentioned S414 to S416C, which will not be repeated here.
[0369] pass Figure 6 The method shown allows an electronic device to synchronously schedule a first task corresponding to a first service on a second processor, and a second task corresponding to the first service on the first processor, based on the running state of the first application and / or the device state. This avoids delays in the first service response or resource waste caused by mismatches in task priorities or distribution priorities between the first and second tasks, and / or mismatches in the operating frequencies of the kernel executing the first task and the kernel running the second task.
[0370] It should be noted that the technical solutions of this application embodiment are also applicable to the scheduling and processing of tasks in different software modules in a single processor.
[0371] For example, Figure 7A According to some embodiments of this application, a schematic diagram of establishing a session corresponding to a synchronous service is shown; Figure 7B According to some embodiments of this application, a schematic diagram of tasks and threads related to session scheduling synchronization services is shown.
[0372] like Figure 7A As shown, this scenario includes a system framework, a cloud image library application, a media management service, a scheduling management service, a CPU scheduler, service subsystems, and a file subsystem. The functions of the system framework, scheduling management service, and CPU scheduler can be found in [reference needed]. Figures 3A to 7B The specific implementation examples are not described in detail here.
[0373] Cloud image library applications are used to synchronize images between electronic devices and servers. For example, a cloud image library application can store data that exists on a cloud server but not on the electronic device through a file subsystem on the electronic device, or transfer data that exists on the electronic device but not on the cloud server to the cloud server, thereby achieving synchronization between the data stored on the electronic device and the data stored on the cloud server.
[0374] Media management services can include sub-services such as image management, metadata management, file management, and synchronization interfaces. These sub-services can provide interfaces for media management functions to applications (such as cloud image library applications, address book applications, and file management applications), such as image synchronization, file synchronization, address book synchronization, and file / image / audio management.
[0375] The synchronization interface is used for session creation / destruction, the establishment of synchronization services, and communication between the application and the media management service and file subsystem.
[0376] In some embodiments, the synchronization interface can respond to the application's call by establishing a session corresponding to the synchronization business through the scheduling management service, obtaining the SID of the established session, establishing the association between the SID and the corresponding task of the business and sending it to the cloud service subsystem (for example, sending the data access task corresponding to the synchronization business and the SID of the established session together to the cloud service subsystem), and destroying the session corresponding to the synchronization business after the synchronization business is completed.
[0377] For example, refer to Figure 7A ① In this context, the synchronization interface can respond to calls from the cloud image library application, establish session S10 through the scheduling management service, and obtain the session identifier SID10 of session S10.
[0378] For example, refer to Figure 7A In step ②, the synchronization interface can call the cloud data management service to establish the corresponding Chinese-English translation business task DA1 after obtaining the session identifier SID10 of session S10, and configure the session identifier SID10 for task DA1.
[0379] For example, refer to Figure 7A In section ⑥, the synchronization interface can destroy session S10 after the synchronization service execution is completed.
[0380] The cloud service subsystem may include cloud data management services and cloud data access interfaces.
[0381] The cloud data management service can respond to a request from the media management service to call a specific synchronization business, obtain data from the cloud server through the cloud data access interface, or store data locally stored on electronic devices in the cloud service.
[0382] In some embodiments, the cloud data management service can establish a cloud data access task (used for cloud servers to obtain data and / or cloud servers to send data, such as cloud data access task DA1, hereinafter referred to as task DA1) for each synchronization service, and establish a thread to implement cloud data access and synchronization (hereinafter, the thread that implements cloud data access is referred to as the synchronization thread, and the thread identifier of the synchronization thread is denoted as TID3).
[0383] In some embodiments, the cloud data management service can also establish an association between SID10, task DA1, and synchronization thread (e.g., thread identifier TID3) after receiving task DA1 and SID10.
[0384] For example, refer to Figure 7A In step ③, after task DA1 and its corresponding synchronization thread are established, the cloud data management service can establish an association between SID10, task DA1, and the synchronization thread (e.g., thread identifier TID3). For example, the cloud data management service can store the association between task DA1 and SID10, send the association between TID3 and SID10 to the CPU scheduler, and send the association between task DA1 and SID10 to the file subsystem, etc.
[0385] The cloud data management service can also be used to convert the QoS level sent by the scheduling management service into CPU task priority, and execute cloud data access tasks based on the converted CPU task priority.
[0386] For example, refer to Figure 7A In step ⑤, after receiving the initial QoS level and SID10, the cloud data management service can convert the initial QoS level into a CPU task priority and execute the task DA1 corresponding to SID10 based on the converted CPU task priority.
[0387] For example, refer to Figure 7B In step 9, after receiving the current QoS level and SID10, the cloud data management service can convert the current QoS level into a CPU task priority and execute the task DA1 corresponding to SID10 based on the converted CPU task priority.
[0388] The method by which cloud data management services convert QoS levels into CPU task priorities can be found in Table 4 or Table 5 or other methods for obtaining CPU task priorities, and will not be elaborated here.
[0389] The cloud data access interface is used to enable communication between the cloud data management service and the cloud server.
[0390] The file subsystem is used for reading, writing, and modifying data in the memory of electronic devices. For example, different applications, services, processes, and threads can access data through the file access interface provided by the file subsystem. A single call to the file access interface of an application, service, process, or thread can be called an input / output (I / O) task. That is, when multiple entities (applications, services, processes, and threads) call the file access interface, there will be multiple I / O tasks, and an I / O task can be executed by one or more I / O threads.
[0391] In some embodiments, the file subsystem can be used to establish the association between IO tasks and SIDs, as well as the association between SIDs and the corresponding IO threads of each IO task.
[0392] For example, refer to Figure 7A In step ④, the file subsystem can respond to the synchronous interface call by establishing an IO thread (thread identifier denoted as TID4) for the corresponding IO task DA2 (hereinafter referred to as DA2) in the cloud graph library. Then, the file subsystem can establish the association relationship between SID10, task DA2, and TID4. For example, the file subsystem can store the association relationship between task DA2 and SID10, and send the association relationship between TID4 and SID10 to the CPU scheduler, etc.
[0393] In some embodiments, the file subsystem can also be used to determine the CPU task priority corresponding to each IO task based on the SID and QoS level, and to execute each IO task based on the CPU task priority corresponding to each IO task.
[0394] For example, refer to Figure 7A In step ⑤, after receiving the initial QoS level and SID10, the file subsystem can convert the initial QoS level into a CPU task priority. Then, the file subsystem can execute task DA2 corresponding to SID10 based on the converted CPU task priority.
[0395] For example, refer to Figure 7B In step ⑨, upon receiving the current QoS level and SID10, the file subsystem can convert the current QoS level into a CPU task priority. Then, the file subsystem can execute task DA2 corresponding to SID10 based on the converted CPU task priority.
[0396] In some embodiments, the CPU scheduler can establish an association between the synchronization thread and the corresponding SID in the cloud data management service by interacting with the cloud data management service, or it can establish an association between the IO thread and the corresponding SID in the file subsystem by interacting with the file subsystem.
[0397] For example, refer to Figure 7A In point ③, the CPU scheduler can receive TID3 and SID10 from the cloud data management service and establish a relationship between SID10 and TID3. For example, see reference... Figure 7A In section ④, the CPU scheduler can receive the TID (e.g., TID4) and SID10 of the IO thread sent by the file subsystem and establish the association between SID10 and TID4.
[0398] In some embodiments, the CPU scheduler can also adjust the priority of the thread corresponding to the SID and / or configure the operating frequency of the kernel used to run the thread corresponding to the SID based on the QoS level and SID sent by the scheduling management service. For example, after receiving the QoS level, the CPU scheduler can obtain the CPU task priority and CPU operating frequency corresponding to the QoS level based on Tables 4 and 5; then, the CPU scheduler can schedule the thread corresponding to the SID based on the obtained CPU task priority and configure the operating frequency of the kernel running the thread corresponding to the SID to the obtained CPU operating frequency.
[0399] For example, refer to Figure 7A In step ⑤, after receiving the initial QoS level and SID10, the CPU scheduler can convert the initial QoS level into CPU task priorities and CPU operating frequencies. Then, the CPU scheduler can schedule the synchronization thread and I / O thread corresponding to SID10 based on the converted CPU task priorities, and configure the operating frequency of the kernel in the CPU used to run the synchronization thread and I / O thread according to the converted CPU operating frequency.
[0400] For example, refer to Figure 7B In step 9, upon receiving the current QoS level and SID10, the CPU scheduler can convert the current QoS level into CPU task priorities and CPU operating frequencies. Then, the CPU scheduler can schedule the synchronization thread and I / O thread corresponding to SID10 based on the converted CPU task priorities, and configure the operating frequency of the CPU kernel used to run the synchronization thread and I / O thread based on the converted CPU operating frequency.
[0401] based on Figure 7A and Figure 7B The method shown can avoid the mismatch between the priority of the cloud data management service scheduling task DA1 and the priority of the file subsystem scheduling task DA2, or the mismatch between the priorities of the synchronization thread corresponding to task DA1 and the IO thread corresponding to task DA2, or the mismatch between the kernel working frequencies of the synchronization thread corresponding to task DA1 and the IO thread corresponding to task DA2, which would affect the timeliness of the cloud image library application or waste resources.
[0402] This application also provides a task scheduling method for scenarios where tasks for the same business are implemented by multiple functional units.
[0403] For example, Figure 8 According to some embodiments of this application, a flowchart of another task scheduling method is shown. The execution entity of this method is an electronic device. Figure 8 As shown, the method includes:
[0404] S801, A request from the second application to call the second service is detected. The second service includes multiple tasks. The first part of the multiple tasks is executed by the third functional unit, and the second part of the multiple tasks is executed by the fourth functional unit.
[0405] It should be noted that the first part of the task and the second part of the task can be executed by the same processor or by different processors; this is not limited here.
[0406] It should be noted that the third and fourth functional units can be task-oriented functional units capable of implementing functions related to the first business. The specific forms of functional units can include, but are not limited to, applications, microservices, metaservices, mini-programs, software modules, system services, and third-party services.
[0407] It should be noted that the first part of the task and the second part of the task can be some or all of the multiple tasks in the second business.
[0408] For example, for synchronization services (such as synchronizing one or more of images, audio, video, contacts, and files), the third functional unit can be a cloud data management service, the fourth functional unit can be a file subsystem, the first task can be a cloud data access task, the second task can be an IO task, the first thread can be a synchronization thread, and the second thread can be an IO thread. It should be noted that the second service can be any service that requires the collaborative implementation of multiple functional units, including but not limited to synchronization services.
[0409] S802, establish a third association relationship between the second application, the first part of the task, the second part of the task, the first thread associated with the first part of the task in the third functional unit, and the second thread associated with the second part of the task in the fourth functional unit.
[0410] The electronic device can respond to a request from the second application to call the second service and establish a third association relationship between the second application, the first part of the task, the second part of the task, the first thread associated with the first part of the task in the third functional unit, and the second thread associated with the second part of the task in the fourth functional unit.
[0411] It should be noted that if the first part of the task is not executed by a specific thread, the third association relationship may not include the first thread; similarly, if the second part of the task is not executed by a specific thread, the third association relationship may not include the second thread. This application does not impose such limitations on the embodiments.
[0412] It should be noted that the first thread may include one or more threads, and the second thread may also include one or more threads; this is not limited here.
[0413] For example, the electronic device can establish a third session corresponding to the second service and configure a globally unique third session identifier for the third session. Then, the electronic device can establish associations between the second application (e.g., the package name of the second application, the PID of the process calling the second service, the TID of the thread calling the second service), the first part of the task, the second part of the task, the first thread (e.g., the TID of the first thread), and the second thread (e.g., the TID of the second thread). See details for further information. Figure 7A and Figure 7B The process by which electronic devices establish the association between SID10, TID3, TID4, task DA1, and task DA2 will not be elaborated here.
[0414] It should be noted that, in some other embodiments, when the above-mentioned multiple tasks of the second service include one or more tasks performed by one or more other functional units, the third association may also include the one or more tasks, and the thread in the fifth functional unit associated with the one or more tasks.
[0415] S803 determines a third QoS level based on the operating status of the second application and / or the device status of the electronic device.
[0416] After the third association is established, the electronic device can determine the third QoS level based on the operating status of the second application and / or the device status of the electronic device. For example, the electronic device can determine the third QoS level corresponding to the operating status of the second application and / or the device status of the electronic device based on Tables 4 and 5, or other associations between operating status, device status and QoS level.
[0417] For example, taking Table 5 as an example, when the second application is running in state S3 and the device status level is DS1, the scheduling management service can determine the initial QoS level as L3; when the second application is running in state S2 and the device status level is DS2, the scheduling management service can determine the initial QoS level as L6; and when the device status level is DS3, the scheduling management service can determine the initial QoS level as L9.
[0418] It should be noted that the method for determining the third QoS level can refer to the methods for determining the initial QoS level and the current QoS level mentioned above, and will not be repeated here.
[0419] S804 schedules and processes the second service based on the third association relationship and the third QoS level.
[0420] After determining the third QoS level, electronic devices can schedule and process the second service based on the third QoS level.
[0421] For example, the electronic device can determine the fifth priority corresponding to the third QoS level based on Table 4, Table 5, or other correspondences between QoS levels and priorities, and configure the priorities corresponding to the first and second part tasks as the fifth priority. Then, the third functional unit can execute the first part task based on the fifth priority, and the fourth functional unit can execute the second part task based on the fifth priority. For example, the third functional unit can execute the first part task before other tasks with priorities lower than the fifth priority, and the fourth functional unit can execute the second part task before other tasks with priorities lower than the fifth priority.
[0422] For example, an electronic device can determine the fifth priority corresponding to the third QoS level based on Table 4, Table 5, or other correspondences between QoS levels and priorities, and configure the first thread corresponding to the first part of the task and the second thread corresponding to the second part of the task to the fifth priority. Then, the electronic device (e.g., a scheduling management service) can schedule the first and second threads based on the fifth priority. For example, the electronic device can schedule the first and second threads before other threads with a priority lower than the fifth priority.
[0423] For example, an electronic device can determine the fifth operating frequency level corresponding to the third QoS level based on Table 4, Table 5, or other correspondences between QoS levels and priorities, and configure the first kernel running the first thread to operate at the operating frequency corresponding to the fifth operating frequency level, and configure the operating frequency of the kernel running the second thread to operate at the operating frequency corresponding to the fifth operating frequency level.
[0424] It should be noted that before the second service is completed, the electronic device can repeat S803 and S804 to update the third QoS level based on the running status of the second application and / or the device status of the electronic device, and schedule the second service based on the updated third QoS level.
[0425] based on Figure 8As shown, the electronic device can synchronously configure the priorities of the first and second parts of the task based on its device state, and / or synchronously configure the priorities of the first thread associated with the first part of the task and the second thread corresponding to the second part of the task, and / or synchronously configure the operating frequency of the kernel running the first and second threads. This helps improve the efficiency of the electronic device in executing the second service.
[0426] This application also provides a computer program product, which may be a software or program product including instructions, capable of running on a computing device or stored on any usable medium. When the computer program product runs on at least one computing device, it causes the at least one computing device to implement the task scheduling method provided in this application.
[0427] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any storage medium (e.g., magnetic medium, optical medium, semiconductor medium, etc.) capable of storing and / or retrieving data by a computing device. The computer-readable storage medium includes instructions that direct the computing device to implement the task scheduling method provided in this application.
[0428] This application also provides an electronic device, which includes at least one processor, memory, and non-volatile memory. The at least one processor is used to execute instructions to implement the task scheduling methods provided in the foregoing embodiments.
[0429] This application also provides a task scheduling device for implementing the task scheduling methods provided in the foregoing embodiments.
[0430] For example, Figure 9 A schematic diagram of a task scheduling device 200 is shown according to some embodiments of this application.
[0431] like Figure 9 As shown, the task scheduling device includes a scheduling management unit 201, one or more functional units 202, a first scheduling unit 203, and a second scheduling unit 204.
[0432] The scheduling management unit 201 is used to establish / maintain / destroy sessions, determine the QoS level based on the application's running status, and send the QoS level to the functional unit 202, the first scheduling unit 203, and the second scheduling unit 204. For details, please refer to the aforementioned scheduling management service; further elaboration will not be repeated here.
[0433] In some embodiments, the scheduling management unit 201 may also determine the aforementioned first QoS level and second QoS level based on the running status of the application and / or the device status of the electronic device, and send the first QoS level and second QoS level to the functional unit 202, the first scheduling unit 203, and the second scheduling unit 204. For details, please refer to the contents of S402, S414, S415, S502, S503, S602, and S603, which will not be repeated here.
[0434] Functional unit 202 is used to distribute the SID of the first task and session of the first service to the second scheduling unit, establish the second task of the first service, and send the SID of the second task and session to the first scheduling unit 203. For details, please refer to the aforementioned AI service management service; it will not be repeated here. For example, functional unit 202 may include a first functional unit, which may send the first task to the second scheduling unit 204 (or second functional unit) based on the aforementioned first or second distribution priority. For details, please refer to the aforementioned S406, S416A, S502, S503, S602, and S603; it will not be repeated here.
[0435] The first scheduling unit 203 is used for scheduling the first processor. For example, the first scheduling unit 203 can be used to maintain the association between the SID of the second task and the session, and configure the priority of the second task on the first processor and the working frequency of the kernel running the second task on the first processor based on the QoS level sent by the scheduling management unit 201. For details, please refer to the aforementioned CPU scheduler content, which will not be repeated here.
[0436] For example, the first scheduling unit 203 can configure the priority of the second task on the first processor to the third priority or the fourth priority, and configure the operating frequency of the kernel running the second task on the first processor to the third operating frequency or the fourth operating frequency, etc. For details, please refer to the aforementioned S405, S412C, S416C, S502, S503, S602, and S603, which will not be repeated here.
[0437] The second scheduling unit 204 is used for scheduling the first processor. For example, the second scheduling unit 204 can be used to maintain the association between the SIDs of the first task and the session, and configure the priority of the first task on the second processor, the operating frequency of the kernel running the first task on the second processor, and the priority of the second task distributed by the second scheduling unit 204 to the second processor based on the QoS level sent by the scheduling management unit 201. For details, please refer to the previous content on AI task executors, which will not be repeated here.
[0438] For example, the second scheduling unit 204 can configure the priority of the first task on the second processor as a first priority or a second priority, configure the operating frequency of the kernel running the first task on the second processor as a first operating frequency or a second operating frequency, and distribute the first task to the second processor with the first priority or the second priority, etc. For details, please refer to the aforementioned S408, S412B, S416B, S502, S503, S602, and S603, which will not be repeated here.
[0439] It should be noted that, Figure 9 The structure of the task scheduling device shown is only an example. In other embodiments, the task scheduling device 200 may include more or fewer modules, or merge or split some modules, which is not limited here.
[0440] For example, Figure 10 According to some embodiments of this application, a schematic diagram of the structure of an electronic device 100 is shown. The electronic device 100 can be used to implement the task scheduling methods provided in the embodiments of this application.
[0441] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and 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.
[0442] Processor 110 may include one or more processing units, such as a central processing unit (CPU), application processor, modem processor, graphics processing unit (GPU), image signal processor (ISP), microcontroller unit (MCU), video codec, digital signal processor (DSP), baseband processor, neural network processing unit (NPU), field-programmable gate array (FPGA), etc. In some embodiments, different processing units may be independent devices or integrated into one or more processors. These one or more processing units may include the aforementioned first processor and second processor.
[0443] In some embodiments, the processor 110 may be used to execute instructions to implement the task scheduling methods provided in the foregoing embodiments.
[0444] The charging management module 140 receives charging input from the charger. While charging the battery 142, the charging management module 140 can also supply power to the electronic device through the power management module 141.
[0445] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, display 194, camera 193, and wireless communication module 160, etc.
[0446] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0447] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
[0448] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
[0449] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as Wireless Fidelity), Bluetooth (BT), Global Navigation Satellite System (GNSS), Near Field Communication (NFC), Infrared (IR), and Near Link (NL). The wireless communication module 160 can be one or more devices integrating at least one communication processing module.
[0450] Electronic device 100 implements 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.
[0451] Display screen 194 is used to display images.
[0452] Camera 193 is used to capture still images or videos.
[0453] The external memory interface 120 can be used to connect an external memory card. The external memory card communicates with the processor 110 through the external memory interface 120 to implement data storage functions. For example, application data can be stored on the external memory card. In some embodiments, the memory connected to the external memory interface 120 can be a non-volatile memory, which can be used to store application buffers.
[0454] Internal memory 121 can be used to store one or more programs and corresponding data. Internal memory 121 may include a program storage area and a data storage area. In some embodiments, the program storage area may store an operating system, an application program required for at least one function, such as a program / instruction corresponding to the task scheduling method provided in the foregoing embodiments. The data storage area may store data created during the use of electronic device 100. In addition, internal memory 121 may include high-speed random access memory (e.g., RAM); it may also include non-volatile memory, such as at least one disk storage device, flash memory device, general-purpose flash memory, etc. Processor 110 executes various functional applications of electronic device 100 by running one or more programs stored in internal memory 121 and / or one or more programs stored in memory disposed in processor 110.
[0455] In some embodiments, the volatile memory (e.g., RAM) in the internal memory 121 can be used to store application buffers when the application is running in the foreground or when the application is running in the background and the swap-out condition is not met; the non-volatile memory in the internal memory 121 and the non-volatile memory connected to the external memory interface 120 can be used to store application buffers when the application is running in the background and the swap-out condition is met.
[0456] Electronic device 100 can implement audio functions through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor. For example, audio module 170 can be used to play prompts.
[0457] Audio module 170 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. Audio module 170 can also be used for encoding and decoding audio signals.
[0458] The loudspeaker 170A, also known as a "loudspeaker", is used to convert audio electrical signals into sound signals.
[0459] The receiver 170B, also known as the "earpiece", is used to convert audio electrical signals into sound signals.
[0460] The microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals.
[0461] The 170D headphone jack is used to connect wired headphones.
[0462] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0463] Motor 191 can generate vibration alerts. Indicator 192 can be an indicator light, used to indicate charging status, power level changes, or to indicate messages, notifications, etc. In some embodiments, electronic device 100 can alert the user by controlling the vibration of motor 191.
[0464] The SIM card interface 195 is used to connect a SIM card or eSIM.
[0465] It should be noted that the structure of the electronic device 100 shown in the embodiments of this application does not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than shown, or combine some components, or split some components, or have different component arrangements. The components shown may be implemented in hardware, software, or a combination of software and hardware.
[0466] It should be noted that in the embodiments of this application, "or" describes the relationship between related objects, indicating that there can be two relationships. For example, A or B can mean either A or B, where A or B can be singular or plural.
[0467] It should be noted that in the embodiments of this application, terms such as "for example," "in some embodiments," "in another embodiment," "in yet another embodiment," and "exemplarily" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as an "example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the term "example" is intended to present concepts in a concrete manner.
[0468] It should be noted that the terms "first" and "second" used in the embodiments of this application are only used for descriptive purposes and should not be construed as indicating or implying relative importance or order. The term "equal to" in the embodiments of this application can be used with "greater than" to apply to technical solutions used when "greater than," and can also be used with "less than" to apply to technical solutions used when "less than." It should be noted that when "equal to" is used with "greater than," it is not used with "less than," and vice versa.
[0469] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.
[0470] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A task scheduling method, characterized in that, Applied to electronic devices, the method includes: The first application runs through the first processor of the electronic device, and the first application is running in the foreground. Upon detecting a request from the first application to invoke the first service, the second processor of the electronic device executes a first task included in the first service and establishes a first association between the first application and the first task. The first task has a first priority in the second processor, and the operating frequency of at least one core in the second processor used to run the first task is a first operating frequency. Upon detecting that the running state of the first application has been switched from foreground to background, the first service is scheduled. The scheduling process includes: adjusting the priority of the first task on the second processor from the first priority to the second priority, and / or adjusting the operating frequency of the at least one core from the first operating frequency to the second operating frequency.
2. The method according to claim 1, characterized in that, The first service also includes a second task executed by the first processor. When the first application is running in the foreground, the second task has a third priority on the first processor, and the operating frequency of one or more cores of the first processor used to execute the second task is a third operating frequency. The scheduling process also includes: The priority of the second task on the first processor is adjusted from the third priority to the fourth priority; And / or, adjust the operating frequency of the one or more cores from the third operating frequency to the fourth operating frequency.
3. The method according to claim 2, characterized in that, When the first application is running in the foreground, the electronic device distributes the first task to the second processor based on the first priority; Furthermore, the scheduling process also includes: The priority of the electronic device distributing the first task to the second processor is adjusted from the first priority to the second priority.
4. The method according to claim 3, characterized in that, The electronic device includes a first functional unit and a second functional unit, wherein the first functional unit is used to distribute the first task to the second functional unit, and the second functional unit is used to distribute the first task to the second processor. When the running state of the first application is the foreground running state, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. The scheduling process also includes: The first functional unit distributes the first task to the second functional unit based on the second distribution priority.
5. The method according to claim 4, characterized in that, The first priority, the third priority, the first distribution priority, the first operating frequency, and the third operating frequency are related to the foreground operation, or to the foreground operation and the device status of the electronic device; the second priority, the fourth priority, the second distribution priority, the second operating frequency, and the fourth operating frequency are related to the background operation, or to the background operation and the device status of the electronic device; wherein, the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
6. The method according to claim 4, characterized in that, The second priority is lower than the first priority, and / or the fourth priority is lower than the second priority, and / or the second distribution priority is lower than the first distribution priority, and / or the second operating frequency is lower than the first operating frequency, and / or the fourth operating frequency is lower than the second operating frequency.
7. The method according to claim 1, characterized in that, The foreground operation includes foreground operation and being the focus, and / or foreground operation and not being the focus; the background operation includes background operation and being perceptible to the user and / or background operation and not perceptible to the user.
8. The method according to any one of claims 1 to 7, characterized in that, The first association relationship includes the association relationship between the first session identifier of the first session and the first application, and the association relationship between the first session identifier and the first task.
9. The method according to claim 8, characterized in that, The detection process involves switching the running state of the first application from foreground to background, and then scheduling the first service, including: In response to the first application switching its running state from foreground to background, the first session identifier is determined based on the first application and the first association relationship, and a first quality of service level corresponding to the background running is configured for the first session corresponding to the first session identifier.
10. The method according to claim 9, characterized in that, The step of detecting and switching the running state of the first application from foreground to background, and scheduling the first service, further includes: Based on the first service quality level, the relationship between service quality level and priority, and the first relationship, the priority of the first task on the second processor is adjusted from the first priority to the second priority. And / or, based on the first quality of service level, the correlation between the quality of service level and the operating frequency, and the first correlation, the operating frequency of the at least one core is adjusted from the first operating frequency to the second operating frequency.
11. The method according to claim 8, characterized in that, The method further includes: In response to the completion of the first service or the cessation of the first application, the first session is deleted.
12. The method according to claim 9, characterized in that, The first quality of service level is related to the background operation, or the first quality of service level is related to the background operation and the device status of the electronic device, wherein the device status includes one or more of the following: remaining battery power, temperature, processor load, power connection status, and available bandwidth of memory.
13. The method according to claim 1, characterized in that, The first processor is a central processing unit, and the second processor is a graphics processing unit or a neural network processor.
14. The method according to claim 2, characterized in that, The first processor is a central processing unit, and the second task includes at least one thread associated with the first task.
15. The method according to claim 2, characterized in that, The first service is an artificial intelligence service, the first processor is a central processing unit, the second processor is a neural network processor, the first task is a task included in the artificial intelligence service and executed in the neural network processor based on an artificial intelligence model, and the second task is at least one thread associated with the first task and running on the central processing unit.
16. A readable storage medium, characterized in that, The readable storage medium includes one or more programs that, when executed on an electronic device, cause the electronic device to implement the task scheduling method according to any one of claims 1 to 15.
17. An electronic device, characterized in that, include: Memory, used to store one or more programs; A first processor and a second processor are configured to execute one or more programs to enable the electronic device to implement the task scheduling method according to any one of claims 1 to 15.
18. A program product, characterized in that, When the program product is executed on an electronic device, it causes the electronic device to implement the task scheduling method according to any one of claims 1 to 15.