Task scheduling method, readable storage medium, program product and electronic equipment
By detecting the running status of the first application in the electronic device and dynamically adjusting the priority of the task on the processor and the operating frequency of the core, the problem of scheduling mismatch during multi-processor collaborative processing is solved, and more efficient resource utilization and responsiveness are achieved.
Patent Information
- Application Number
- CN202510585499.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-05-07
AI Technical Summary
In electronic devices, when multiple processors collaborate to process the same service, if task scheduling does not match, the electronic device may fail to respond to the service in a timely manner or waste computing resources.
By detecting the running state of the first application, the priority of the task on the processor and the operating frequency of the core are dynamically adjusted to match the running state of the application.
This avoids electronic device response delays or resource waste caused by mismatches between task priority and processor frequency and the application's running status.
Smart Images

Figure CN120670104A_ABST
Abstract
Description
Technical Field
[0001] The present 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 Art
[0002] Electronic devices are typically equipped with multiple processors, such as a central processing unit (CPU), a neural network processing unit (NPU), and a graphics processing unit (GPU). Different processors have different performance and uses. In some scenarios, multiple processors can collaborate to process the same task.
[0003] When a service is collaboratively processed by multiple processors, if the scheduling modes of the tasks corresponding to the service are not matched among the processors processing the service, the electronic device may fail to respond to the service in a timely manner or waste computing resources. Summary of the Invention
[0004] In view of this, the present 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, which is applied to an electronic device, the method comprising: running a first application through a first processor of the electronic device, the running state of the first application being foreground running; detecting a request from the first application to call a first service, executing a first task included in the first service through a second processor of the electronic device, wherein the priority of the first task in the second processor is a first priority, and the operating frequency of at least one core in the second processor for running the first task is a first operating frequency; detecting that the running state of the first application is switched from foreground running to background running, scheduling the first service, the scheduling comprising: adjusting the priority of the first task in 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, the electronic device can, when the first application is running in the foreground, configure the priority of the first task on the second processor to the first priority and the operating frequency of the core running the first task in the second processor to the first operating frequency; when the first application is switched to run in the background, configure the priority of the first task on the second processor to the second priority and / or configure the operating frequency of the core running the first task in the second processor to the second operating frequency. In other words, the electronic device can use the second processor to run the first task with different priorities and / or use different operating frequencies to run the first task based on the different running states of the first application in the foreground and background. In this way, it can avoid the electronic device from responding to the first service delay or wasting resources due to the mismatch between the priority of the first task on the second processor and the running state of the first application, and / or the mismatch between the operating frequency of the core running the first task in the second processor and the running state of the first application.
[0007] In a possible implementation of the above-mentioned first aspect, the above-mentioned first business also includes a second task executed by the first processor. When the running state of the first application is foreground running, the priority of the second task on the first processor is the third priority, and the operating frequency of one or more cores of the first processor used to execute the second task is the third operating frequency; the above-mentioned scheduling processing also 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 as the running state of the first application changes, thereby avoiding delays in the electronic device's response to the first service or waste of resources due to a mismatch between the priority of the first task on the second processor and the priority of the second task on the first processor. In addition, the operating frequency of the core executing the second task in the first processor can also be dynamically adjusted as the running state of the first application changes, thereby avoiding delays in the electronic device's response to the first service or waste of resources due to a mismatch between the operating frequency of the core executing the second task on the first processor and the operating frequency of the core executing the first task on the second processor.
[0009] In a possible implementation of the first aspect above, when the running status of the first application is foreground running, the electronic device distributes the first task to the second processor based on the first priority; and the scheduling process also includes: adjusting the priority of the electronic device in 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 in distributing the first task to the second processor may also change with the running state of the first application, thereby avoiding distributing the first task to the second processor too late, which may cause delays in the execution of the first task, and avoiding distributing the first task to the second processor too early, which may cause waste of resources or affect the execution of other tasks in the second processor.
[0011] In a 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 the first task to the second functional unit, and the second functional unit is used to distribute the first task to the second processor, and when the running state of the first application is foreground running, the first functional unit distributes the first task to the second functional unit based on the first distribution priority; the above scheduling processing also includes: distributing the first task to the second functional unit based on the second distribution priority through the first functional unit.
[0012] In this implementation, the distribution priority of the first task from the first functional unit to the second functional unit may also change with the change of the running state of the first application, so as to avoid the delay of the execution of the first task due to the late distribution of the first task to the second functional unit, and to avoid the waste of resources or the impact of the second functional unit in distributing other tasks with higher priority.
[0013] In a 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 are related 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 are related to background operation and the device status of the electronic device; wherein the device status includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0014] In a possible implementation of the above-mentioned first aspect, the above-mentioned 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 a possible implementation of the first aspect above, the foreground running includes foreground running and being in focus, and / or foreground running and not being in focus; the background running includes background running and being perceptible to the user and / or background running and not being perceptible to the user.
[0016] In a 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 relationship between the first application and the first task, the first association relationship including an association relationship between the first session identifier of the first session and the first application, and an association relationship between the first session identifier and the first task.
[0017] In this implementation, the electronic device may establish a first association between the first session identifier of the first session, the first application, and the first task in response to a request from the first application to invoke the first service. This first association may be used by the electronic device to determine, based on the running state of the first application, the priority of the first task on the second processor and / or the operating frequency of the core in the second processor that runs the first task.
[0018] In a possible implementation of the first aspect above, the above detection of switching the running state of the first application from foreground running to background running and scheduling the first service includes: in response to the running state of the first application switching from foreground running to background running, 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 switches from foreground running to background running, the electronic device can determine the first service quality level (for example, L2, L4, L6 or L8) corresponding to the background running based on the association between the running state and the service quality level (for example, the association shown in the first and second columns of Table 4 below, or the association shown in the first, second and third columns of Table 5 below).
[0020] In a possible implementation of the first aspect above, the above-mentioned detection of switching the running state of the first application from foreground running to background running and scheduling the first business also includes: based on the first service quality level, the association between the service quality level and the priority and the first association relationship, adjusting the priority of the first task in the second processor from the first priority to the second priority; and / or, based on the first service quality level, the association between the service quality level and the operating frequency and the first association relationship, adjusting the operating frequency of at least one core from the first operating frequency to the second operating frequency.
[0021] In this implementation, the electronic device may first determine the priority (second priority) of the task on the second processor corresponding to the first quality of service level based on the first quality of service level and the association between the quality of service level and the priority (for example, the association 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 and the association between the quality of service level and the core operating frequency (for example, the association shown in columns 2 and 6 of Table 4 below). Then, the electronic device may 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 a possible implementation of the first aspect, the method further includes: deleting the first session in response to completion of execution of the first service or cessation of execution of the first application.
[0023] In a 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 device status of the electronic device, wherein the device status includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0024] In a 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, the second association relationship including an association relationship between the second session identifier of the second session and the first application, an association relationship between the second session identifier and the first task, and an association relationship between the second session identifier and the second task.
[0025] In a possible implementation of the first aspect above, the above detection of switching the running state of the first application from foreground running to background running and scheduling the first service include: in response to the running state of the first application switching from foreground running to background running, 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 association between the operating status and the service quality level (for example, the association shown in the first and second columns of Table 4 below), or determine the second service quality level corresponding to the background operation and the current device status level of the electronic device based on the association between the operating status, the device status level and the service quality level (for example, the association shown in the first to third columns of Table 5 below).
[0027] In a possible implementation of the first aspect above, the above-mentioned detection of switching the running state of the first application from foreground running to background running and scheduling the first business also includes: based on the second quality of service level, the association relationship between the quality of service level and the priority and the second association relationship, 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 distributing the first task to the second processor from the third priority to the fourth priority; and / or, based on the second quality of service level, the association relationship between the quality of service level and the distribution priority and the second association relationship, adjusting the priority of the first task distributed by the first functional unit to the second functional unit from the first distribution priority to the second distribution priority; and / or, based on the second quality of service level, the association relationship between the quality of service level and the operating frequency and the second association relationship, 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.
[0028] In this implementation, the electronic device may 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 association relationship between the quality of service level and the priority (for example, the association relationship shown in the 3rd and 6th columns 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, the association relationship between the quality of service level and the priority (for example, the association relationship shown in the 3rd and 4th columns 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, the association relationship between the quality of service level and the core operating frequency (for example, the association relationship shown in the 3rd and 4th columns of Table 5 below). The electronic device may determine the operating frequency (second operating frequency) corresponding to the core operating frequency level of the second processor based on the second quality of service level and the association between the quality of service level and the core operating frequency (for example, the association shown in columns 3 and 7 of Table 5 below); and / or determine the operating frequency (fourth operating frequency) corresponding to the core operating frequency level of the first processor based on the second quality of service level and the association between the quality of service level and the core operating frequency (for example, the association shown in columns 3 and 5 of Table 5 below); and / or determine the distribution priority (second distribution priority) for distributing the first task corresponding to the second quality of service level based on the association between the second quality of service level and the distribution priority (for example, the association shown in columns 3 and 4 of Table 6). Then, the electronic device may 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 task distributed by the first functional unit to the second functional unit from the first distribution priority to the second distribution priority.
[0029] In a possible implementation of the first aspect, the method further includes: deleting the second session in response to completion of execution of the first service or cessation of execution of the first application.
[0030] In a 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 device status of the electronic device, wherein the device status includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0031] In a possible implementation of the first aspect 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 a possible implementation of the first aspect, 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, 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 (NPU), 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 may be one or more tasks in Task 01, and the second task may be a data transmission thread and / or a Chinese-English translation execution thread. In a second aspect, the present application provides a task scheduling method, which is applied to an electronic device, the method comprising: running a first application through a first processor of the electronic device, the running state of the first application being 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 the second processor of the electronic device, wherein the priority of the first task in the second processor is a first priority, and the operating frequency of at least one core in the second processor for running the first task is a first operating frequency; detecting that the running state of the first application switches from the first running state to the second running state, scheduling the first service, the scheduling processing comprising: adjusting the priority of the first task in 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 information: whether the first application is running in the foreground or background, whether the first application is a focus application, and whether the first application is user-perceivable.
[0034] Based on the above method, the electronic device can, when the running state of the first application is the first running state, configure the priority of the first task on the second processor to the first priority and configure the operating frequency of the core running the first task in the second processor to the first operating frequency; after the running state of the first application is switched to the second running state, the electronic device can configure the priority of the first task on the second processor to the second priority and / or configure the operating frequency of the core running the first task in the second processor to the second operating frequency. In other words, the electronic device can use the second processor to run the first task with different priorities and / or use different operating frequencies to run the first task based on the different running states of the first application. In this way, it can avoid the electronic device from delaying the response to the first service or wasting resources due to the mismatch between the priority of the first task on the second processor and the running state of the first application, and / or the mismatch between the operating frequency of the core running the first task in the second processor and the running state of the first application.
[0035] In a possible implementation of the above-mentioned second aspect, the above-mentioned first business also includes a second task executed by the first processor, and when the running state of the first application is the first running state, the priority of the second task on the first processor is the third priority, and the operating frequency of one or more cores of the first processor used to execute the second task is the third operating frequency; the above-mentioned scheduling processing also 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; wherein, 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 size relationship between the third operating frequency and the fourth operating frequency is the same as the size relationship between the first operating frequency and the second operating frequency.
[0036] In a possible implementation of the second aspect above, when the running state of the first application is the first running state, the electronic device distributes the first task to the second processor based on the first priority; and the scheduling process also includes: adjusting the priority of the electronic device in distributing the first task to the second processor from the first priority to the second priority.
[0037] In a 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 the first task to the second functional unit, and the second functional unit is used to distribute the first task to the second processor, and when the running status of the first application is foreground running, the first functional unit distributes the first task to the second functional unit based on the first distribution priority; the above scheduling processing also includes: distributing the first task to the second functional unit based on the second distribution priority through the first functional unit.
[0038] In a 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 are related 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 are related to background operation and the device status of the electronic device; wherein the device status includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0039] In a possible implementation of the second aspect above, the running state corresponding to the first application includes multiple states: running in the foreground and in focus, running in the foreground and not in focus, running in the background and perceptible to the user, and running in the background and not perceptible to the user; or, the running state corresponding to the first application includes multiple states: running in the foreground, running in the background and perceptible to the user, and running in the background and not perceptible to the user; or, the running state corresponding to the first application includes multiple states: running in the foreground and in focus, running in the foreground and not in focus, and running in the background; or the running state corresponding to the first application includes running in the foreground and running in the background.
[0040] In a possible implementation of the second aspect above, in the following circumstances, the second priority is lower than the first priority, and / or the second operating frequency is lower than the first operating frequency: the first running state is foreground running and is the focus, the second running state is foreground running and is not the focus, background running and is user-perceivable, or background running and is not user-perceivable; or, the first running state is foreground running and is not the focus, the second running state is background running and is user-perceivable, or background running and is not user-perceivable; or, the first running state is background running and is user-perceivable, the second running state is background running and is user-perceivable; or, the first running state is background running and is user-perceivable, the second running state is background running and is not user-perceivable; or, the first running state is foreground running, and the second running state is background running.
[0041] In a possible implementation of the second aspect above, in the following circumstances, the second priority is higher than the first priority, and / or the second operating frequency is greater than the first operating frequency: the first running state is background running and is not perceptible to the user, and the second running state is foreground running and is in focus, foreground running and is not in focus, or background running and perceptible to the user; or, the first running state is background running and perceptible to the user, and the second running state is foreground running and is in focus or foreground running and is not in focus; or, the first running state is foreground running and is not in focus, and the second running state is foreground running and is in focus; or, the first running state is background running, and the second running state is foreground running.
[0042] In a 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 relationship between the first application and the first task, the first association relationship including an association relationship between the first session identifier of the first session, the first application, and the first task.
[0043] In a possible implementation of the second aspect, the above-mentioned detection that the running state of the first application switches from the first running state to the second running state and the scheduling processing of the first service include: 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 the 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 the 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 the operating frequency, and the first association relationship.
[0044] In a possible implementation of the second aspect, the method further includes: deleting the first session in response to completion of execution of the first service or cessation of execution of the first application.
[0045] In a possible implementation of the second aspect above, the first quality of service level is related to the second operating state, or is related to the second operating state and the device state of the electronic device, wherein the device state includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0046] In a possible implementation of the second aspect above, the above method also 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, the second association relationship including the second session identifier of the second session, the first application, the second task and the association relationship between the first task.
[0047] In a possible implementation of the second aspect, the detecting that the running state of the first application switches from the first running state to the second running state and the scheduling processing of the first service include: in response to the running state of the first application switching from the first running state to the second running state, determining a second session identifier based on the first application and the second association, and configuring a second quality of service 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 the priority of the second task on the first processor from the third priority to the fourth priority based on the second quality of service level, the association between the quality of service level and the 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 quality of service level, the association between the quality of service level and the operating frequency, and the second association; and / or adjusting the priority of the first task distributed by the first functional unit to the second functional unit from the first distribution priority to the second distribution priority based on the second quality of service level, the association between the quality of service level and the distribution priority, and the second association.
[0048] In a possible implementation of the second aspect, the method further includes: deleting the second session in response to completion of the first service execution or cessation of the first application.
[0049] In a possible implementation of the second aspect above, the second service quality level is related to the second operating state, or is related to the second operating state and the device state of the electronic device, wherein the device state includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
[0050] In a possible implementation of the second aspect, the first processor is a central processing unit, and the second processor is a graphics processor or a neural network processor.
[0051] In a possible implementation of the second aspect, the first processor is a central processing unit, and the second task includes at least one thread associated with the first task.
[0052] In a third aspect, a readable storage medium is provided, which includes one or more programs. When the one or more programs are executed on an electronic device, the electronic device implements the task scheduling method provided in the first aspect and any possible implementation of the first aspect.
[0053] In a fourth aspect, an electronic device is provided, comprising: a memory for storing one or more programs; and a processor for executing the one or more programs so that the electronic device implements the task scheduling method provided in the first aspect and any possible implementation of the first aspect.
[0054] In a fifth aspect, a program product is provided. When the program product is executed on an electronic device, the electronic device implements 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 elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 According to some embodiments of the present application, a schematic diagram of a Chinese-English translation service scenario is shown.
[0057] Figure 2A According to some embodiments of the present application, a schematic diagram of the interaction between the CPU and the NPU in a Chinese-English translation business scenario is shown.
[0058] Figure 2B According to some embodiments of the present application, a schematic diagram of an NPU task list is shown.
[0059] Figure 3A According to some embodiments of the present application, a schematic diagram of a process in which a call application calls a Chinese-English translation service is shown.
[0060] Figure 3B According to some embodiments of the present application, a schematic diagram of establishing a first association relationship or a second association relationship based on a session is shown.
[0061] Figure 3C According to some embodiments of the present application, a schematic diagram of tasks and threads related to a Chinese-English translation service based on session scheduling is shown.
[0062] Figure 4A According to some embodiments of the present application, a schematic diagram of an interaction process for an electronic device to perform a Chinese-English translation service is shown.
[0063] Figure 4B According to some embodiments of the present application, a schematic diagram of an interaction process of another electronic device performing a Chinese-English translation service is shown.
[0064] Figure 5 According to some embodiments of the present application, a flowchart of a task scheduling method is shown.
[0065] Figure 6According to some embodiments of the present application, a flowchart of another task scheduling method is shown.
[0066] Figure 7A According to some embodiments of the present application, a schematic diagram of establishing a session corresponding to a synchronous service is shown.
[0067] Figure 7B According to some embodiments of the present application, a schematic diagram of tasks and threads related to synchronous services based on session scheduling is shown.
[0068] Figure 8 According to some embodiments of the present application, a flowchart of another task scheduling method is shown.
[0069] Figure 9 According to some embodiments of the present application, a schematic diagram of a task scheduling device is shown.
[0070] Figure 10 According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown. DETAILED DESCRIPTION
[0071] Illustrative embodiments of the present application include, but are not limited to, a task scheduling method, a readable storage medium, an electronic device, and a program product.
[0072] To facilitate understanding, the terms involved in the embodiments of the present application are first introduced.
[0073] The technical solution of this application is introduced below with reference to the accompanying drawings.
[0074] It should be noted that the task scheduling method provided in the embodiments of the present application can be applied to any electronic device, such as an electronic device including at least one processor. For example, the electronic device may include, but is not limited to, a mobile station (MS), a mobile terminal (MT), such as a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a desktop computer, a laptop computer, a virtual reality (VR) device, an augmented reality (AR) device, a terminal in industrial control, a terminal in self-driving, a terminal in remote medical surgery, a terminal in a smart grid, a terminal in transportation safety, a terminal in a smart city, a terminal in a smart home, a vehicle-mounted terminal (such as a vehicle computer, a smart cockpit, a vehicle-mounted tablet, etc.), and the like.
[0075] When a service is collaboratively processed by multiple processors, if the scheduling modes of the tasks corresponding to the service are not matched among the processors processing the service, the electronic device may fail to respond to the service in a timely manner or waste computing resources.
[0076] For example, Figure 1 According to some embodiments of the present 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 rejection control, an AI call control, and an acceptance control. In response to the operation of user A of the electronic device clicking the AI call control, the electronic device can display the AI call interface U2 to enable user A to talk with user B based on artificial intelligence (AI) technology (such as Chinese-English translation, text call, AI answering, etc.). Among them, the Chinese-English translation service is specifically an electronic device that converts user B's voice into text and displays it in the interface, and converts the text entered by user A into voice and sends it to user B's electronic device; the Chinese-English translation service is used to convert user A's Chinese voice into English voice and send it to user B's electronic device, and convert user B's English voice into Chinese voice for playback; AI answering is used for the intelligent body to talk with user B.
[0078] Taking the Chinese-English translation service as an example, the NPU of the electronic device can convert the English voice of user B into Chinese voice and the Chinese voice of user A into English voice by executing one or more tasks (hereinafter referred to as task 01) that the Chinese-English translation service needs to execute on the NPU. Exemplarily, task 01 may include the task of converting the English voice of user B into English text based on an automatic speech recognition (ASR) model, the task of converting the Chinese voice of user A into Chinese text, the task of translating the Chinese text of user A into English text based on a translation model, the task of translating the English text of user B into Chinese text based on a translation model, and the task of converting the translated English text of user A into English voice and the task of converting the translated Chinese text of user B into Chinese voice based on a text to speech (TTS) model. In the process of the call application calling the Chinese-English translation service, refer to Figure 2A The CPU of the 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 from the NPU.
[0079] In some cases, reference Figure 2B In this scenario, the NPU must execute Task 01, corresponding to the Chinese-English translation service, as well as Task 02, Task 03, and Task 04. In this scenario, if the NPU's scheduling of Task 01 and the CPU's scheduling of data transmission threads do not match the call service's operating status (e.g., foreground or background), the electronic device will be unable to respond to the Chinese-English translation service in a timely manner, impacting the user experience.
[0080] For example, for Figure 1 In the scenario shown, after the call application calls the Chinese-English translation service, if the NPU prioritizes scheduling tasks 02, 03, and 04 and does not prioritize scheduling task 01, or the CPU does not prioritize scheduling the above-mentioned data transmission threads (or the processor core (referred to as the core, also called core, core, processing core) used to run the data transmission thread runs at a lower operating frequency), it may cause the NPU to be unable to convert user B's English voice into Chinese voice, or convert user A's Chinese voice into English voice in a timely manner, resulting in a delay in user A hearing user B's Chinese voice or user B hearing user A's English voice.
[0081] Based on this, an embodiment of the present application provides a task scheduling method, which is applied to an electronic device including multiple processors, wherein the multiple processors include a first processor and a second processor. In the process of an electronic device running a first application through a first processor, the electronic device can execute at least one task of the first business through the second processor when detecting that the first application calls a first business that requires the collaborative execution of the second processor (hereinafter referred to as the at least one task of the first business executed by the second processor) in the first business. In the process of executing 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 based on the running state of the first application, and adjust the operating frequency of the kernel running the first task in the second processor. In this way, it is possible to avoid the electronic device from failing to execute the first business in a timely manner or causing resource waste due to the mismatch between the priority of the first task and the running state of the first application, and / or the mismatch between the operating frequency of the kernel running the first task and the running state of the first application.
[0082] It should be noted that the operating frequency of a processor core (also known as main frequency, clock frequency, operating frequency, or frequency point) refers to the frequency at which the core operates when the processor executes instructions. The operating frequency of a processor core can generally be adjusted within a certain range. The higher the operating frequency of the processor core, the higher the computing performance of the processor core. A processor may include one or more cores, and electronic devices can configure the same or different operating frequencies for these one or more cores.
[0083] It should be noted that a business can be divided into one or more tasks, and the one or more tasks can be executed by one or more processors. The specific forms of tasks executed on different processors may be different. For example, the NPU is scheduled and processed at the granularity of task. The tasks executed on the NPU can be tasks that process data through one or more models and obtain processing results, or tasks that process data through one or more operators in the one or more models, or tasks of other granularities divided by the processor based on its own operating logic. For another example, the CPU is scheduled and processed at the granularity of thread, and the tasks executed on the CPU may include one or more threads. For another example, the input and output (IO) controller is scheduled and processed at the granularity of IO request, and the specific form of the tasks executed on the IO controller can be IO request.
[0084] For example, the electronic device may run a first application in a first operating state via a first processor. Upon detecting a request from the first application to invoke a first service, the electronic device may configure the priority of a first task corresponding to the first service on the second processor to a first priority matching the first operating state, and schedule and execute the first task via the second processor based on the first priority.
[0085] In some embodiments, when the running state of the first application is the first running state, the operating frequency of at least one core in the second processor for executing the above-mentioned first task can also be configured as the first operating frequency matching the first running state.
[0086] During the process of the second processor scheduling and executing the first task based on the first priority, the electronic device may, after detecting a first operation by a user 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. The 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 the at least one core from the first operating frequency to the 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 matching the second running state, and / or adjust the operating frequency of the above at least one core from the first operating frequency to the second operating frequency matching the second running state, thereby avoiding the electronic device from failing to execute the first service in a timely manner or causing waste of resources.
[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 second tasks). When the electronic device executes the first service 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 a thread that provides input data to the first task, a thread that obtains the execution result of the first task, a thread that schedules the thread that provides input data to the first task / the thread that obtains 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 the first running state, the priority of the second task can be configured to the third priority that matches the first running state, and the operating frequency of the one or more cores can be configured to the third operating frequency that matches the first running state; after the running state of the first application switches from the first running state to the second state, the priority of the second task can be configured to the fourth priority that matches the second running state, and the operating frequency of the one or more cores can be configured to the third operating frequency that matches 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 avoid the situation where the way the first processor schedules the second task is different from the way the second processor schedules the first task, which affects the execution of the first business.
[0091] In some embodiments, when a first application calls a first service, the electronic device can establish a first association relationship between the first application and the first task corresponding to the first service; or a second association relationship between the first application and the first task corresponding to the first service, and the second task. In this way, when the running state of the first application changes, the electronic device can search for the first task to be scheduled based on the first association relationship, or search for the first task and the second task to be scheduled based on the second association relationship. The method of establishing the first association relationship and the second association relationship will be introduced below and will not be repeated here.
[0092] In some embodiments, to balance parameters such as performance, power consumption, heat dissipation, and battery life of an electronic device, the configurable range of the core operating frequencies 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: remaining battery power, temperature, processor load, power connection status, and available memory bandwidth. 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 the processor is connected to a power source, 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. When the electronic device has a low remaining battery power, and / or a high temperature, and / or a high processor load, and / or the processor is not connected to a power source, 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 process of the first service, the specific values of the core operating frequencies 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 is not detailed here.
[0093] Next, we will describe the running status of the application.
[0094] It should be noted that the running state of the application is used to indicate the running status of the application in the foreground or background. In some embodiments, the running state may include the following states ST1 to ST4:
[0095] ST1: Foreground Running and Focused: This means the application is running in the foreground and is the focused application. "Foreground Running" means the application is the foreground application; "focused application" means the currently active application, such as the last application running in the foreground or the application that was the subject of the last user action.
[0096] ST2: Running in the background and user-perceivable. "Background running" means the application is a background application; "user-perceivable" means the application provides information to the user through a display interface, sound, vibration motor, indicator light, etc. For example, an application that runs in the background and plays audio or video, an application that runs in the background and controls the lighting or changing of indicator lights on electronic devices, an application that runs in the background and vibrates through the motor of an electronic device, and an application that runs in the background and displays part of the application's content through a small window, live window, etc.
[0097] ST3: Running in the foreground and not in focus, that is, the application is running in the foreground and is not the focus application.
[0098] ST4. Running in the background and not perceptible to the user. This means that the application runs in the background and does not display content on the display interface of the electronic device, nor does it provide information to the user through any other means other than the display interface of the electronic device.
[0099] It should be noted that, in other embodiments, the running state of the application can also be divided into more or fewer states, or some states can be merged / split, which is not limited here. For example, running in the foreground and being in focus, running in the foreground and not being in focus can be divided into one running state (such as running in the foreground (denoted as ST5)), and running in the background and being perceptible to the user, and running in the background and not being perceptible to the user can be divided into one running state (such as running in the background (denoted as ST6)). For another example, state ST3 (running in the foreground and not in focus) can be divided into multiple running states based on whether the window of the application is blocked by the windows of other applications or the degree of being blocked, such as: running in the foreground and not in focus, and the window is not blocked, running in the foreground and not in focus, and the window is partially blocked, running in the foreground and not in focus, and the area of the window blocked is less than the first threshold, running in the foreground and not in focus, and the area of the window blocked is greater than the second threshold, running in the foreground and not in focus, and the area of the window blocked is between the first threshold and the second threshold, etc.
[0100] It should be noted that the running state of the first application may include part or all of states ST1 to ST6, such as states ST1 to ST4, state ST5, state ST2 and state ST4, state ST1, state ST3 and state ST6, state ST5 and state ST6, etc. The embodiment of the present application does not limit the division method of the running state of the first application.
[0101] Next, in conjunction with the aforementioned operating states, a scheme for configuring the priority of electronic device tasks and the operating frequency of the core is introduced.
[0102] Exemplarily, the electronic device may first establish an association between the running state and the task priority, and / or an association between the running state and the operating frequency of the processor core (hereinafter referred to as the core operating frequency). Then, during the operation of the first application, the electronic device may determine 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 core of the second processor used to execute the first task, and the core operating frequency of the core of the first processor used to run the second task based on the running state of the first application and the above-mentioned association. Then, the electronic device may schedule the first service based on the task priority and core operating frequency obtained from the above-mentioned association.
[0103] It should be noted that the task priority may be the priority of a software module (eg, processor driver, application programming interface, etc.) in the electronic device to distribute tasks to the processor, or the priority of a processor to execute tasks.
[0104] In some embodiments, the association between the running state and the 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 association between the running state and the core operating frequency may include an association between the running state and the core operating frequency of the first processor, and an association between the running state and the core operating frequency of the second processor.
[0106] It should be noted that the association between the running state and the task priority, and the association between the running state and the kernel operating frequency can be a direct association, or an indirect association established based on an intermediate parameter (the intermediate parameter can be one or more). In the case where the association between the running state and the priority and the kernel operating frequency is a direct association, the electronic device can directly determine the task priority corresponding to the first task or the second task based on the running state of the first application, and the operating frequency corresponding to the kernel running the first task or the second task. In the case where the association between the running state and the priority and the kernel operating frequency is an indirect association (for example, the association between the running state and the intermediate parameter, and the association between the intermediate parameter and the priority and the kernel operating frequency), the electronic device can determine the intermediate parameter based on the running state of the first application and the association between the running state and the intermediate parameter, and then determine the task priority corresponding to the first task or the second task, and the kernel operating frequency corresponding to the kernel running the first task or the second task based on the association between the intermediate parameter and the priority and the kernel operating frequency.
[0107] The following introduces several examples of establishing the association between the running status and priority, and the association between the running status and the core operating frequency.
[0108] Method 1: Directly establish the association between the running status and the task priority, and the association between the running status and the core operating frequency.
[0109] For example, Table 1 shows an example of an association relationship between an operating state and a task priority.
[0110] Table 1. The relationship between running status and task priority.
[0111]
[0112] As shown in Table 1, the running state of the first application may include state ST1 to state ST4, and the task priorities of the tasks executed by the first processor corresponding to states ST1 to ST4 may be task priority P1, task priority P2, task priority P3, and task priority P4 arranged from high to low, and the task priorities of the tasks executed by the second processor corresponding to states ST1 to ST4 may be task priority P1', task priority P2', task priority P3', and task priority P4' arranged from high to low.
[0113] Based on Table 1 above, the electronic device can, when the running state of the first application is ST1, configure the task priority of the first task to P1' and the task priority of the second task to P1. Alternatively, the electronic device can, when the running state of the first application is ST2, configure the task priority of the first task to P2' and the task priority of the second task to P2. Alternatively, the electronic device can, when the running state of the first application is ST3, configure the task priority of the first task to P3' and the task priority of the second task to P3. Alternatively, the electronic device can, when the running state of the first application is ST4, configure the task priority of the first task to P4' and the task priority of the second task to P4.
[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 and higher than task priority P2, task priority P2 can be a real-time priority and lower than task priority P1, task priority P3 can be a non-real-time priority and higher than task priority P4, task priority P4 can be a non-real-time priority and lower than task priority P3, wherein the real-time priority is higher than the non-real-time priority. Optionally, task priorities P1 to P4 are all lower than the priorities corresponding to the threads / processes / tasks used to draw the display interface in the electronic device.
[0115] It should be noted that the specific names of the task priorities P1 ′ to P4 ′ may 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 divided, and 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, which is not limited here.
[0117] It should be noted that the high and low relationship of the task priorities corresponding to the operating states shown in Table 1 is only an example. In other embodiments, the task priorities corresponding to the operating states may also be adjusted, which is not limited in the embodiments of the present application. For example, the high and low relationship of the task priorities corresponding to state ST2 and state ST3 may be exchanged, such as the task priority of the first processor corresponding to state ST2 may be task priority P3, the task priority of the first processor corresponding to state ST3 may be task priority P2, and / or the task priority of the second processor corresponding to state ST2 may be task priority P3', the task priority of the second processor corresponding to state ST3 may be task priority P2'.
[0118] In some embodiments, a plurality of core operating frequency levels may be configured for the processor, where each core operating frequency level may correspond to an operating frequency of a processor core. Then, a correspondence between the running state of the application and the core operating frequency level may be established.
[0119] For example, Table 2 shows an association relationship between an operating state and a core operating frequency level.
[0120] Table 2 Correlation between operating status and core operating frequency level
[0121]
[0122] As shown in Table 2, the running state of the first application may include states ST1 to ST4. The core operating frequency levels of the first processor corresponding to states ST1 to ST4 may be arranged from high to low as the highest frequency, high frequency, medium frequency, and lowest frequency, and the core operating frequency levels of the second processor corresponding to states ST1 to ST4 may be arranged from high to low as the highest frequency, high frequency, medium frequency, and lowest frequency. The frequency values or maximum values (or minimum values, or intermediate values) of the frequency value intervals corresponding to the highest frequency, high frequency, medium frequency, and lowest frequency operating frequency levels decrease in sequence.
[0123] It should be noted that an operating frequency level can correspond to a specific frequency value or a frequency range. For example, the operating frequency can be configured by a lower frequency threshold and / or an upper frequency threshold: when the lower frequency threshold and the upper frequency threshold are the same, the core runs at the same frequency as the lower frequency threshold and the upper frequency threshold; when the lower frequency threshold and the upper frequency threshold are different, the core can run at any frequency between the lower frequency threshold and the upper frequency threshold (the arbitrary frequency can be a fixed value or can change dynamically); when only the lower frequency threshold is configured, the core can run at any frequency between the lower frequency threshold and the highest frequency value of the core (the arbitrary frequency can be a fixed value or can change dynamically); when only the upper frequency threshold is configured, the core can run at any frequency between the lowest frequency value of the core and the upper frequency threshold (the arbitrary frequency can be a fixed value or can change dynamically).
[0124] It should be noted that the specific numerical value of the operating frequency corresponding to the core operating frequency level of the first processor and the specific numerical value of the operating frequency corresponding to the core operating frequency level of the second processor may be the same or different, and this is not limited here. For example, if the frequency range of a core of the first processor is 1000 MHz to 2000 MHz, and the frequency range of another core of the second processor is 600 MHz to 1600 MHz, then the operating frequencies corresponding to the four operating frequency levels of the highest frequency, high frequency, medium frequency, and lowest frequency of the core of the first processor may be 1900 MHz to 2000 MHz, 1500 MHz to 1700 MHz, 1200 MHz to 1300 MHz, and 1000 MHz to 1100 MHz, respectively, while the operating frequencies corresponding to the four operating frequency levels of the highest frequency, high frequency, medium frequency, and lowest frequency of the other core of the second processor may 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 values of the operating frequencies of different cores in the same processor at the same operating frequency level can be the same or different. For example, the frequency range of a core of a first processor is 1000MHz to 2000MHz, and the frequency range of another core is 800MHz to 1600MHz. The operating frequencies corresponding to the four operating frequency levels of the highest frequency, high frequency, medium frequency, and lowest frequency for the core can be 1900MHz to 2000MHz, 1500MHz to 1700MHz, 1200MHz to 1300MHz, and 1000MHz to 1100MHz, respectively, while the operating frequencies corresponding to the four operating frequency levels of the highest frequency, high frequency, medium frequency, and lowest frequency for the other core can be 1500MHz to 1600MHz, 1300MHz to 1400MHz, 1000MHz to 1100MHz, and 800MHz to 900MHz, respectively. Based on the association shown in Table 1, the electronic device can determine the corresponding QoS level based on the running state of the first application during the running of the first application. 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 the above-mentioned 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 the above-mentioned 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 association relationship shown in Table 2, the electronic device can, when the running state of the first application is ST1, configure the first task kernel running in the second processor to the operating frequency corresponding to the core operating frequency level of "highest frequency", and / or configure the second task kernel running in the first processor to the operating frequency corresponding to the core operating frequency level of "highest frequency". Alternatively, the electronic device can, when the running state of the first application is ST2, configure the first task kernel running in the second processor to the operating frequency corresponding to the core operating frequency level of "high frequency", and / or configure the second task kernel running in the first processor to the operating frequency corresponding to the core operating frequency level of "high frequency". Alternatively, the electronic device can, when the running state of the first application is ST3, configure the first task kernel running in the second processor to the operating frequency corresponding to the core operating frequency level of "medium frequency", and / or configure the second task kernel running in the first processor to the operating frequency corresponding to the core operating frequency level of "medium frequency". When the running state of the first application is ST4, the electronic device can configure the first task core running in the second processor to the operating frequency corresponding to the core operating frequency level "lowest frequency", and / or configure the second task core running in the first processor to the operating frequency corresponding to the core operating frequency level "lowest frequency".
[0127] It should be noted that, in other embodiments, the core operating frequency levels in Table 2 may also be replaced with specific frequency values or frequency ranges, which are not limited here.
[0128] It should be noted that the division of core operating frequency levels shown in Table 2 is only an example. In other embodiments, the division may be divided into more or fewer core operating frequency levels, which is not limited here. For example, if the number of core operating frequency levels is less than the number of operating states, one core operating frequency level may correspond to multiple operating states.
[0129] It should be noted that the high and low relationship of the core operating frequency levels corresponding to the operating states shown in Table 1 is only an example. In other embodiments, the core operating frequency levels corresponding to the operating states can also be adjusted, which is not limited in the embodiments of the present application. For example, the high and low relationship of the core operating frequency level corresponding to state ST2 and the core operating frequency level corresponding to state ST3 can be exchanged, such as the core operating frequency level of the first processor corresponding to state ST2 can be medium frequency, the core operating frequency level of the first processor corresponding to state ST3 can be high frequency, and / or the core operating frequency level of the second processor corresponding to state ST2 can be medium frequency, and the core operating frequency level of the second processor corresponding to state ST3 can be high frequency.
[0130] Method 2: Directly establish the association between the running status, device status and task priority, and the association between the running status, device status and kernel operating frequency.
[0131] In some embodiments, the operating frequency of the core may also be related to the device state of the electronic device. For example, when the remaining power of the electronic device is relatively high, and / or the temperature is relatively low, and / or the processor load is relatively low, and / or the processor is connected to a power source, and / or the available bandwidth of the memory is relatively high, the device state level is relatively high, and the operating frequency of the core of the first processor and / or the second processor may be configured with a relatively high value; when the remaining power of the electronic device is relatively low, and / or the temperature is relatively high, and / or the processor load is relatively high, and / or the processor is not connected to a power source, and / or the available bandwidth of the memory is relatively low, the device state level is relatively low, and the operating frequency of the core of the first processor and / or the second processor may be configured with a relatively low value.
[0132] Based on the above-mentioned device status level, the electronic device can first establish an association relationship between the device status level (or device status), the operating status and the task priority, and / or the association relationship between the device status level (or device status), the operating status and the core operating frequency. Then, during the operation 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 core of the second processor used to execute the first task and the operating frequency of the core of the first processor used to run the second task based on the operating status of the first application, the device status level of the electronic device and the association relationship. Then, the electronic device can schedule the first service based on the task priority and operating frequency obtained from the above-mentioned association relationship.
[0133] For example, Table 3 shows an example of the association relationship among the running state, the device state level, the task priority, and the core operating frequency level.
[0134] Table 3 Correlation between operating status, device status level, task priority, and core operating frequency level.
[0135]
[0136]
[0137] As shown in Table 3, when the device status level is DS1, the task priorities of the tasks executed by the first processor corresponding to states ST1 to ST4 may be task priority P1, task priority P2, task priority P3, and task priority P4, and the task priorities of the tasks executed by the second processor corresponding to states ST1 to ST4 may be task priority P1', task priority P2', task priority P3', and task priority P4'. When the device status level is DS2, the task priorities of the tasks in the first processor corresponding to states ST1 to ST4 may be task priority P1, task priority P2, task priority P3, and task priority P4, and the task priorities of the tasks in the second processor corresponding to states ST1 to ST4 may be task priority P1', task priority P2', task priority P3', and task priority P4'. 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', where task priority P5 can be lower than task priority P4 or the same as task priority P4, and task priority P5' can be lower than task priority P4' or the same as task priority P4'.
[0138] Continuing to refer to Table 3, when the device status level is DS1, 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, and 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. When the device status level is DS2, the core operating frequency levels of the first processor corresponding to states ST1 to ST4 can be medium frequency, medium frequency, lowest frequency, and lowest frequency, and the core operating frequency levels of the second processor corresponding to states ST1 to ST4 can be medium frequency, medium frequency, lowest frequency, and lowest frequency. When the device status level is DS3, the core operating frequency level of the first processor can be the lowest frequency, and the core operating frequency level of the second processor can be the lowest frequency.
[0139] 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 that match the running state of the first application and the device state level of the electronic device. The electronic device can then 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 core running the second task based on the determined core operating frequency level of the first processor, configure the operating frequency of the core running the first task based on the determined core operating frequency level of the second processor, and the second task based on the determined core operating frequency level. For example, if the running 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 core 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 core running the first task in the second processor to the operating frequency corresponding to the core operating frequency level "medium frequency".
[0140] It should be noted that, in other embodiments, the device status level may also include more or fewer levels, which is not limited here.
[0141] Method 3 indirectly establishes the association between the running status and the priority, and the association between the running status and the core operating frequency.
[0142] In some embodiments, the association relationship between the quality of service (QoS) level (as an intermediate parameter) that matches the running state of the application (hereinafter referred to as the running state-QoS level association relationship), as well as the association relationship between the QoS level and the task priority of each processor scheduling task (hereinafter referred to as the QoS level-priority association relationship), and the association relationship between the QoS level and the core operating frequency level of each processor (hereinafter referred to as the QoS level-operating frequency level association relationship) can be pre-configured. 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 relationship; then, the electronic device can adjust the task priorities of the first task and the second task related to the first business based on the determined QoS level and QoS-priority association relationship, and / or adjust the operating frequency of the core executing the first task and the core executing the second task based on the determined QoS level and QoS-operating frequency level association relationship.
[0143] It should be noted that in some embodiments, part or all of the operating status-QoS level association relationship, QoS level-priority association relationship, and QoS level-operating frequency level association relationship can also be combined into one association relationship, and the embodiments of the present application do not limit this.
[0144] Exemplarily, Table 4 shows an association relationship among an operating state, a QoS level, a task priority, and a core operating frequency level according to some embodiments of the present application.
[0145] Table 4. Correlation between running status, QoS level, task priority, and core operating frequency level.
[0146]
[0147] As shown in Table 4, the running state of the first application may include states ST1 to ST4, and the QoS levels corresponding to states ST1 to ST4 may be QoS levels L1 to QoS level L4, respectively. The task priorities of the tasks executed by the first processor corresponding to QoS levels L1 to L4 may 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 may 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 may 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 may be the highest frequency, high frequency, medium frequency, and lowest frequency.
[0148] In some embodiments, the association relationship indicated by the operating status column (column 1) and the QoS level column (column 2) in Table 4 may be an operating status-QoS level association relationship. The association relationship indicated by the QoS level column in Table 4 and the task priority column (column 3) of the first processor and the task priority column (column 5) of the second processor may be a QoS level-priority association relationship. The association relationship indicated by the QoS level column in Table 3 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 may be a QoS level-operating frequency level association relationship.
[0149] Optionally, in some embodiments, the above Table 4 can be split into multiple tables to indicate different association relationships. For example, the first and second columns in Table 4 can be split to obtain the operating status-QoS level association relationship, the second, third, and fifth columns in Table 4 can be split to obtain the QoS level-priority association relationship, and the second, fourth, and sixth columns and the second column in Table 4 can be split to obtain the QoS level-operating frequency level association relationship. This embodiment of the present application is not limited.
[0150] Based on the association shown in Table 4, when executing the first service, the electronic device may first determine the QoS level associated with the running state of the first application in Table 4 based on the running state of the first application. The electronic device may then schedule the corresponding task based on the task priority associated with the determined QoS level, and configure the operating frequency of the core used to execute the first task or the second task based on the core operating frequency level associated with the determined QoS level.
[0151] For example, when the running state of the first application is state ST4, the electronic device can determine that the QoS level corresponding to state ST4 is L4 based on Table 4; then, the electronic device can determine that the task priority on the first processor corresponding to QoS level L4 is P4, the task priority on the second processor corresponding to QoS level L4 is P4', the core operating frequency level of the first processor corresponding to QoS level L4 is the lowest frequency, and the core operating frequency level of the second processor corresponding to QoS level L4 is the lowest frequency; finally, the electronic device can configure the priority of the first task on the second processor to task priority P4, configure the priority of the second task on the first processor to task priority P4', configure the operating frequency of the core running the first task in the second processor to the operating frequency corresponding to the core operating frequency level "lowest frequency", and configure the operating frequency of the core running the second task in the first processor to the operating frequency corresponding to the core operating frequency level "lowest frequency".
[0152] Method 4: Indirectly establish the association between the running status, device status and task priority, and the association between the running status, device status and kernel operating frequency.
[0153] Exemplarily, Table 5 shows the association 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 according to some embodiments of the present application.
[0154] Table 5. Correlation between operating status, device status level, QoS level, task priority, and core operating frequency level.
[0155]
[0156]
[0157] As shown in Table 5, the QoS levels include QoS level L1 to QoS level L9, which respectively correspond to 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).
[0158] Continuing to refer to Table 5, the task priorities of the tasks executed by the first processor corresponding to QoS levels L1 to L9 may 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 may 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 (wherein, task priority P5' may be lower than task priority P4' or the same as task priority P4'). The core operating frequency levels of the first processor corresponding to QoS levels L1 to L9 may be 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: highest frequency, high frequency, medium frequency, lowest frequency, highest frequency, high frequency, medium frequency, lowest frequency and lowest frequency.
[0159] Based on the association shown in Table 5, the electronic device can determine the corresponding QoS level during the operation of the first application based on the operating state of the first application and the device status level of the electronic device. Then, the task priority of the second task is configured based on the task priority on the first processor corresponding to the QoS level, the task priority of the first task is configured based on the task priority on the second processor corresponding to the QoS level, the operating frequency of the 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 the 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.
[0160] For example, when the running state of the first application is state ST4 and the device state level is DS1, the electronic device can determine that the QoS level corresponding to state ST4 and device state level DS1 is L4 based on Table 4; then, the electronic device can determine that the task priority on the first processor corresponding to QoS level L4 is P4, the task priority on the second processor corresponding to QoS level L4 is P4', the core operating frequency level of the first processor corresponding to QoS level L4 is the lowest frequency, and the core operating frequency level of the second processor corresponding to QoS level L4 is the lowest frequency; finally, the electronic device can configure the task priority of the first task on the second processor to task priority P4, configure the task priority of the second task on the first processor to task priority P4', configure the operating frequency of the core running the first task in the second processor to the operating frequency corresponding to the core operating frequency level "lowest frequency", and configure the operating frequency of the core running the second task in the first processor to the operating frequency corresponding to the core operating frequency level "lowest frequency".
[0161] It should be noted that the device status levels, QoS level division methods, priority division methods, operating frequency level division methods, etc. 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, which is not limited here. For example, multiple QoS levels in Table 5 may correspond to the same task priority and / or the same core operating frequency level, and one task priority or core operating frequency level may also correspond to multiple QoS levels, which is not limited here.
[0162] In some embodiments, when 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 may further be configured with a distribution priority corresponding to the running state of the first application and the device status level (or QoS level). In the process of distributing the first task, any one of the one or more functional units may also distribute the first task based on the running state of the first application and the device status level of the electronic device.
[0163] It should be noted that the distribution priority may refer to the priority of task transfer between software modules of the electronic device.
[0164] Illustratively, Table 6 shows an example of an association relationship between the QoS level configured for the first functional unit among the one or more functional units and the distribution priority.
[0165] Table 6 Correlation between operating status, device status level, QoS level, and distribution priority.
[0166]
[0167]
[0168] As shown in Table 6, the distribution priorities, from high to low, may include distribution priority DP1, distribution priority DP2, distribution priority DP3, distribution priority DP4, and distribution priority DP5. Distribution priority 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 device state level DS3.
[0169] based on Figure 6 As shown in the association relationship, in the process of distributing 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, when 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. For another example, when the first functional unit obtains the running state of the first application as ST2 and the device status level as DS2, it can distribute the first task to the second functional unit based on the distribution priority DP2 corresponding to the state ST2 and the device status level DS2.
[0170] It should be noted that the first functional unit may also configure only some of the associations in Table 6, which is not limited here. For example, the first functional unit may configure the correspondence between QoS levels and distribution priorities, such as the associations shown in columns 3 and 4 in Table 6; or the relationship between operating status, device status, and distribution priority, such as the correspondences shown in columns 1, 2, and 4 in Table 6.
[0171] It should be noted that, for multiple functional units involved in the same service, the same or different distribution priorities may be configured for the tasks of the service, which is not limited here.
[0172] It should be noted that, in other embodiments, the distribution priorities may be divided in other ways, such as dividing more or fewer distribution priorities, which is not limited here.
[0173] Below, the technical solution of this application is introduced by taking the case where the first application is a call application and the first service is a Chinese-English translation service as an example.
[0174] For example, Figure 3A According to some embodiments of the present application, a schematic diagram of a process in which a call application calls a Chinese-English translation service is shown.
[0175] like Figure 3A As shown, when the electronic device detects that the user has enabled the Chinese-English translation service (for example, when the user clicks Figure 1 ), you can initiate a request for Chinese-English translation service to the AI assistant process through the call process of the call application (the process used to implement the call function).
[0176] Then, the AI assistant process can respond to the call of the call process and run the AI toolkit (hereinafter referred to as AI kit) corresponding to the Chinese-English translation service (hereinafter referred to as the AI kit corresponding to the Chinese-English translation service as the Chinese-English translation AI kit. Then, the Chinese-English translation AI kit can request the AI service management service (a service used to manage and coordinate AI services in electronic devices) to establish a thread in the AI service management service for executing the Chinese-English translation service (hereinafter referred to as the Chinese-English translation execution thread) and an AI task (for example, task 01) for implementing the Chinese-English translation service.
[0177] It should be noted that an AI kit can be an electronic device used to implement an AI service interface. One AI service can correspond to one AI kit, and one AI kit can correspond to one or more AI services.
[0178] Secondly, the Chinese-English translation execution thread can interact with the AI task executor and dispatch Task 01 to it. After receiving Task 01, the AI task executor can establish a thread associated with Task 01 on the CPU (such as a data transmission thread), load the AI model used to execute Task 01, and schedule the NPU to execute Task 01.
[0179] Finally, based on the Chinese voice of user A sent by the data transmission thread, the NPU may convert user A's Chinese voice into Chinese text by executing the Chinese voice-to-Chinese text subtask of Task 01, translate user A's Chinese text into English text by executing the Chinese text-to-English text subtask of Task 01, and convert user A's English text into English voice by executing the English text-to-English voice subtask. Furthermore, the NPU may send user A's English voice to the call process through the AI task executor, AI task management service, Chinese-English translation AI kit, etc., for the call process to send it to user B's electronic device. Based on the English voice of user B sent by the data transmission thread, the NPU may convert user B's English voice into English text by executing the English voice-to-English text subtask of Task 01, translate user B's English text into Chinese text by executing the English text-to-Chinese text subtask of Task 01, and convert user B's K-text into Chinese voice by executing the Chinese text-to-Chinese voice subtask. Furthermore, the NPU may send user B's K-text voice to the call process through the AI task executor, AI task management service, Chinese-English translation AI kit, etc., for the call process to play.
[0180] It should be noted that Figure 3A The process shown is only an example. In other embodiments, the first task and the second task corresponding to the Chinese-English translation service (such as a data transmission thread and a Chinese-English translation execution thread) may be established in other forms, which are not limited here.
[0181] It should be noted that for other businesses, Figure 3A The process shown is to establish the tasks corresponding to the business and the threads associated with the tasks corresponding to the business. 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 tasks corresponding to the XX business and threads associated with tasks corresponding to the XX business through the XX execution thread and the AI task executor.
[0182] Next, combine Figure 3A The process shown introduces the process of an electronic device establishing a first association relationship between a first application and a first task corresponding to a first service called by the first application, or establishing a second association relationship between a first application and a first task corresponding to the first service called by the first application and a second task.
[0183] Exemplarily, the electronic device can establish a session related to the first application and the first business when the first application calls the first business, and configure a globally unique session identifier (SID) for the session. Then, the electronic device can associate the first task corresponding to the first business with the configured SID; and when the second task of the first business is running in the CPU, the second task is also associated with the configured SID. That is to say, the first application, the first task corresponding to the first business, and the second task are all associated with the same SID. In this way, a first association relationship between the first application and the first task corresponding to the first business called by the first application can be established, or a second association relationship between the first application, the first task corresponding to the first business called by the first application, and the second task can be established.
[0184] In some embodiments, the first application may call 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.
[0185] In some embodiments, any process of the first application may also call one or more services, and the one or more services may respectively correspond to a session, and the SIDs of the sessions corresponding to the one or more services are different.
[0186] In some embodiments, the SID of a session can be randomly generated or generated by other means. Different sessions have different corresponding SIDs. In this way, when there are multiple sessions in an electronic device, the electronic device can still uniquely identify a session through a SID, thereby scheduling the task configured with the SID, the task priority / distribution priority of the thread, and the operating frequency of the kernel running the task / thread configured with the SID according to the running status of the application corresponding to the SID. For example, Figure 3B According to some embodiments of the present application, a schematic diagram of an architecture for establishing a session is shown.
[0187] For example, Figure 3B According to some embodiments of the present application, a schematic diagram of establishing a first association relationship or a second association relationship based on a session is shown.
[0188] like Figure 3B As shown, the electronic device may include a system framework, a scheduling management service, a CPU scheduler, a call application, an AI assistant, an AI subsystem, and an AI task executor.
[0189] The system framework may include an application programming interface (API) provided by the operating system or application of the electronic device, which can obtain or view the device status (or device status level) of the electronic device and the running status of the application. Applications, services, or modules in the electronic device can obtain the device status (or device status level) of the electronic device, the running status of the application, or the operating frequency level through the API provided by the system framework.
[0190] The scheduling management service can be used to establish and maintain (eg, update, destroy, etc.) sessions, and can also determine the QoS level of the session corresponding to the application based on the application's running state (or the application's running state and the device state of the electronic device).
[0191] In some embodiments, the scheduling management service can respond to the call of the AI assistant, establish a session associated with the business to be performed by the AI assistant, configure a globally unique SID for the established session, and establish an association between the configured SID and the identifier of the entity (such as an application, process, thread or service, etc., hereinafter referred to as the initiator) that calls the AI business provided by the AI assistant (hereinafter referred to as the initiator identifier).
[0192] For example, reference Figure 3B In step ①, upon detecting that a call application's call process has invoked the Chinese-English translation AI kit, the Chinese-English translation AI kit can invoke the session establishment API provided by the scheduling management service. In response to the invocation of the Chinese-English translation AI kit, the scheduling management service can establish session S1 corresponding to the Chinese-English translation service and send a session identifier SID1 of session S1 to the Chinese-English translation AI kit.
[0193] Continue to refer Figure 3B In ①, for the Chinese-English translation service, 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 (eg, PID1) of the call process and SID1.
[0194] It should be noted that the initiator identifier is an arbitrary identifier used to indicate the initiator of a service call. 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 in the application that calls the service, or the thread identification (TID) of the thread in the application that calls the service. For another example, when a service calls a service, the initiator identifier can be the name of the service, or the PID of the process in the service that calls the service, or the TID of the thread.
[0195] In some embodiments, based on the association between the initiator identifier and the SID, the scheduling management service can also destroy the sessions corresponding to all or part of the SID corresponding to the initiator identifier when the initiator (process, thread, application, service, etc.) corresponding to the initiator identifier stops running.
[0196] 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 may 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, the process or thread of the application. The scheduling management service may then send the one or more SIDs and the determined QoS level to the CPU scheduler, the AI business management service in the AI subsystem, and the AI task executor.
[0197] For example, reference Figure 3B In ⑤, 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, and then send the initial QoS level and SID1 to the CPU scheduler, the AI business management service in the AI subsystem, and the AI task executor.
[0198] For example, refer to Figure 3B In ⑦ and ⑧, the scheduling management service can determine the current QoS level when it detects the running status of the call application and / or the device status change 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, and then send the current QoS level and SID1 to the CPU scheduler, the AI business management service in the AI subsystem, and the AI task executor.
[0199] For example, in Figure 3BIn the case where the initiator identifier of session S0 (session identifier is SID0) is also PID1, or the package name of the call application, the scheduling management service can also send the initial QoS level and SID0 to the CPU scheduler, the AI business management service and the AI task executor in the AI subsystem after determining the initial QoS level, or send the current QoS level and SID0 to the CPU scheduler, the AI business management service and the AI task executor in the AI subsystem after determining the current QoS level. The AI assistant may include one or more AI kits (such as a Chinese-English translation AI kit) to provide the application / service / module in the electronic device with the ability to call AI services. The AI kit can provide a calling interface to the application so that the application calls the AI kit to execute related AI services, establish an AI task corresponding to the AI service based on the call of the application, send the AI task to the AI subsystem and obtain the execution result of the AI task from the AI subsystem, and send the execution result of the AI task to the application.
[0200] In some embodiments, the AI kit can, in response to an application call, establish a session corresponding to the service associated with the AI kit through the scheduling management service, obtain the SID of the established session, associate the SID with the task corresponding to the service, and send the association to the AI subsystem (for example, sending the AI task corresponding to the service and the SID of the established session together to the AI subsystem). The AI kit can also destroy the session corresponding to the service after the service execution is completed.
[0201] For example, reference Figure 3B In ①, the Chinese-English translation AI kit can respond to the call of the call application, establish a session S1 corresponding to the Chinese-English translation service through the scheduling management service, and obtain the session identifier SID1 of the session S1.
[0202] For example, refer to Figure 3B In ②, after obtaining the session identifier SID1 of session S1, the Chinese-English translation AI kit can call the AI business management service to establish task 01 corresponding to the Chinese-English translation business and configure the session identifier SID1 for task 01.
[0203] For example, refer to Figure 3B In ⑥, the Chinese-English translation AI kit can destroy session S1 after the Chinese-English translation service is completed.
[0204] The AI subsystem may include AI business management services and NPU interfaces.
[0205] The AI business management service is used to receive AI tasks and the SID corresponding to the AI tasks from the AI kit in the AI assistant, collaborate with the CPU scheduler to establish an association between the SID and the thread associated with the AI task in the AI business management service, send the AI task and the SID corresponding to the AI task to the AI task executor through the NPU interface, obtain the execution results of the AI task from the AI task executor and send the execution results to the corresponding AI kit in the AI assistant.
[0206] For example, reference Figure 3B In ③, after Task 01 is established, the AI business management service can determine one or more threads associated with Task 01 (for example, the Chinese-English translation execution thread, whose TID is TID1) and establish an association between SID1, Task 01, and the thread associated with Task 01 in the AI business management service (the Chinese-English translation execution thread or TID1). For example, the AI business management service can store the association between Task 01 and SID1, send the association between TID1 and SID1 to the CPU scheduler, and send the association between Task 01 and SID1 to the AI task executor.
[0207] The AI business management service can also be used to convert the QoS level sent by the scheduling management service into a task priority defined by the NPU (hereinafter referred to as the NPU task priority), such as the task priority P1' to the task priority P4' shown in the task priority of the second processor in Table 5, and distribute the AI task to the AI task executor based on the converted NPU task priority. Alternatively, the AI business management service can also be used to convert the QoS level sent by the scheduling management service into a distribution priority (such as the distribution priority DP1 to the distribution priority DP5 shown in Table 5), and distribute the AI task to the AI task executor based on the converted distribution priority.
[0208] For example, reference Figure 3B ⑤, 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 task 01 corresponding to SID1 to the AI task executor based on the converted NPU task priority (or distribution priority).
[0209] For example, refer to Figure 3C In 9, after receiving the current QoS level and SID1, the AI business management service can convert the current QoS level into the 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).
[0210] The NPU interface is used to implement communication between the AI business management service and the AI task executor.
[0211] The AI task executor is used to call the NPU to execute the AI task based on the NPU task priority corresponding to the AI task and the NPU operating frequency of the core running the AI task, and send the execution result of the AI task to the AI business management service through the NPU interface. Exemplarily, the AI task executor can convert the QoS level sent by the scheduling management service into the NPU task priority and the NPU operating frequency. Then, the AI task executor can schedule the AI task based on the converted NPU task priority; and / or, the AI task executor can configure the operating frequency of the core used to execute different AI tasks based on the converted NPU operating frequency.
[0212] For example, reference Figure 3B In step 4, after receiving Task 01, the AI task executor can run one or more threads associated with Task 01 (e.g., a data transmission thread whose session identifier is TID2) and establish an 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.
[0213] 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. The AI task executor can then schedule Task 01 corresponding to SID1 based on the converted NPU task priority and configure the operating frequency of the core in the NPU used to run Task 01 based on the converted NPU operating frequency.
[0214] For example, refer to Figure 3C In step 9, after 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. The AI task executor can then schedule Task 01 corresponding to SID1 based on the converted NPU task priority and configure the operating frequency of the core in the NPU used to run Task 01 based on the converted NPU operating frequency.
[0215] The CPU scheduler is used to schedule the priorities of threads and processes running on the CPU and to configure the operating frequency of the CPU core.
[0216] In some embodiments, the CPU scheduler can establish an association relationship between the thread associated with the AI task in the AI business management service and the corresponding SID by interacting with the AI business management service, or it can establish an association relationship between the thread associated with the AI task in the AI task executor (such as a data transmission thread) and the corresponding SID by interacting with the AI task executor.
[0217] For example, reference 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 an association between SID1 and TID1.
[0218] For example, refer to Figure 3B In ④, 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 an association relationship between SID1 and TID2.
[0219] In some embodiments, the CPU scheduler may also adjust the task priority of the thread corresponding to the SID and / or configure the operating frequency of the core 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 may obtain the CPU task priority (the priority of the thread or process defined by the CPU, such as the task priority P1 to task priority P5 shown in the task priority 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 may schedule the thread corresponding to the SID based on the obtained CPU task priority and configure the operating frequency of the core running the thread corresponding to the SID to the obtained CPU operating frequency.
[0220] 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 a CPU task priority and a CPU operating frequency. The CPU scheduler can then schedule the Chinese-English translation execution thread and data transmission thread corresponding to SID1 based on the converted CPU task priority, and configure the operating frequency of the CPU cores used to run the Chinese-English translation execution thread and data transmission thread based on the converted CPU operating frequency.
[0221] For example, refer to Figure 3CIn step 9, after receiving the current QoS level and SID1, the CPU scheduler can convert the current QoS level into a CPU task priority and a CPU operating frequency. The CPU scheduler can then schedule the Chinese-English translation execution thread and data transmission thread corresponding to SID1 based on the converted CPU task priority, and configure the operating frequency of the CPU cores used to run the Chinese-English translation execution thread and data transmission thread based on the converted CPU operating frequency.
[0222] The following combination Figures 3A to 3C The content shown introduces the interactive process of electronic devices performing Chinese-English translation services.
[0223] For example, Figure 4A According to some embodiments of the present application, a schematic diagram of an interactive process of an electronic device performing a Chinese-English translation service is shown. Figure 4A As shown, the process includes:
[0224] S401, the Chinese-English translation AI kit calls the scheduling management service to establish session S1.
[0225] The Chinese-English translation AI kit can respond to the call application's request to call the Chinese-English translation service through the call process, call the scheduling management service to establish a session S1 and obtain the SID1 corresponding to the session S1.
[0226] 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 call application's request to invoke the Chinese-English translation service through a call process. In response to the request to establish the session, the scheduling management service can establish session S1, determine a globally unique session identifier SID1 for session S1, and send 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 one service), avoiding inaccurate scheduling due to different sessions using the same SID.
[0227] In some embodiments, the SID1 generated by the scheduling management service may be random or generated based on a preset logic or algorithm.
[0228] In some embodiments, the SID1 generated by the scheduling management service can indicate the initiator. For example, part of the content of SID1 may include the package name of the call application, the PID of the call process, the package name code obtained by encoding the package name of the call application, the PID code obtained by encoding the PID of the call process, etc. The other part of the content may be randomly generated or generated based on preset logic or algorithm.
[0229] In some embodiments, the scheduling management service may further establish an association relationship between SID1 and the process identifier PID1 of the communication process.
[0230] S402: The scheduling management service determines an initial QoS level based on an initial operation state and / or an initial device state.
[0231] After session S1 is established, the scheduling management service may obtain the initial running state of the call application and / or the initial device state of the electronic device, and determine an initial QoS level based on the initial running state and / or the initial device state.
[0232] For example, the scheduling management service may 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 association between other device states, operating states, and QoS levels. For example, using Table 5 as an example, if the operating state of the call application is S1 and the device state level is DS1, the scheduling management service may determine the initial QoS level to be L1; if the operating state of the call application is S3 and the device state level is DS2, the scheduling management service may determine the initial QoS level to be L7.
[0233] S403, the Chinese-English translation AI kit calls the AI task management service based on SID1 to establish task 01.
[0234] After receiving SID1, the Chinese-English translation AI kit can call the AI task management service to create task 01 based on SID1.
[0235] For example, the Chinese-English translation AI kit can send a request to the AI task management service to create an AI task (the request can include SID1) based on the API provided by the AI task management service. The AI task management service can create Task 01 in response to the request and store the association between Task 01 and SID1.
[0236] S404: The AI task management service sends the association relationship between the Chinese-English translation execution thread and SID1 to the CPU scheduler.
[0237] After establishing Task 01, the AI Task Management Service determines the Chinese-English translation execution thread (for example, by creating a new one or configuring an existing one as the Chinese-English translation execution thread) and sends the thread identifiers TID1 and SID1 of the Chinese-English translation execution thread to the CPU scheduler. Accordingly, upon 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).
[0238] S405 , the CPU scheduler schedules the Chinese-English translation execution thread based on SID1 and the initial QoS level.
[0239] After receiving the association between the Chinese-English translation execution thread and SID1, the CPU scheduler may 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.
[0240] For example, when the initial QoS level is L1, the CPU scheduler can determine that the CPU task priority is P1 based on Table 5 and configure the CPU task priority of the Chinese-English translation execution thread to P1; and determine that the CPU operating frequency level is the highest frequency based on Table 5, and configure the operating frequency of the core in the CPU used to run the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "highest frequency".
[0241] For another example, when the initial QoS level is L7, the CPU scheduler can determine that the CPU task priority is P3 based on Table 5 and configure the CPU task priority of the Chinese-English translation execution thread to P3; and determine that the CPU operating frequency level is the lowest frequency based on Table 5, and configure the operating frequency of the core in the CPU used to run the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "lowest frequency".
[0242] 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 from the scheduling management service based on SID1 after the CPU scheduler receives the association between the Chinese-English translation execution thread and SID1, without limitation. 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.
[0243] S406 , the AI task management service sends task 01 and SID1 to the AI task executor based on the initial QoS level.
[0244] After establishing 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.
[0245] For example, when the initial QoS level is L1, the AI task management service can determine the NPU task priority as P1' based on Table 5 and configure the NPU task priority of Task 01 to P1', and distribute Task 01 to the AI task executor before 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 and configure the distribution priority of Task 01 to DP1, and distribute Task 01 to the AI task executor before other tasks with distribution priorities of DP2, DP3, and DP4.
[0246] For another example, when the initial QoS level is L7, the AI task management service can determine the NPU task priority as P3' based on Table 5 and configure the NPU task priority of Task 01 to P3', and distribute Task 01 to the AI task executor earlier than other tasks with NPU task priority P4' and later than other tasks with NPU task priority P2' or P3'. Alternatively, the AI task management service can determine the distribution priority as DP3 based on Table 6 and configure the distribution priority of Task 01 to DP3, and distribute Task 01 to the AI task executor earlier than other tasks with distribution priority DP4 and later than other tasks with distribution priority DP3 or DP4.
[0247] It should be noted that the execution order of S406, S404 and S405 can be swapped or executed in parallel, which is not limited here.
[0248] It should be noted that the initial QoS level can be sent by the Scheduling Management Service to the AI Task Management Service after executing S402, or it can be obtained from the Scheduling Management Service based on SID1 after the AI Task Management Service establishes Task 01, without limitation. For example, after establishing Task 01, 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.
[0249] S407 , the AI task executor sends the association relationship between the data transmission thread and SID1 to the CPU scheduler.
[0250] After receiving Task 01 and SID1, the AI task executor can determine the data transmission thread (for example, create a new data transmission thread or configure an existing thread as a data transmission thread). Then, the AI task executor can send the association relationship between the data transmission thread and SID1 to the CPU scheduler. For example, the AI task executor can send the thread identifier TID2 and SID1 of the data transmission thread to the CPU scheduler. After receiving TID2 and SID1, the CPU scheduler can store the association relationship between TID2 and SID1 (equivalent to the association relationship between the data transmission thread and SID1).
[0251] In some embodiments, after receiving task 01 and SID1, the AI task executor may store the association between task 01 and SID1.
[0252] In some embodiments, Task 01 may be split into multiple subtasks, and the task executor may associate SID1 with the multiple subtasks.
[0253] S408 , the AI task executor calls the NPU to execute task 01 based on SID1 and the initial QoS level.
[0254] After receiving Task 01, the AI Task Executor may 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.
[0255] For example, when the initial QoS level is L1, the AI task executor can determine that the NPU task priority is P1' based on Table 5 and configure the NPU task priority of task 01 to P1', and call the NPU to execute task 01 earlier than other tasks with NPU task priorities of P2', P3', and P4'; and determine that the NPU operating frequency level is the highest frequency based on Table 5, and reduce the operating frequency of the core in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "highest frequency".
[0256] For another example, when the initial QoS level is L7, the AI task executor can determine that the NPU task priority is P3' based on Table 5 and configure the NPU task priority of task 01 to P3', and call the NPU to execute task 01 earlier than other tasks with NPU task priority P4'; and determine that the NPU operating frequency level is the lowest frequency based on Table 5, and reduce the operating frequency of the core in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "lowest frequency".
[0257] 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, without limitation. 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.
[0258] S409 , the CPU scheduler schedules the data transmission thread based on SID1 and the initial QoS level.
[0259] After receiving the association between the data transmission thread and SID1, the CPU scheduler may schedule the data transmission thread and the Chinese-English translation execution thread based on SID1 and the initial QoS level.
[0260] For example, when the initial QoS level is L1, the CPU scheduler can determine that the CPU task priority is P1 based on Table 5 and configure the CPU task priority of the data transmission thread to P1; and determine that the CPU operating frequency level is the highest frequency based on Table 5, and configure the operating frequency of the core in the CPU used to run the data transmission thread to the operating frequency corresponding to the operating frequency level "highest frequency".
[0261] For another example, when the initial QoS level is L7, the CPU scheduler can determine that the CPU task priority is P3 based on Table 5 and configure the CPU task priority of the data transmission thread to P3; and determine that the CPU operating frequency level is the lowest frequency based on Table 5, and configure the operating frequency of the core in the CPU used to run the data transmission thread to the operating frequency corresponding to the operating frequency level "lowest frequency".
[0262] It should be noted that S409 may be executed before S408 or in parallel with S408, which is not limited here.
[0263] It should be noted that after session S1, task 01, data transmission thread and Chinese-English translation execution thread are established, the electronic device can implement the Chinese-English translation service based on session S1, task 01, data transmission thread and Chinese-English translation execution thread. In the process of implementing the Chinese-English translation service, the electronic device can schedule task 01, data transmission thread and Chinese-English translation execution thread based on the device state of the electronic device and the running state of the call application. For example, when the device state of the electronic device is the initial device state and the running state of the call application is the initial running state, the electronic device can implement the Chinese-English translation service by repeatedly executing the following S410 to S412C.
[0264] 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 obtained by the CPU scheduler in S405, or obtained from the scheduling management service after receiving the association between the data transmission thread and SID1. There is no limitation here.
[0265] S410, the Chinese-English translation AI kit sends input data and SID1 to the AI task management service.
[0266] After obtaining the input data passed by the call application (such as the Chinese voice of user A and the English voice of user B), the Chinese-English translation AI kit can send the input data and SID1 to the AI task management service.
[0267] For example, every time the electronic device collects a Chinese voice clip from user A, the call application can send the Chinese voice clip from user A to the Chinese-English translation AI kit. The Chinese-English translation AI kit can then send the Chinese voice clip from user A to the AI task management service.
[0268] For another example, every time the electronic device receives an English voice clip from user B, the call application can send the English voice clip from user B to the Chinese-English translation AI kit. The Chinese-English translation AI kit can send the voice clip and SID1 sent by the call application to the AI task management service.
[0269] S411: The AI task management service verifies SID1 with the Chinese-English translation AI kit.
[0270] After receiving the input data and SID1, the AI task management service may verify SID1, for example, to verify whether SID1 is the session identifier of the session corresponding to the application that provided the input data.
[0271] 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.
[0272] S412A, the AI task management service distributes task 01 based on SID1 and the initial QoS level.
[0273] After receiving the input data and SID1 (for example, after SID1 passes verification D), the AI task management service can distribute task 01 based on SID1 and the initial QoS level. For details, please refer to S406 and will not be repeated here.
[0274] S412B, the AI task executor calls the NPU to execute task 01 based on SID1 and the initial QoS level.
[0275] After receiving Task 01 distributed by the AI Task Management Service, the AI Task Executor can call the NPU to execute Task 01 based on SID1 and the initial QoS level. For details, please refer to S408 and will not be repeated here.
[0276] In S412C, the CPU scheduler schedules the data transmission thread and the Chinese-English translation execution thread based on SID1 and the initial QoS level.
[0277] When the CPU scheduler does not receive a QoS level corresponding to SID1 and 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 repeated here.
[0278] In some embodiments, when the call ends (e.g., user A hangs up the call or user B hangs up the call), or when task 01 is completed (e.g., user A stops the Chinese-English translation function), the electronic device can destroy session S1. For example, the electronic device can destroy session S1 based on S413 and / or S413' as follows.
[0279] In step S413 , the Chinese-English translation AI kit responds to the call ending / task 01 completion by destroying session S1 .
[0280] In some embodiments, the Chinese-English translation AI kit destroys session S1 in response to the call ending / task 01 being completed.
[0281] S413': In response to the call process stopping, the scheduling management service destroys the session S1.
[0282] In some embodiments, if a call process stops running, the scheduling management service can determine SID1 associated with the call process based on its process identifier PID1. The scheduling management service can then destroy session S1 if the session corresponding to SID1 has not been destroyed. This prevents resource waste caused by the Chinese-English translation AI kit failing to successfully destroy session S1.
[0283] based on Figure 4A According to the method shown, the electronic device can schedule task 01, data transmission thread and Chinese-English translation execution thread to implement Chinese-English translation service based on the operating status of the electronic device and the initial QoS level corresponding to the initial operating status of the call application, which can avoid the electronic device from being unable to respond to the Chinese-English translation service in a timely manner or wasting resources.
[0284] In some embodiments, in the process of implementing 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.
[0285] For example, Figure 4B According to some embodiments of the present application, a schematic diagram of an interaction process in which another electronic device performs a Chinese-English translation service is shown.
[0286] like Figure 4B As shown, the process includes S401 to S409, S415 to S419. Among them, S401 to S409 can refer to Figure 4A The contents of S401 to S409 are not described here. Figure 4A The embodiments shown are different from S414 to S416C:
[0287] S414: The scheduling management service detects a change in the device status and / or a change in the running status of the call application, and determines the current QoS level.
[0288] The scheduling management service may periodically or non-weekly obtain the current device state of the electronic device and / or the current running state of the call application. Upon detecting a change in the device state and / or the running state of the call application, the scheduling management service may determine a current QoS level corresponding to the current running state and / or the current device state based on either Table 4 or Table 5, or based on other associations between device states, running states, and QoS levels.
[0289] After session S1 is established, the scheduling management service may obtain the current operating state of the call application and / or the current device state of the electronic device, and determine the current QoS level based on the current operating state and / or current device state. For example, the scheduling management service may determine the current QoS level corresponding to the current operating state and / or current device state based on Table 4 or Table 5, or based on other associations between device states, operating states, and QoS levels.
[0290] For example, taking Table 5 as an example, when the initial running state is S1 and the initial device status level is DS1, the scheduling management service can determine that the current QoS level is L2 when the current running state of the call application is S2 (for example, the call application switches to background operation and is user-perceivable) and the current device status is DS1.
[0291] For another example, taking Table 5 as an example, when the initial running state is S1 and the initial device status level is DS1, the scheduling management service can determine that the current QoS level is L5 when the current running state of the call application is S1 (for example, the call application remains running in the foreground and is in focus) and the current device status is DS2.
[0292] 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.
[0293] After determining the current QoS level, the scheduling management service may send SID1 and the current QoS level to the AI task management service, the AI task executor, and the CPU scheduler.
[0294] S416A, the AI task management service distributes task 01 based on SID1 and the current QoS level.
[0295] After receiving the current QoS level, the AI task management service may distribute task 01 based on SID1 and the current QoS level.
[0296] For example, when the initial QoS level is L1 and the current QoS level is 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 to P2', and distribute Task 01 to the AI task executor before other tasks with NPU task priorities of P3' and P4'. Alternatively, the AI task management service can also determine the distribution priority corresponding to the QoS level L2 as DP2 based on Table 6 and configure the distribution priority of Task 01 to DP2, and distribute Task 01 to the AI task executor before other tasks with distribution priorities of DP3 and DP4.
[0297] For another example, when the initial QoS level is L1 and the current QoS level is 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 at P1', and distribute Task 01 to the AI task executor before 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 at DP1, and distribute Task 01 to the AI task executor before other tasks with distribution priorities of DP2, DP3, and DP4.
[0298] S416B, the AI task executor calls the NPU to execute task 01 based on SID1 and the current QoS level.
[0299] After receiving the current QoS level, the AI task executor can call the NPU to execute task 01 based on SID1 and the current QoS level.
[0300] For example, when the initial QoS level is L1 and the current QoS level is L2, the AI task management service can determine that the NPU task priority is P2' based on Table 5 and configure the NPU task priority of task 01 to P2', and call the NPU to execute task 01 earlier than other tasks with NPU task priorities of P3' and P4'; and determine that the NPU operating frequency level is high frequency based on Table 5, and reduce the operating frequency of the core in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "high frequency".
[0301] For another example, when the initial QoS level is L1 and the current QoS level is L5, the AI task executor can determine that the NPU task priority is 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 that the NPU operating frequency level is medium frequency based on Table 5, and reduce the operating frequency of the core in the NPU used to execute task 01 to the operating frequency corresponding to the operating frequency level "medium frequency".
[0302] In S416C, the CPU scheduler schedules the data transmission thread and the Chinese-English translation execution thread based on SID1 and the current QoS level.
[0303] After 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.
[0304] For example, when the initial QoS level is L1 and the current QoS level is L2, the CPU scheduler can determine that the CPU task priority is P2 based on Table 5 and reduce the CPU task priority of the data transmission thread and the Chinese-English translation execution thread to P2; and determine that the CPU operating frequency level is high frequency based on Table 5, and reduce the operating frequency of the core in the CPU used to run the data transmission thread and the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "high frequency".
[0305] For another example, when the initial QoS level is L1 and the current QoS level is L5, the CPU scheduler can determine that the CPU task priority is P1 based on Table 5 and keep the CPU task priority configuration of the data transmission thread and the Chinese-English translation execution thread as P1; and determine that the CPU operating frequency level is medium frequency based on Table 5, and reduce the operating frequency of the core in the CPU used to run the data transmission thread and the Chinese-English translation execution thread to the operating frequency corresponding to the operating frequency level "medium frequency".
[0306] based on Figure 4A and Figure 4B In the illustrated embodiment, the electronic device can dynamically configure the task priority of CPU threads, the operating frequency of the CPU core, the task priority of tasks in the NPU, the operating frequency of the NPU core, etc. based on the device state of the electronic device and the running state of the application program in the electronic device. In this way, service execution delays or resource waste caused by mismatches in task priority between the CPU and NPU and / or mismatches in core frequency between the CPU and NPU for the same service can be avoided.
[0307] Next, a task scheduling method applied to electronic equipment is introduced.
[0308] For example, Figure 5 According to some embodiments of the present application, a flowchart of a task scheduling method is shown. The execution subject of the method is an electronic device, such as Figure 5 As shown, the method includes:
[0309] S501: Run a first application through a first processor of an electronic device, and the running state of the first application is a first running state.
[0310] For example, the first processor may be a CPU of an electronic device, and the electronic device may run the first application through the CPU.
[0311] 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 may be any one of the multiple running states. For example, the running state of the first application may include states ST1 to state ST4, or state ST5 and state ST6, or state ST5, state ST3, state ST4, or state ST1, state ST2, and state ST6, etc.
[0312] S502, detecting a request from a 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 priority of the first task in the second processor is a first priority, and the operating frequency of at least one core in the second processor for running the first task is a first operating frequency.
[0313] When the electronic device detects a request from the first application to invoke the first service, the electronic device may execute the first task corresponding to the first service through the second processor of the electronic device. The first service may be a service in which at least part of the task (eg, the first task) is executed by the second processor.
[0314] It should be noted that the first processor and the second processor can be any processor, including but not limited to a CPU, an NPU, a GPU, an image signal processor (ISP), a microcontroller unit (MCU), a digital signal processor (DSP), a field programmable gate array (FPGA), an application-specific integrated circuit (such as an input / output controller, a power management chip, a memory controller, a security chip, a display driver chip, and other processors used to implement specific functions or handle specific tasks), etc. The embodiments of the present application do not limit the specific forms of the first processor and the second processor.
[0315] It should be noted that the first processor and the second processor can be independent devices or integrated into the same device (for example, integrated into a system on chip (SoC), etc.). The embodiments of the present application do not limit the packaging form of the first processor and the second processor.
[0316] In some embodiments, when the second processor is an NPU, the first business can be any business that requires AI reasoning or AI training based on an AI model through the NPU; when the second processor is a GPU, the first business can be any business that requires graphics processing or AI reasoning, AI training through the GPU (such as text call business, Chinese-English translation business, AI answering business, anti-fraud detection business, other businesses that call the NPU for image processing / audio processing / text processing, etc.); when the second processor is an ISP, the first business can be any business that requires the ISP to perform image signal processing; when the second processor is a security chip, the first business can be a security verification task; when the second processor is an input and output controller, the first business can be a data access business; when the second processor is a display driver chip, the first business can be a business that refreshes image data to the display screen. The embodiment of the present application does not limit the specific form of the first business. Among them, the AI model can be any model that needs to be run through the NPU, including but not limited to neural network models, deep learning models, large models, etc.
[0317] In some embodiments, while the second processor is executing the first task corresponding to the first business, the first processor may also execute the second task corresponding to the first business. The electronic device may also configure the CPU task priority of the second task to a third priority matching the first running state based on the first running state, and / or configure the operating frequency of one or more cores in the first processor for running the second task to a third operating frequency, and / or the first processor distributes the first task to the second processor based on the third priority (for example, the AI business management service may distribute the task to the AI executor based on the CPU task priority corresponding to the initial QoS level). For example, for Figures 3A to 4B In the illustrated embodiment, the first service may be a Chinese-English translation service, the first task corresponding to the Chinese-English translation service may be task 10, the second task may include a Chinese-English translation execution thread and a data transmission thread, and the first processor may be a CPU of the electronic device.
[0318] In some embodiments, when the electronic device detects a request from a first application to call a first service, it can establish a first association relationship between the first application and the first task of the first service; or when there is a second task of the first service run by the first processor, it can establish a second association relationship between the first application, the first task, and the second task.
[0319] In some embodiments, the electronic device may determine the initial QoS level based on the first running state of the first application (and / or the device state of the electronic device). Then, the electronic device may determine the first task associated with the first application based on the first association relationship, and configure the task priority of the first task to the first priority that matches 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 match the initial QoS level as the first operating frequency. Alternatively, the electronic device may also determine the first task and the second task associated with the first application based on the second association relationship, and configure the task priority of the first task to the first priority that matches the initial QoS level based on the initial QoS level, configure the priority of the second task to the third priority that matches 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 match the initial QoS level as the first operating frequency, and configure the operating frequency of at least one core in the first processor used to run the second task to match the initial QoS level as the third operating frequency. For details, please refer to Figure 3B The contents of ⑤, S402 to S409, S412A to S412C are not repeated here.
[0320] It should be noted that the electronic device can determine the first operating frequency, the third operating frequency, the first priority, and the third priority based on the initial QoS level, the association between the QoS level and the operating frequency, and the association between the QoS level and the priority (for example, the association shown in Table 4 and Table 5).
[0321] It should be noted that the electronic device can determine the first priority corresponding to the first operating state based on the association between the operating state and the distribution priority, or the association between the operating state, device status level and the distribution priority, or the association between the QoS level and the distribution priority (for example, the association shown in Table 6).
[0322] In some embodiments, the first association relationship and the second association relationship may be established based on a session.
[0323] For example, in response to a first application invoking a first service, the electronic device may establish a first session with a first session identifier. Based on this, the first association relationship may include an association relationship between the first session identifier and the first application (e.g., the package name, process PID, thread TID (as an initiator identifier) of the first application), and an association relationship between the first session identifier and the first task.
[0324] For another example, the electronic device may establish a second session with a second session identifier in response to the first application invoking the first service. Based on this, the second association relationship may include an association relationship 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), an association relationship between the second session identifier and the second task (e.g., the TID or other identifier corresponding to the second task), and an association relationship between the second session identifier and the first task.
[0325] For example, for Figures 3A to 4B In the case shown, the second association relationship can be the association relationship between the session identifier SID1 of session S1, the thread identifier (TID1) of the Chinese-English translation execution thread and the thread identifier (TID2) of the data transmission thread (the Chinese-English translation execution thread and the data transmission thread serve as the second task), and task 01 (serving as the first task). The establishment method of the second association relationship can refer to Figure 3B The contents of S401 to S407 are not described in detail here.
[0326] In some embodiments, the initial QoS level may be determined based on the initial device state of the first electronic device and the first running state of the first application, by an association between the device state, the running state of the application, and the QoS level (e.g., the association shown in Table 4 or Table 5). For details, please refer to the content of S402 and will not be repeated here.
[0327] In some embodiments, the priority of the first task on the second processor may be a task priority. For example, the priority of the first task on the second processor may include the priority of the second processor's corresponding driver or management service (e.g., AI task executor) to directly pass the first task to the second processor, or the priority of the second processor to actually execute the first task.
[0328] In some embodiments, the first task is sent by a first functional unit (such as an AI business management service) run by a first processor of an electronic device to a second functional unit (such as an AI task executor), and then distributed by the second functional unit to the second processor. When the running state of the first application is the first running state, the first functional unit may distribute the first task to the second functional unit based on the first distribution priority corresponding to the first running state. For details, please refer to the content of S406, which will not be repeated here.
[0329] It should be noted that the electronic device can determine the first priority and the third priority based on the association between the operating status and the task priority (for example, the association shown in Table 1), or determine the first priority and the third priority based on the association between the operating status, the device status level and the task priority (for example, the association shown in Table 3).
[0330] It should be noted that the electronic device can determine the first operating frequency and the third operating frequency based on the association between the operating status and the core operating frequency (for example, the association shown in Table 2), or determine the first priority and the third priority based on the association between the operating status, the device status level and the core operating frequency (for example, the association shown in Table 3).
[0331] S503, detecting that the running state of the first application switches from the first running state to the second running state, and scheduling the first business, 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.
[0332] 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 may schedule the first service based on the second running state. For example, the electronic device may adjust 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 adjust the operating frequency of at least one core from the first operating frequency to the second operating frequency matching the second running state.
[0333] In some embodiments, the electronic device may detect that the running state of the first application is switched from the first running state to the second running state when detecting a first operation of the user to switch the running state of the first application from the first running state to the second running state.
[0334] It should be noted that the first operation can be any operation that can switch the running state of the first application. The first operation can act on the window of the first application or on the windows of other applications, or the first operation can also be an air gesture, voice operation, etc. For example, when the first operation is an operation in which the user clicks on the window of the first application, the second running state can be state ST1; when the first operation is an operation in which the user clicks on other areas outside the window of the first application in the display interface of the electronic device, the second running state can be state ST3; when the first operation is an operation in which the user switches the first application from the foreground to the background, and the user cannot perceive the first application, the second running state can be state ST4; when the first operation is an operation in which the user switches the first application from the foreground to the background, and the user can perceive the first application, the second running state can be state ST2.
[0335] In some embodiments, when a second task of the first service is also running on the first processor, the scheduling process may further include: adjusting the priority of the second task on the first processor from the third priority to a fourth priority matching the second operating state, wherein the relationship between the third priority and the fourth priority is the same as the relationship between the first priority and the second priority; and / or adjusting the operating frequency of one or more cores from the third operating frequency to a fourth operating frequency matching the second operating state, wherein the relationship between the third operating frequency and the fourth operating frequency is the same as the relationship between the first operating frequency and the second operating frequency.
[0336] 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 circumstances: the first running state is foreground running and is in focus, the second running state is foreground running and not in focus, background running and user-perceivable, or background running and user-imperceivable; or, the first running state is foreground running and not in focus, the second running state is background running and user-perceivable, or background running and user-imperceivable; or, the first running state is background running and user-perceivable, the second running state is background running and user-imperceivable; or, the first running state is background running and user-perceivable, the second running state is background running and user-imperceivable; or, the first running state is foreground running, and the second running state is background running.
[0337] 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 circumstances: the first running state is running in the background and is not perceptible to the user, and the second running state is running in the foreground and is in focus, running in the foreground and is not in focus, or running in the background and is perceptible to the user; or, the first running state is running in the background and is perceptible to the user, and the second running state is running in the foreground and is in focus or running in the foreground and is not in focus; or, the first running state is running in the foreground and is not in focus, and the second running state is running in the foreground and is in focus; or, the first running state is running in the background and is perceptible to the user.
[0338] In some embodiments, the electronic device may determine the second QoS level based on the second operating state of the first application (and / or the device state of the electronic device). Then, the electronic device may determine the first task associated with the first application based on the first association relationship, and adjust the task priority of the first task from the first priority to the 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 the first operating frequency to the second operating frequency matching the second QoS level. For details, please refer to the contents of S414 to S416C, which will not be repeated here.
[0339] In some embodiments, the electronic device may determine the second QoS level based on the second operating state of the first application (and / or the device state of the electronic device). Then, the electronic device may determine the first task and the second task associated with the first application based on the second association relationship, and adjust the task priority of the first task from the first priority to the second priority matching the second QoS level based on the initial QoS level, adjust the priority of the second task from the third priority to the fourth priority matching the second QoS level, and / or adjust the operating frequency of at least one core of the second processor used to run the first task from the first operating frequency to the second operating frequency matching the second QoS level, and adjust the operating frequency of one or more cores of the first processor used to run the second task from the third operating frequency to the fourth operating frequency matching the first QoS level. For details, please refer to the contents of S414 to S416C, which will not be repeated here.
[0340] For example, when the second association relationship includes the second session identifier of the second session, the first application (such as 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 (such as the PID of the second task), and the association relationship between the first tasks, 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 relationship, 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 relationship between the QoS level and the operating frequency (such as the association relationship shown in the second, fourth, and sixth columns of Table 4, or the association relationship shown in the third, fifth, and seventh columns of Table 5), and the association relationship between the QoS level and the task priority (such as the association relationship shown in the second, third, and fifth columns of Table 4, or the association relationship shown in the third, fourth, and sixth columns 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 task from the first processor to the second processor to the fourth priority, and / or configure the operating frequency of at least one core in the second processor for running the first task to the second operating frequency, and configure the operating frequency of one or more cores in the first processor for running the second task to the fourth operating frequency.
[0341] For example, Figures 3A to 4B Taking the situation shown as an example, the second running state may be the current running state. After determining the current running state, the scheduling management service may obtain the second session identifier (session identifier SID1 corresponding to session S1) based on the process identifier PID1 of the communication process. Then, the scheduling management service may send the current running state to the AI business management service, the AI task executor, and the CPU scheduler. Secondly, the AI business management service and the AI task executor may schedule task 01 (as the first task) based on the current running state, and the CPU scheduler may 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 contents of S414 to S416C, which will not be elaborated here.
[0342] In some embodiments, after the first service is completed, or the first application stops running, or the process / thread in the first application that calls the first service ends running, the electronic device can delete the first association and the second association, or destroy the first session and the second session. This can avoid maintaining the first association and the second association and occupying resources. For details, please refer to S413 and S413', which will not be repeated here.
[0343] It should be noted that, in other embodiments, when the first business also includes one or more tasks executed by one or more other processors, the electronic device may also configure the priority of the one or more tasks on the one or more other processors to a priority that matches the first operating state, and / or configure the operating frequency of the core running the one or more tasks in the one or more processors to match the first operating state, when the operating state of the first application is the first operating state. After the operating state of the first application is adjusted to the second operating state, the electronic device may also configure the priority of the one or more tasks on the one or more other processors to a priority that matches the second operating state, and / or configure the operating frequency of the core running the one or more tasks in the one or more processors to match the second operating state. For details, please refer to the content of configuring the priority of the first task in the second processor and the operating frequency of the core running the first task in the second processor by the electronic device, which will not be repeated here.
[0344] pass Figure 5 In the method shown, the electronic device can synchronously schedule a first task on the second processor corresponding to a first service, and a second task on the first processor corresponding to the first service, based on the running state of the first application and / or the device state. This can avoid untimely response to the first service or waste of resources due to a mismatch in task priority or dispatch priority between the first task and the second task, and / or a mismatch in operating frequency between the core executing the first task and the core running the second task.
[0345] Below, the technical solution of this application is introduced by taking the first running state as foreground running and the second state as background running as an example.
[0346] For example, Figure 6 According to some embodiments of the present application, a flowchart of a task scheduling method is shown. The execution subject of the method is an electronic device, such as Figure 6 As shown, the method includes the following steps:
[0347] S601: Run a first application through a first processor of an electronic device, and the running state of the first application is foreground running.
[0348] S602, detecting a request from a first application to call a first service, executing a first task included in the first service through a second processor of the electronic device, wherein the priority of the first task in the second processor is a first priority, and the operating frequency of at least one core in the second processor for running the first task is a first operating frequency.
[0349] It should be noted that the specific forms of the first service, the first task, the first processor, the second processor, and the method for determining the first priority and the first operating frequency can be referred to the content of the aforementioned S502 and will not be repeated here.
[0350] In some embodiments, the first business also includes a second task executed by the first processor. When the running state of the first application is foreground running, the priority of the second task on the first processor is the third priority, and the operating frequency of one or more cores of the first processor used to execute the second task is the third operating frequency.
[0351] In some embodiments, when the running state of the first application is foreground running, the electronic device distributes the first task to the second processor based on the first priority.
[0352] 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 the first task to the second functional unit, and the second functional unit is used to distribute the first task to the second processor, and when the running state of the first application is foreground running, the first functional unit distributes the first task to the second functional unit based on a first distribution priority. For example, if the first service is the aforementioned Chinese-English translation service or other AI service, the first functional unit can be an AI service management service and the second functional unit can be an AI task executor.
[0353] 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.
[0354] Exemplarily, when the foreground is running as the aforementioned ST1 (or when the foreground is running as the aforementioned ST1 and the device status level is the aforementioned DS1 or DS2): based on Table 1 or Table 3 or Table 4 or Table 5, the priority of the first task on the second processor may be task priority P1' (first priority), and the priority of the second task on the first processor may be task priority P1 (third priority). When the foreground is running as the aforementioned ST3 (or when the foreground is running as the aforementioned ST3 and the device status level is the aforementioned DS1 or DS2): based on Table 1 or Table 3 or Table 4 or Table 5, the priority of the first task on the second processor may be task priority P3' (first priority), and the priority of the second task on the first processor may be task priority P3 (third priority).
[0355] Exemplarily, 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 (first operating frequency) corresponding to the core operating frequency level "highest frequency", and the operating frequency of one or more cores running the second task in the first processor is the operating frequency (third operating frequency) corresponding to the core operating frequency level "highest frequency". When the foreground is running in the aforementioned 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 (first operating frequency) corresponding to the core operating frequency level "highest frequency", and the operating frequency of one or more cores running the second task in the first processor is the operating frequency (third operating frequency) corresponding to the core operating frequency level "highest 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 (first operating frequency) corresponding to the core operating frequency level "medium frequency", and the operating frequency of one or more cores running the second task in the first processor is the operating frequency (third operating frequency) corresponding to the core operating frequency level "medium".
[0356] For example, when the foreground is in the aforementioned state ST1, based on Table 6, the first dispatch priority may be dispatch priority DP1; in this case, the first functional unit may dispatch the first task to the second functional unit based on dispatch priority DP1. When the foreground is in the aforementioned state ST3, based on Table 6, the first dispatch priority may be dispatch priority DP3; in this case, the first functional unit may dispatch the first task to the second functional unit based on dispatch priority DP3.
[0357] 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, first operating frequency / first operating frequency, and first distribution priority based on the association between the QoS level and the task priority, core operating frequency, and distribution priority. For details, please refer to the aforementioned S501, Tables 1 to 6, and the contents of S402, S405, S406, S408, and S409, which will not be repeated here.
[0358] S603, detecting that the running state of the first application is switched from foreground running to background running, and scheduling the first business, 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.
[0359] In some embodiments, the first service also includes a second task executed by the first processor. When the first application is 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. In this case, the scheduling process further includes: adjusting the priority of the second task on the first processor from the third priority to a fourth priority; and / or adjusting the operating frequency of one or more cores from the third operating frequency to the fourth operating frequency.
[0360] In some embodiments, when the running status of the first application is foreground running, the electronic device distributes the first task to the second processor based on the first priority; and the scheduling process also includes: adjusting the priority of the electronic device in distributing the first task to the second processor from the first priority to the second priority.
[0361] 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 the first task to the second functional unit, and the second functional unit is used to distribute the first task to the second processor, and when the running state of the first application is foreground running, the first functional unit distributes the first task to the second functional unit based on the first distribution priority; and the scheduling processing also includes: distributing the first task to the second functional unit based on the second distribution priority through the first functional unit.
[0362] 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.
[0363] For example, when the foreground is running as ST1 and the background is running as ST2, 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, based on Table 2 or Table 4, the electronic device can adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the core operating frequency level "highest 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 "highest frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "high frequency" (second operating frequency). And / or, based on Table 6, the electronic device can adjust the distribution priority of the first task from the first functional unit to the second functional unit from the distribution priority DP1 (first distribution priority) to the distribution priority DP2 (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.
[0364] For example, when the foreground is running as ST3 and the background is running as ST4, 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, based on Table 2 or Table 4, the electronic device can 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, based on Table 6, the electronic device can adjust the distribution priority of the first task from the first functional unit to the second functional unit from the distribution priority DP3 (first distribution priority) to the 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.
[0365] For example, when the foreground is running as ST1 and the background is running as ST4, 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, based on Table 2 or Table 4, the electronic device can adjust the operating frequency of at least one core running the first task from the operating frequency corresponding to the core operating frequency level "highest 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 "highest frequency" (first operating frequency) to the operating frequency corresponding to the core operating frequency level "lowest frequency" (second operating frequency). And / or, based on Table 6, the electronic device can adjust the distribution priority of the first task from the first functional unit to the second functional unit from the distribution priority DP1 (first distribution priority) to the 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.
[0366] For example, when the foreground is running as ST3 and the background is running as ST2, 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, based on Table 2 or Table 4, the electronic device can 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, based on Table 6, the electronic device can adjust the distribution priority of the first task from the first functional unit to the second functional unit from the distribution priority DP3 (first distribution priority) to the distribution priority DP2 (second distribution priority). In this case, 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] 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 and the running state of the electronic device.
[0368] For example, when the background operation is the aforementioned ST2 and the device status level is the aforementioned DS1, based on the aforementioned 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 operation being the aforementioned 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 operation being the aforementioned 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.
[0369] For example, when the background operation is the aforementioned ST2 and the device status level is the aforementioned DS2, based on the aforementioned 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 core operating frequency level "medium frequency", the fourth operating frequency can be the operating frequency corresponding to the core operating frequency level "medium frequency", and the second distribution priority can be the distribution priority DP2 (second distribution priority). In this case, corresponding to the foreground operation being the aforementioned 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 operation being the aforementioned 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.
[0370] For example, when the background operation is ST4 and the device status level is DS1 or 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 P4, the second operating frequency can be the operating frequency corresponding to the core operating frequency level "lowest frequency", the fourth operating frequency can be the operating frequency corresponding to the core operating frequency level "lowest frequency", 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.
[0371] 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, the second operating frequency / fourth operating frequency, and the second distribution priority based on the association between the QoS level and the task priority, the core operating frequency, and the distribution priority. For details, please refer to the aforementioned S502, Tables 1 to 6, and S414 to S416C, which will not be repeated here.
[0372] pass Figure 6 In the method shown, the electronic device can synchronously schedule a first task on the second processor corresponding to a first service, and a second task on the first processor corresponding to the first service, based on the running state of the first application and / or the device state. This can avoid untimely response to the first service or waste of resources due to a mismatch in task priority or dispatch priority between the first task and the second task, and / or a mismatch in operating frequency between the core executing the first task and the core running the second task.
[0373] It should be noted that the technical solution of the embodiment of the present application is also applicable to the scheduling processing of tasks in different software modules in a single processor.
[0374] For example, Figure 7A According to some embodiments of the present application, a schematic diagram of establishing a session corresponding to a synchronous service is shown; Figure 7B According to some embodiments of the present application, a schematic diagram of tasks and threads related to synchronous services based on session scheduling is shown.
[0375] like Figure 7A As shown, this scenario includes the system framework, cloud library application, media management service, scheduling management service, CPU scheduler, service subsystem, and file subsystem. The functions of the system framework, scheduling management service, and CPU scheduler can be referred to Figures 3A to 7B The embodiments of the present invention are not described in detail here.
[0376] The cloud image library application can be an application for synchronizing images on an electronic device with a server. For example, the cloud image library application can store data that exists on a cloud server but not on the electronic device on the electronic device via a file subsystem, or transmit data that exists on the electronic device but not on the cloud server to the cloud server, thereby synchronizing data stored on the electronic device with data stored on the cloud server.
[0377] Media management services can include sub-services such as image management, metadata management, file management, and synchronization interfaces. Sub-services within media management services can provide applications (such as cloud gallery applications, address book applications, and file management applications) with interfaces for media management services, such as image synchronization, file synchronization, address book synchronization, and file / image / audio management services.
[0378] The synchronization interface is used for establishing / destroying sessions, establishing synchronization services, and communicating between applications and media management services and file subsystems.
[0379] In some embodiments, the synchronization interface can respond to the call of the application program, establish a session corresponding to the synchronization business corresponding to the synchronization interface through the scheduling management service, obtain the SID of the established session, establish an association relationship between the SID and the task corresponding to the business and send it to the cloud service subsystem (for example, the data access task corresponding to the synchronization business and the SID of the established session are sent to the cloud service subsystem together), and destroy the session corresponding to the synchronization business after the synchronization business is executed.
[0380] For example, reference Figure 7A In ①, the synchronization interface can respond to the call of the cloud gallery application, establish a session S10 through the scheduling management service, and obtain the session identifier SID10 of the session S10.
[0381] For example, refer to Figure 7A In ②, after obtaining the session identifier SID10 of session S10, the synchronization interface can call the cloud data management service to establish a task DA1 corresponding to the Chinese-English translation service and configure the session identifier SID10 for the task DA1.
[0382] For example, refer to Figure 7A In step ⑥, the synchronization interface can destroy the session S10 after the synchronization service is completed.
[0383] The cloud service subsystem may include cloud data management services and cloud data access interfaces.
[0384] The cloud data management service can respond to a request from the media management service to call a synchronization service, obtain data from the cloud server through the cloud data access interface, or store data stored locally on the electronic device in the cloud service.
[0385] In some embodiments, the cloud data management service can establish a cloud data access task for each synchronization business (used by the cloud server to obtain data and / or the cloud server to send data, such as cloud data access task DA1, referred to as task DA1), and establish a thread to implement cloud data access and synchronization (hereinafter the thread that implements cloud data access will be referred to as the synchronization thread, and the thread identifier of the synchronization thread will be recorded as TID3).
[0386] In some embodiments, the cloud data management service may further establish an association relationship among SID10, task DA1, and a synchronization thread (eg, thread identifier TID3) after receiving task DA1 and SID10.
[0387] For example, reference Figure 7A In step ③, after task DA1 and the 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.
[0388] The cloud data management service may also be used to convert the QoS level sent by the scheduling management service into a CPU task priority, and execute the cloud data access task based on the converted CPU task priority.
[0389] For example, reference Figure 7A In ⑤, 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 task DA1 corresponding to SID10 based on the converted CPU task priority.
[0390] For example, refer to Figure 7B In step 9, after receiving the current QoS level and SID10, the cloud data management service may convert the current QoS level into a CPU task priority, and execute task DA1 corresponding to SID10 based on the converted CPU task priority.
[0391] The way in which the cloud data management service converts the QoS level into the CPU task priority can refer to the content of obtaining the CPU task priority based on Table 4 or Table 5 or other methods, which is not repeated here.
[0392] The cloud data access interface is used to implement communication between the cloud data management service and the cloud server.
[0393] The file subsystem is used to read, write, and modify data in the electronic device's memory. For example, different applications, services, processes, threads, etc. 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 (IO) task. That is, when multiple entities (applications, services, processes, threads) call the file access interface, there will be multiple IO tasks, and an IO task can be executed by one or more IO threads.
[0394] In some embodiments, the file subsystem may be used to establish an association relationship between an IO task and a SID, and an association relationship between a SID and an IO thread corresponding to each IO task.
[0395] For example, reference Figure 7A In step ④, the file subsystem can respond to the call of the synchronization interface and establish an IO thread (thread identifier TID4) corresponding to the IO task DA2 (hereinafter referred to as DA2) of the cloud library. The file subsystem can then establish an association between SID10, task DA2, and TID4. For example, the file subsystem can store the association between task DA2 and SID10, send the association between TID4 and SID10 to the CPU scheduler, and so on.
[0396] In some embodiments, the file subsystem may also be used to determine the CPU task priority corresponding to each IO task based on the SID and the QoS level, and execute each IO task based on the CPU task priority corresponding to each IO task.
[0397] For example, reference Figure 7A In step ⑤, after receiving the initial QoS level and SID 10, the file subsystem may convert the initial QoS level into a CPU task priority. Then, the file subsystem may execute task DA2 corresponding to SID 10 based on the converted CPU task priority.
[0398] For example, refer to Figure 7B In step 9, after receiving the current QoS level and SID 10, the file subsystem may convert the current QoS level into a CPU task priority. Then, the file subsystem may execute task DA2 corresponding to SID 10 based on the converted CPU task priority.
[0399] In some embodiments, the CPU scheduler can establish an association relationship between the synchronization thread in the cloud data management service and the corresponding SID by interacting with the cloud data management service, or it can establish an association relationship between the IO thread in the file subsystem and the corresponding SID by interacting with the file subsystem.
[0400] For example, reference Figure 7A In ③, the CPU scheduler can receive TID3 and SID10 sent by the cloud data management service and establish an association between SID10 and TID3. For another example, refer to Figure 7A In step ④, the CPU scheduler may receive the TID (eg, TID4) and SID10 of the IO thread sent by the file subsystem, and establish an association between SID10 and TID4.
[0401] In some embodiments, the CPU scheduler may also adjust the priority of the thread corresponding to the SID and / or configure the operating frequency of the core running 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 may obtain the CPU task priority and CPU operating frequency corresponding to the QoS level based on Tables 4 and 5; then, the CPU scheduler may schedule the thread corresponding to the SID based on the obtained CPU task priority and configure the operating frequency of the core running the thread corresponding to the SID to the obtained CPU operating frequency.
[0402] For example, refer to Figure 7A In step ⑤, after receiving the initial QoS level and SID 10, the CPU scheduler can convert the initial QoS level into a CPU task priority and a CPU operating frequency. The CPU scheduler can then schedule the synchronization thread and I / O thread corresponding to SID 10 based on the converted CPU task priority, and configure the operating frequency of the CPU core used to run the synchronization thread and I / O thread based on the converted CPU operating frequency.
[0403] For example, refer to Figure 7B In step 9, after receiving the current QoS level and SID 10, the CPU scheduler can convert the current QoS level into a CPU task priority and a CPU operating frequency. The CPU scheduler can then schedule the synchronization thread and I / O thread corresponding to SID 10 based on the converted CPU task priority, and configure the operating frequency of the CPU core used to run the synchronization thread and I / O thread based on the converted CPU operating frequency.
[0404] 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 priority of the synchronization thread corresponding to task DA1 and the IO thread corresponding to task DA2, or the mismatch between the working frequencies of the kernels running the synchronization thread corresponding to task DA1 and the IO thread corresponding to task DA2, which affects the timeliness of the cloud library application operation or wastes resources.
[0405] The embodiment of the present application also provides a task scheduling method for scenarios where tasks of the same business are implemented by multiple functional units.
[0406] For example, Figure 8 According to some embodiments of the present application, a flow chart of another task scheduling method is shown. The execution subject of the method is an electronic device. Figure 8 As shown, the method includes:
[0407] S801 , detecting a request from a second application to call a second service, wherein the second service includes multiple tasks, a first portion of the multiple tasks is executed by a third functional unit, and a second portion of the multiple tasks is executed by a fourth functional unit.
[0408] 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, which is not limited here.
[0409] It should be noted that the third functional unit and the fourth functional unit may be task functional units capable of implementing functions related to the first business. Specific forms of functional units may include, but are not limited to, applications, microservices, meta-services, applets, software modules, system services, third-party services, etc.
[0410] It should be noted that the first part of tasks and the second part of tasks may be part or all of the multiple tasks of the second business.
[0411] For example, for a synchronization service (e.g., synchronizing one or more of images, audio, video, address books, and files), the third functional unit may be a cloud data management service, the fourth functional unit may be a file subsystem, the first portion of the task may be a cloud data access task, the second portion of the task may be an IO task, the first thread may be a synchronization thread, and the second thread may be an IO thread. It should be noted that the second service may be any service that requires the coordinated implementation of multiple functional units, including but not limited to a synchronization service.
[0412] S802: Establish a third association relationship among 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.
[0413] The electronic device can 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 in response to the request of the second application to call the second service.
[0414] It should be noted that, if the first part of the task is not executed by a specific thread, the first thread may not be included in the third association relationship; and if the second part of the task is not executed by a specific thread, the second thread may not be included in the third association relationship. This embodiment of the application is not limited to this.
[0415] 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, which is not limited here.
[0416] 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 an association relationship between the second application (such as the package name of the second application, the PID of the process of the second application calling the second service, the TID of the thread of the second application calling the second service, etc.), the first part of the task, the second part of the task, the first thread (such as the TID of the first thread), and the second thread (such as the TID of the second thread). For details, please refer to Figure 7A and Figure 7B In the process of the electronic device establishing the association relationship between SID10, TID3, TID4, task DA1, and task DA2, it will not be described in detail here.
[0417] It should be noted that, in other embodiments, when the above-mentioned multiple tasks of the second business include one or more tasks performed by one or more other functional units, the third association relationship may also include the one or more tasks and the threads associated with the one or more tasks in the fifth functional unit.
[0418] S803: Determine a third QoS level based on the running state of the second application and / or the device state of the electronic device.
[0419] After the third association is established, the electronic device may determine a third QoS level based on the running state of the second application and / or the device state of the electronic device. For example, the electronic device may determine the third QoS level corresponding to the running state of the second application and / or the device state of the electronic device based on Table 4, Table 5, or other associations between running states, device states, and QoS levels.
[0420] For example, taking Table 5 as an example, when the running status of the second application is S3 and the device status level is DS1, the scheduling management service can determine the initial QoS level as L3; when the running status of the second application is S2 and the device status level is DS2, the scheduling management service can determine the initial QoS level as L6; when the device status level is DS3, the scheduling management service can determine the initial QoS level as L9.
[0421] It should be noted that the method for determining the third QoS level can refer to the method for determining the initial QoS level and the current QoS level mentioned above, which will not be described in detail here.
[0422] S804: Schedule the second service based on the third association relationship and the third QoS level.
[0423] After determining the third QoS level, the electronic device may schedule the second service based on the third QoS level.
[0424] For example, the electronic device may 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 parts of tasks to be the fifth priority. Then, the third functional unit may execute the first part of tasks based on the fifth priority, and the fourth functional unit may execute the second part of tasks based on the fifth priority. For example, the third functional unit may execute the first part of tasks before other tasks with a priority lower than the fifth priority, and the fourth functional unit may execute the second part of tasks before other tasks with a priority lower than the fifth priority.
[0425] For another example, the electronic device may 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 of the first thread corresponding to the first part of the task and the second thread corresponding to the second part of the task to be the fifth priority. Then, the electronic device (e.g., a scheduling management service) may schedule the first thread and the second thread based on the fifth priority. For example, the electronic device may schedule the first thread and the second thread before other threads with a priority lower than the fifth priority.
[0426] For another example, the 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 core running the first thread to the operating frequency corresponding to the fifth operating frequency level, and configure the operating frequency of the core running the second thread to the operating frequency corresponding to the fifth operating frequency level.
[0427] It should be noted that the electronic device can repeat S803 and S804 before the second service is completed, 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.
[0428] based on Figure 8In the manner shown, the electronic device can, based on the device state of the electronic device, synchronously configure the priorities of the first part of the task and the second part of the task, 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 frequencies of the cores running the first thread and the second thread. This helps improve the efficiency of the electronic device in executing the second service.
[0429] The present application also provides a computer program product, which may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device implements the task scheduling method provided in the present application.
[0430] The present 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.) that can store and / or read data on a computing device. The computer-readable storage medium includes instructions that instruct the computing device to implement the task scheduling method provided in the present application.
[0431] An embodiment of the present application also provides an electronic device, which includes at least one processor, a memory, and a non-volatile memory. The at least one processor is used to execute instructions to implement the task scheduling method provided by the aforementioned embodiments.
[0432] An embodiment of the present application further provides a task scheduling device for implementing the task scheduling methods provided in the aforementioned embodiments.
[0433] For example, Figure 9 According to some embodiments of the present application, a schematic diagram of a task scheduling device 200 is shown.
[0434] 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 .
[0435] The scheduling management unit 201 is used to establish / maintain / destroy sessions, determine QoS levels based on the running status of applications, and send QoS levels 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 content and will not be repeated here.
[0436] In some embodiments, the scheduling management unit 201 may also determine the first QoS level and the second QoS level based on the running state of the application and / or the device state of the electronic device, and send the first QoS level and the second QoS level to the function 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 above, which will not be repeated here.
[0437] The functional unit 202 is used to distribute the first task of the first business and the SID of the session to the second scheduling unit, establish the second task of the first business and send the SID of the second task and the session to the first scheduling unit 203. For details, please refer to the content of the aforementioned AI business management service, which will not be described in detail here. For example, the functional unit 202 may include a first functional unit, and the first functional unit may send the first task to the second scheduling management unit 204 (or referred to as the second functional unit) based on the aforementioned first distribution priority or the second distribution priority. For details, please refer to the contents of S406, S416A, S502, S503, S602, and S603, which will not be described in detail here.
[0438] The first scheduling unit 203 is used to schedule the first processor. For example, the first scheduling management unit 203 can be used to maintain the association between the second task and the session SID, and configure the priority of the second task on the first processor and the operating frequency of the core 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 content of the CPU scheduler and will not be repeated here.
[0439] For example, the first scheduling unit 203 may 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 core 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 above-mentioned S405, S412C, S416C, S502, S503, S602, and S603, which will not be repeated here.
[0440] The second scheduling unit 204 is used to schedule the first processor. For example, the second scheduling unit 204 can be used to maintain the association between the first task and the session SID, and configure the priority of the first task on the second processor, the operating frequency of the core 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 content of the AI task executor above and will not be repeated here.
[0441] For example, the second scheduling unit 204 may configure the priority of the first task on the second processor to be the first priority or the second priority, configure the operating frequency of the core running the first task on the second processor to be the first operating frequency or the second operating frequency, distribute the first task to the second processor with the first priority or the second priority, etc. For details, please refer to the above-mentioned S408, S412B, S416B, S502, S503, S602, and S603, which will not be repeated here.
[0442] 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 also include more or fewer modules, or merge or split some modules, which is not limited here.
[0443] For example, Figure 10 According to some embodiments of the present 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 method provided in each embodiment of the present application.
[0444] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0445] The processor 110 may include one or more processing units, for example: the processor 110 may include a central processing unit (CPU), an application processor, a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a microcontroller unit (MCU), a video codec, a digital signal processor (DSP), a baseband processor, a neural network processing unit (NPU), a field programmable gate array (FPGA), etc. In some embodiments, different processing units may be independent devices or integrated into one or more processors. The one or more processing units may include the aforementioned first processor and second processor.
[0446] In some embodiments, the processor 110 may be configured to execute instructions to implement the task scheduling methods provided in the aforementioned embodiments.
[0447] The charging management module 140 is configured to receive charging input from a charger. While charging the battery 142 , the charging management module 140 can also provide power to the electronic device through the power management module 141 .
[0448] 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 provide power to the processor 110, the internal memory 121, the display 194, the camera 193, and the wireless communication module 160.
[0449] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0450] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
[0451] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc.
[0452] The wireless communication module 160 can provide wireless communication solutions for the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity networks), Bluetooth (BT), global navigation satellite system (GNSS), near field communication (NFC), infrared technology (IR), and near link (NL). The wireless communication module 160 can be one or more devices that integrate at least one communication processing module.
[0453] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0454] The display screen 194 is used to display images.
[0455] The camera 193 is used to capture still images or videos.
[0456] The external memory interface 120 can be used to connect to an external memory card. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage. For example, application data of an application 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 the application's buffered items.
[0457] The internal memory 121 can be used to store one or more programs and corresponding data. The 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 required for at least one function, etc., such as the program / instructions corresponding to the task scheduling method provided in the aforementioned embodiments. The data storage area may store data created during the use of the electronic device 100. In addition, the internal memory 121 may include a high-speed random access memory (such as a memory); it may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a general flash memory, etc. The processor 110 executes various functional applications of the electronic device 100 by running one or more programs stored in the internal memory 121, and / or one or more programs stored in a memory provided in the processor 110.
[0458] In some embodiments, the volatile memory (e.g., internal memory) in the internal memory 121 can be used to store the application's buffer items when the application is running in the foreground, or when the application is running in the background and the swap-out conditions are 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 the application's buffer items when the application is running in the background and the swap-out conditions are met.
[0459] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc. For example, the audio module 170 can be used to play prompt information.
[0460] The 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. The audio module 170 can also be used to encode and decode audio signals.
[0461] The speaker 170A, also called a "horn", is used to convert audio electrical signals into sound signals.
[0462] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals.
[0463] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0464] The headphone jack 170D is used to connect a wired headphone.
[0465] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0466] Motor 191 can generate a vibration prompt. Indicator 192 can be an indicator light that can be used to indicate charging status, power changes, messages, notifications, etc. In some embodiments, electronic device 100 can prompt the user by controlling motor 191 to vibrate.
[0467] The SIM card interface 195 is used to connect a SIM card or an eSIM.
[0468] It should be noted that the structure of the electronic device 100 shown in the embodiment of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or some components may be combined or separated, or the components may be arranged differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0469] It should be noted that in the embodiments of the present application, "or" describes the association relationship of associated objects, indicating that two relationships may exist. For example, A or B can represent: A exists alone, and B exists alone, where A and B can be singular or plural.
[0470] It should be noted that in the embodiments of this application, the words "for example," "in some embodiments," "in another embodiment," "in another embodiment," and "exemplarily" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as an "example" in this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "example" is intended to present concepts in a concrete way.
[0471] It should be noted that the words "first" and "second" in the embodiments of the present application are only used for the purpose of distinguishing descriptions and should not be understood as indicating or implying relative importance or order. The words "equal to" in the embodiments of the present application can be used in conjunction with "greater than" and are applicable to the technical solutions adopted when "greater than" is used, and can also be used in conjunction with "less than" and are applicable to the technical solutions adopted when "less than" is used. It should be noted that when "equal to" is used in conjunction with "greater than", it should not be used in conjunction with "less than"; when "equal to" is used in conjunction with "less than", it should not be used in conjunction with "greater than".
[0472] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.
[0473] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A task scheduling method, characterized in that: Applied to electronic equipment, the method includes: Running a first application through a first processor of the electronic device, where the running state of the first application is foreground running; detecting a request by the first application to invoke a first service, and executing, by a second processor of the electronic device, a first task included in the first service, wherein the priority of the first task in the second processor is a first priority, and an operating frequency of at least one core in the second processor for running the first task is a first operating frequency; It is detected that the running state of the first application is switched from the foreground running to the background running, and the first business is scheduled, and the scheduling 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 further includes a second task executed by the first processor, and when the running state of the first application is the foreground running, 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 a fourth priority; And / or, adjusting the operating frequency of the one or more cores from the third operating frequency to a fourth operating frequency.
3. The method according to claim 2, characterized in that When the running state of the first application is the foreground running, the electronic device distributes the first task to the second processor based on the first priority; Furthermore, the scheduling process further includes: The priority of distributing the first task by the electronic device 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, and when the running state of the first application is the foreground running, the first functional unit distributes the first task to the second functional unit based on a first distribution priority; The scheduling process further includes: The first task is distributed to the second functional unit by the first functional unit based on a 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 are related 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 are related to the background operation and the device status of the electronic device; wherein the device status includes one or more of remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
6. The method according to claim 4 or 5, 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 any one of claims 1 to 6, characterized in that The foreground running includes running in the foreground and being in focus, and / or running in the foreground and not being in focus; the background running includes running in the background and being perceptible to the user, and / or running in the background and not perceptible to the user.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: After detecting a request from the first application to call a first service, a first association relationship is established between the first application and the first task, where the first association relationship includes an association relationship between a first session identifier of a first session and the first application, and an association relationship between the first session identifier and the first task.
9. The method according to claim 8, characterized in that The detecting that the running state of the first application is switched from the foreground running to the background running, and performing scheduling processing on the first service includes: In response to the running state of the first application being switched from the foreground running to the background running, the first session identifier is determined based on the first application and the first association relationship, and a first service quality 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 detecting that the running state of the first application is switched from the foreground running to the background running and the scheduling processing of the first service further includes: Adjusting the priority of the first task on the second processor from the first priority to a second priority based on the first quality of service level, the association between the quality of service level and the priority, and the first association; And / or, based on the first quality of service level, the association between the quality of service level and the operating frequency, and the first association, adjusting the operating frequency of the at least one core from the first operating frequency to the second operating frequency.
11. The method according to claim 8, characterized in that The method further comprises: In response to the completion of the execution of the first service or the cessation of the execution 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 remaining power, temperature, processor load, power connection status, and available bandwidth of the memory.
13. The method according to any one of claims 1 to 12, 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 business is an artificial intelligence business, 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 business 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, and when the one or more programs are executed on an electronic device, the electronic device implements the task scheduling method according to any one of claims 1 to 15.
17. An electronic device, characterized in that: include: a memory for storing one or more programs; The first processor and the second processor are configured to execute one or more programs so that the electronic device implements 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, the electronic device implements the task scheduling method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Service thread running method and device, storage medium and electronic equipment
CN111597042A
Inter-core migration frequency adjustment method
CN114968540A
Frequency adjustment method and electronic equipment
CN117114961A
Task scheduling method and related equipment
CN117666755A
Task scheduling method and related device
WO2024046088A1