Task scheduling and notification method and device, storage medium and program product

By grouping asynchronous operation instructions into the same group and providing unified feedback response signals, the problem of frequent context switching during asynchronous I/O operations is solved, thus improving task execution performance.

CN121636075APending Publication Date: 2026-03-10ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Frequent context switching during asynchronous I/O operations reduces the time utilization of processing units and affects task execution performance.

Method used

Asynchronous operation instructions with relationships in the target task are grouped into the same group, and a unified response signal is fed back after all asynchronous operation instructions in the same group have been executed, so as to reduce the number of task context switches.

Benefits of technology

By reducing the number of context switches, the utilization rate of processing units and the overall task execution performance are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636075A_ABST
    Figure CN121636075A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a task scheduling and notification method and device, a storage medium and a program product. In the embodiment of the invention, at least part of asynchronous operation instructions with the incidence relation in the target task are divided into the same group, and during the execution period of the asynchronous operation instructions in the same group, a task scheduler schedules and executes other tasks. Under the condition that all the asynchronous operation instructions in the same group are executed, the task scheduler controls the target task to enter a scheduling waiting state so as to wait to be scheduled again, and then under the condition that the target task is scheduled, task context switching is carried out so that the target task can be switched back to continue to be executed; compared with a scheme that task context switching is triggered once after each asynchronous operation instruction is completed, the task context switching frequency can be reduced by performing task context switching under the condition that the asynchronous operation instructions in the same group are completely executed by taking the group as a unit, and the task execution performance is improved on the whole.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task scheduling and notification method, device, storage medium, and program product. Background Technology

[0002] In software code implementation, there are usually multiple tasks. A task is a basic unit of work that needs to be executed by the processing unit. A task typically includes one or more operation instructions. In some tasks, asynchronous I / O (Input / Output) operations may be initiated through corresponding operation instructions, such as file read / write operations and network requests.

[0003] Asynchronous I / O operations are relatively time-consuming. To prevent processing units from being idle while waiting for asynchronous I / O operations to complete, asynchronous I / O operations allow programs to continue scheduling and executing other tasks after initiating an I / O request, and then process the tasks after the asynchronous I / O operation is completed, thereby improving the program's running efficiency and response speed.

[0004] During the execution of an asynchronous I / O operation, scheduling other tasks involves context switching, which involves saving the context information of the current asynchronous I / O operation and restoring the context information of the next task. Context switching incurs overhead, and frequent context switching, in particular, consumes a significant amount of processing unit time, reducing the available processing time and lowering overall task execution performance. Summary of the Invention

[0005] This application provides a task scheduling and notification method, device, storage medium, and program product to reduce context switching operations caused by asynchronous I / O operations, improve the utilization of processing units, and enhance overall task execution performance.

[0006] This application provides a task scheduling method, comprising: scheduling a target task, the target task including multiple operation instructions, the multiple operation instructions including synchronous operation instructions and asynchronous operation instructions, wherein at least some asynchronous operation instructions with a relationship are grouped into the same group, and the same group includes two or more asynchronous operation instructions; executing the multiple operation instructions according to the execution order among the multiple operation instructions; if an asynchronous operation instruction is executed, continuing to execute the next operation instruction; if a synchronous operation instruction is executed, controlling the target task to enter a waiting state and scheduling the next task to wait for the asynchronous operation instruction to be executed; and when all asynchronous operation instructions in the same group have been executed, controlling the target task to enter a waiting-to-be-scheduled state to wait to be rescheduled.

[0007] This application also provides a task generation method, comprising: generating multiple operation instructions required by the target task based on the description information of the target task and determining the execution order among the multiple operation instructions, wherein the multiple operation instructions include synchronous operation instructions and asynchronous operation instructions; identifying asynchronous operation instructions with relationships from the asynchronous operation instructions, dividing at least some of the asynchronous operation instructions with relationships into the same group, wherein the same group includes two or more asynchronous operation instructions; and generating the target task based on the execution order among the multiple operation instructions and the asynchronous operation instructions with relationships in the same group.

[0008] This application embodiment also provides a task notification method, including: receiving a target asynchronous operation instruction in a target task and executing the target asynchronous operation instruction, wherein at least some asynchronous operation instructions with a relationship in the target task are grouped into the same group; when it is identified that the target asynchronous operation instruction belongs to a group, continuing to receive and execute other asynchronous operation instructions in the group; when all asynchronous operation instructions belonging to the group have been executed, sending a response signal to the task scheduler to trigger the task scheduler to control the target task to enter a waiting state to wait for rescheduling.

[0009] This application provides a computer device, including: a host machine, on which a task scheduler and a target program are running, the target program having input / output (I / O) devices, the target program including at least one task, the at least one task including a target task, the target task including multiple operation instructions, the multiple operation instructions including synchronous operation instructions and asynchronous operation instructions, and at least some asynchronous operation instructions with a relationship are divided into the same group, and the same group includes two or more asynchronous operation instructions;

[0010] The task scheduler is used to schedule the target task and execute the multiple operation instructions in the order of execution. If an asynchronous operation instruction is executed, the next operation instruction is executed. If a synchronous operation instruction is executed, the target task is controlled to enter a waiting state, and the next task is scheduled to wait for the asynchronous operation instruction to be completed. When all asynchronous operation instructions in the same group have been completed, the target task is controlled to enter a waiting state to wait to be rescheduled.

[0011] In an optional embodiment, the host machine also runs a virtualization manager, and the target program is a virtualization instance created by the virtualization manager or an application running in a virtualization instance; the I / O device of the target program is a pass-through I / O device or a virtualized I / O device.

[0012] This application also provides an electronic device, including a memory and a processing unit. The memory is used to store a computer program, and the processing unit is coupled to the memory and used to execute the computer program to implement the steps in the various methods provided in this application.

[0013] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processing unit, enables the processing unit to implement the steps in the above-described method.

[0014] This application also provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processing unit, the processing unit is able to implement the steps in the above method embodiments.

[0015] In this embodiment, at least some asynchronous operation instructions with a relationship in the target task are grouped into the same group. During the execution of asynchronous operation instructions in the same group, the task scheduler can schedule other tasks to be executed. When all asynchronous operation instructions in the same group have been executed, the task scheduler controls the target task to enter a waiting scheduling state so that it can be rescheduled. Then, when the target task is scheduled, the task context is switched so that it can switch back to the target task to continue execution. Compared with the scheme of triggering a task context switch every time an asynchronous operation instruction is executed, switching the task context by group when all asynchronous operation instructions in the same group have been executed can reduce the number of task context switches, thereby reducing the resources consumed by task context switching and improving the overall task execution performance. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0017] Figure 1 A flowchart illustrating a task scheduling method provided for an exemplary embodiment of this application;

[0018] Figure 2 This is a schematic diagram of a task scheduling method provided in an embodiment of this application;

[0019] Figure 3 A schematic diagram illustrating the response state of an exemplary task provided for another exemplary embodiment of this application;

[0020] Figure 4 A schematic diagram of the response state of a target task provided as another exemplary embodiment of this application;

[0021] Figure 5 A flowchart illustrating a task generation method provided as another exemplary embodiment of this application;

[0022] Figure 6 A flowchart illustrating a task notification method provided as another exemplary embodiment of this application;

[0023] Figure 7 A schematic diagram of the structure of a computer device provided for an exemplary embodiment of this application;

[0024] Figure 8 A schematic diagram of the structure of an electronic device provided as another exemplary embodiment of this application. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] It should be noted that, in the cases involving user information in the embodiments of this application, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to language models or large models) comply with relevant laws and standards.

[0027] In this embodiment, the software product includes multiple tasks. The software product can be, but is not limited to, applications, system software, programming software, and middleware. A task may involve one or more asynchronous I / O operations. Asynchronous I / O is a non-blocking data transmission method between the software product and external devices. After initiating an asynchronous I / O operation, the task does not block but continues to schedule and execute other tasks while waiting for the result of the asynchronous I / O operation. During the execution of an asynchronous I / O operation, continuing to schedule and execute other tasks involves context switching, i.e., saving the context information of the current task and restoring the context information of the next task. Context switching incurs overhead. Furthermore, after the asynchronous I / O operation is completed, another context switch is triggered to switch back to the task to which the asynchronous I / O operation belonged. Therefore, if a task involves multiple asynchronous I / O operations, each I / O operation execution involves context switching, resulting in frequent context switching, significant context switching overhead, and impacting task execution performance.

[0028] Depending on the software code development scheme and the level of the task within the software code, the granularity of the task execution unit will vary. For example, the granularity of the execution unit can be a process, thread, or coroutine. Different execution unit granularities result in different context switching overheads. The following section describes the context overhead generated by different execution unit granularities.

[0029] First, a process serves as the unit for resource allocation by the operating system. Processes are isolated from each other, and each process includes program code and various resources allocated by the operating system, including but not limited to memory space and stack. Because processes are isolated, the operating system allocates resources to each process, making processes relatively "heavyweight." A thread, on the other hand, is a more lightweight entity than a process. A process includes at least one thread, which is an execution unit within a process. Threads within the same process share the process's resources. When performing context switching, if the execution unit is a process or a thread, the overhead of saving and restoring the context is approximately several microseconds. This means that the processing unit is engaged in ineffective computation for several microseconds.

[0030] Secondly, compared to processes and threads, coroutines are a more lightweight unit of execution, capable of concurrent operations within a single thread. If we consider coroutines as units, the overhead of saving and restoring context is around several hundred nanoseconds. While this context switching overhead is relatively small compared to processes and threads, coroutines are scheduled by the program itself, voluntarily relinquishing execution rights through the characteristics of the programming language, rather than by the operating system. That is to say, coroutines generally cannot be forcibly switched. A coroutine can switch if it actively chooses to pause execution and relinquish execution rights. This can lead to excessively long response times for individual coroutines, wasting processing unit resources and reducing task execution performance.

[0031] Although the process → thread → coroutine progression is increasingly lightweight, and the context switching overhead during asynchronous I / O operations decreases progressively from process → thread → coroutine, all execution units at different granularities incur context switching overhead. Therefore, reducing unnecessary context switching is beneficial for improving task execution performance and reducing program response time.

[0032] To address the issue of reduced available processing unit time and decreased overall task execution performance due to frequent context switching during asynchronous I / O operations, this embodiment divides at least some related asynchronous operation instructions in the target task into the same group. During the execution of asynchronous operation instructions in the same group, the task scheduler schedules other tasks to avoid idle processing units and improve the utilization rate of processing unit resources. When all asynchronous operation instructions in the same group have been executed, the execution device of the asynchronous operation instructions uniformly feeds back a response signal, realizing the aggregation of response signals for asynchronous operation instructions. After receiving the response signal, the task scheduler performs task context switching to switch back to the target task for continued execution. Compared to the scheme of feeding back a response signal and triggering a task context switch after each asynchronous operation instruction is executed, feeding back a response signal uniformly for asynchronous operation instructions in the same group as a group can reduce the number of response signals, thereby reducing the number of task context switches, reducing the resources consumed by context switching, and improving the overall task execution performance.

[0033] This application describes a technical solution that improves several aspects, including the task generation stage, the task scheduling stage, and the notification stage after task scheduling. Specifically, in the task generation stage, multiple asynchronous I / O operations involving the same I / O device within the same task can be grouped into the same group. In the task scheduling stage, context switching is performed on a group basis, rather than on an individual asynchronous I / O operation basis. In the notification stage after task scheduling, feedback or response (e.g., event notification or interrupt method) is provided on a group basis after the asynchronous I / O operation is completed, instead of responding on a single asynchronous I / O operation basis. These three stages work together to achieve unified feedback response signals for asynchronous operation instructions within the same group, reducing the number of response signals and thus reducing the number of task context switches, thereby improving overall task execution performance.

[0034] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0035] Figure 1 This is a flowchart illustrating a task scheduling method provided as an exemplary embodiment of this application. Figure 1 As shown, the method includes:

[0036] S101: Schedule the target task, which includes multiple operation instructions, including synchronous operation instructions and asynchronous operation instructions, and at least some of the asynchronous operation instructions that are related are divided into the same group, and the same group includes two or more asynchronous operation instructions.

[0037] S102: Execute multiple operation instructions in the order of execution. If an asynchronous operation instruction is executed, continue to execute the next operation instruction. If a synchronous operation instruction is executed, control the target task to enter a waiting state and schedule the next task to wait for the asynchronous operation instruction to complete.

[0038] S103: When all asynchronous operation instructions in the same group have been executed, the target task is put into a waiting state to be rescheduled.

[0039] In this embodiment, the software product runs on a computer device, which can be a desktop computer, laptop computer, smartphone, or IoT (Internet of Things) device, or a server device such as a conventional server, cloud server, or server array. Multiple tasks included in the software product can be scheduled by a task scheduler on the computer device. The task scheduler allocates processing unit time to multiple tasks for the processing unit to execute. The processing unit in this embodiment can be a processing unit in a broad sense, that is, any resource object with task execution capabilities, such as a CPU (Central Processing Unit), GPU (Graphics Processing Unit), or DPU (Data Processing Unit). Optionally, the task scheduler can be a process or thread provided by the operating system responsible for task scheduling, or, if the software product is implemented as an application, a coroutine implemented by the application itself responsible for task scheduling. It should be noted that, when the processing unit is implemented as a CPU, the processing unit can be a single-core CPU or one CPU core in a multi-core CPU.

[0040] In this embodiment, at least some of the multiple tasks include multiple operation instructions. Of course, some tasks may include only one operation instruction. For tasks containing multiple operation instructions, there is an execution order among the multiple operation instructions. This execution order is determined when the task is written and may vary depending on the task. This embodiment does not limit this. The task scheduler can schedule multiple tasks according to a certain scheduling strategy. For a scheduled task containing multiple operation instructions, the processing unit can execute the multiple operation instructions according to their execution order. The task scheduler runs on the processing unit, which may be the same processing unit as the processing unit executing the multiple operation instructions, or it may be a different processing unit. This is not limited.

[0041] In this embodiment, a task containing multiple operation instructions is further divided into target tasks and non-target tasks. A target task refers to a task containing multiple operation instructions, including both synchronous and asynchronous operation instructions. Correspondingly, a non-target task refers to any other task containing multiple operation instructions besides the target task, i.e., a task containing multiple operation instructions, all of which are synchronous operation instructions.

[0042] The following explanation uses a target task as an example to illustrate synchronous and asynchronous operation instructions. Asynchronous operation instructions primarily refer to instructions that can initiate asynchronous I / O operations on external devices. Asynchronous I / O operation is a non-blocking data transmission method between the software product and external devices. After initiating an asynchronous I / O operation through an asynchronous operation instruction, the target task will not be blocked but will continue to execute the next operation instruction in the target task. Asynchronous I / O operations include, but are not limited to, disk I / O operations and network I / O operations. Disk I / O operations refer to data read / write operations performed by the software product on disk devices; network I / O operations refer to data transmission operations between the software product and the network. In this application embodiment, all hardware modules interconnected with the processing unit on the computer device through various types of buses can be used as external devices in this application embodiment, also referred to as I / O devices. External devices include, but are not limited to, input / output devices (such as mice, keyboards, etc.), network devices (such as network cards, network switches, etc.), and storage devices (such as hard drives). The bus interconnected with the processing unit can be a high-speed peripheral component interconnect express (PCIe) bus or a serial bus, etc., without limitation, depending on the external device.

[0043] Furthermore, asynchronous operation instructions, as non-blocking operation instructions, do not require waiting for the result of any asynchronous operation instruction before proceeding to the next operation instruction. Upon completion, the external device notifies the computer via a feedback signal. Conversely, synchronous operation instructions are sequentially executed during software product execution; they are blocking operation instructions, meaning that subsequent operation instructions are executed only after the synchronous operation instruction has completed. Therefore, when a synchronous operation instruction is encountered but cannot be executed due to waiting for the result of an asynchronous operation instruction, to improve the efficiency of the processing unit, the target task is put into a waiting state, i.e., the target task is suspended, and the next task is scheduled. This process involves saving the context information of the target task and restoring the context information of the next task, and then scheduling the next task based on its context information. During this period, the execution result of the asynchronous operation instruction in the target task can be awaited. The asynchronous operation instruction will produce an execution result upon completion.

[0044] In this embodiment, for asynchronous operation instructions included in the target task, at least some asynchronous operation instructions with a relationship are grouped into the same group, and the same group includes two or more asynchronous operation instructions. Here, asynchronous operation instructions with a relationship refer to asynchronous operation instructions that need to be executed by the same external device. In this embodiment, the external device responsible for executing the asynchronous operation instructions in the same group is called the target device. Further optionally, asynchronous operation instructions can be grouped according to their type. For example, asynchronous operation instructions may include disk I / O and network I / O, and asynchronous operation instructions of the disk I / O type can be grouped into the same group, but this is not limited to this. Also, asynchronous operation instructions of the same type and related to the same synchronous operation instruction can be grouped into the same group based on their relationship with synchronous operation instructions. Here, "related" means that the execution of the synchronous operation instruction depends on the execution result of the asynchronous operation instruction.

[0045] Based on the above, the task scheduler can schedule multiple tasks of a software product running on a computer device according to a certain task scheduling strategy. When a target task is scheduled, multiple operation instructions are executed according to the execution order of the multiple operation instructions contained in the target task. Specifically, if an asynchronous operation instruction is executed, the next operation instruction is executed; if a synchronous operation instruction is executed, the target task is put into a waiting state, and the next task is scheduled to wait for the asynchronous operation instruction to complete. The process of executing an asynchronous operation instruction refers to either sending the asynchronous operation instruction to the target device, having the target device execute the asynchronous operation instruction and return the execution result, or sending a corresponding request to the target device based on the asynchronous operation instruction, having the target device process the request and return the processing result.

[0046] In this embodiment, the completion of asynchronous operation instructions is determined on a group basis. When all asynchronous operation instructions in the same group have been completed, the target task is controlled to enter a waiting scheduling state to wait for rescheduling. Then, when the target task is rescheduled, the task context is switched to allow the task to continue execution. Compared to the scheme that triggers a task context switch every time an asynchronous operation instruction is completed, switching the task context when all asynchronous operation instructions in the same group have been completed reduces the resources consumed by task context switching and improves the overall task execution performance.

[0047] There are no restrictions on how to determine or identify whether asynchronous operation instructions in the same group have been completed; the following methods may be used, but are not limited to:

[0048] In an optional implementation A1, response signals can be aggregated on the task scheduler side. Specifically, the target device can feed back a response signal once for each asynchronous operation instruction in the same group. When the task scheduler receives the response signals fed back by the target device for all asynchronous operation instructions in the same group, it controls the target task to enter a waiting-to-be-scheduled state to wait for rescheduling. It should be noted that in this optional embodiment, where each asynchronous operation instruction in the same group feeds back a response signal once, each response signal does not immediately trigger subsequent operations upon arriving at the task scheduler side, i.e., it does not immediately control the target task to enter a waiting-to-be-scheduled state. Instead, it aggregates the response signals of each asynchronous operation instruction in the same group on the task scheduler side. That is, when the response signals of each asynchronous operation instruction in the same group have arrived at the task scheduler side, the target task is controlled to enter a waiting-to-be-scheduled state to wait for rescheduling.

[0049] In another optional implementation A2, the target device can send a response signal to the computer device or task scheduler after the asynchronous operation instruction has been executed. This response signal indicates that the asynchronous operation instruction has been completed. In this embodiment, the target device sends a response signal in groups, only when all asynchronous operation instructions in the same group have been executed, rather than sending a response signal per asynchronous operation instruction. That is, the response signals are aggregated on the target device side, combining the response signals of all asynchronous operation instructions in the same group into a single response signal, and then sending the aggregated response signal to the task scheduler all at once. For the task scheduler, upon receiving the unified response signal from the target device, it can determine that all asynchronous operation instructions in the same group have been executed. At this point, it can control the target task to enter a waiting-for-scheduling state to await rescheduling. In subsequent embodiments, optional implementation A2 will be used as an example for explanation.

[0050] It should be noted that due to different task scheduling strategies employed by the task scheduler, upon receiving a response signal, the target task is controlled to enter a waiting-to-schedule state. However, whether the target task is executed immediately upon entering this state may vary. In some task scheduling strategies, a context switch can be performed immediately upon the target task entering the waiting-to-schedule state. This includes saving the context information of the current task and restoring the context information of the target task containing the execution results of asynchronous operation instructions, facilitating an immediate switch from the current task to the target task and its continued execution. In other task scheduling strategies, tasks can be scheduled based on task priority or the order in which they entered the waiting-to-schedule state. In these strategies, when the target task enters the waiting-to-schedule state, it may need to wait for scheduling. When the target task is scheduled again, a context switch is performed, including saving the context information of the current task and restoring the context information of the target task containing the execution results of asynchronous operation instructions, facilitating a switch back to the target task and its continued execution. Continuing to execute the target task here refers to continuing to execute the synchronous operation instructions that caused the target task to enter the blocking state, as well as subsequent operation instructions.

[0051] It should be noted that the "current task" mentioned above may be the "next task" of the target task, or it may be the next task of the "next task". This is because during the execution of the "next task", it may be scheduled for its next task due to the involvement of asynchronous operation instructions, or it may be that the "next task" has finished executing, but the asynchronous operation instructions in the target task have not yet returned the execution result, so its next task continues to be scheduled.

[0052] In this embodiment, at least some asynchronous operation instructions with correlation in the target task are grouped into the same group. During the execution of asynchronous operation instructions in the same group, the task scheduler can schedule other tasks for execution. When all asynchronous operation instructions in the same group have been executed, the execution device of the asynchronous operation instructions uniformly feeds back a response signal, realizing the aggregation of response signals of asynchronous operation instructions. After receiving the response signal, the task scheduler performs task context switching to switch back to the target task for continued execution. Compared with the scheme of feeding back a response signal and triggering a task context switch after each asynchronous operation instruction is executed, feeding back a response signal uniformly for asynchronous operation instructions in the same group as a group can reduce the number of response signals, thereby reducing the number of task context switches, reducing the resources consumed by context switching, and improving the overall task execution performance.

[0053] In this embodiment, the implementation form of the target device responsible for executing asynchronous operation instructions within the same group is not limited, but is specifically related to the implementation form of the software product. In one optional embodiment, when the software product is a virtualized instance created by a virtualization manager, or an application running within a virtualized instance, the target device can be a virtualized I / O device obtained from one or more physical peripherals via virtualization technology, such as a virtual network interface card (NIC) or a virtual disk. In another optional embodiment, when the software product is a virtualized instance created by a virtualization manager, or an application running within a virtualized instance, the target device can also be a physical peripheral that is directly connected to the virtualized instance using pass-through technology, referred to simply as a pass-through I / O device. In yet another optional embodiment, when the software product is a conventional application running directly on a computer device without using virtualization technology, the target device can be a physical peripheral of the computer device.

[0054] Figure 2 This is a schematic diagram illustrating a task scheduling method provided in an embodiment of this application. Figure 2 As shown, the scheduling process involves a task scheduler 21, an execution queue 22, a waiting queue 23, a target device 24, and a processing unit 25. The processing unit 25 is the unit that executes the tasks scheduled by the task scheduler. There are no restrictions on the relationship between the processing unit 25 and the task scheduler 21; the task scheduler 21 can run on the processing unit 25, or it can run on other processing units different from the processing unit 25. Therefore, in… Figure 2 The relationship between the task scheduler 21 and the processing unit 25 is not shown in the diagram. The execution queue 22 is used to store tasks in a pending scheduling state; see [link to relevant documentation]. Figure 2 The execution queue includes multiple tasks, including the target task, such as task 2-task n, where n > 2 and n is a natural number; the waiting queue 23 is used to store tasks in a waiting state, see [link to relevant documentation]. Figure 2 The waiting queue includes tasks 3 to m, where m > 3 and m is a natural number. Tasks in the waiting state cannot be scheduled temporarily. They must be moved from the waiting queue 23 to the execution queue 22 to switch from a waiting state to a scheduled state before they can be scheduled. The task scheduler 21 selects tasks from the execution queue 22 for scheduling and assigns the scheduled tasks to the processing unit 25 for execution.

[0055] In this embodiment, task scheduler 21 is responsible for task scheduling. Task scheduler 21 can be implemented as a target process or target thread in the operating system responsible for task scheduling, or as a target coroutine in an application responsible for task scheduling.

[0056] Furthermore, the task currently scheduled by task scheduler 21 that contains both asynchronous and synchronous operation instructions is called the target task (e.g., Figure 2 As shown in ①), that is, the target task includes multiple operation instructions, which include synchronous operation instructions and asynchronous operation instructions, and at least some of the asynchronous operation instructions that are related are grouped into the same group, such as... Figure 2 As shown, the target task includes asynchronous operation instructions 1 to asynchronous operation instructions k, where k > 1 and k is a natural number. Asynchronous operation instructions 1 to k belong to group 1. It should be understood that this example uses multiple asynchronous operation instructions and exemplifies dividing multiple asynchronous operation instructions 1 to k into one group, but is not limited to this. In this embodiment, there is no limitation on the number of asynchronous operation instructions in any task or the number of groups divided in any task. Furthermore, the target task also includes synchronous operation instruction 0. Similarly, this example uses one synchronous operation instruction, but is not limited to this. For details regarding synchronous and asynchronous operation instructions, please refer to the foregoing embodiments.

[0057] Optionally, the synchronous operation instructions in the target task include: wait instructions adapted to asynchronous operation instructions in the same group. Figure 2 (Not shown in the diagram), the execution order of the wait instruction is after the last asynchronous operation instruction in the same group, used to trigger a switch from the target task to the next task. It should be noted that the wait instruction is a synchronous operation instruction. Synchronous operation instructions, in addition to the wait instruction, can also include other synchronous operation instructions with practical operational significance, such as synchronous operation instructions that perform summation or aggregation on the execution results of asynchronous operation instructions. Alternatively, the target task may not contain a wait instruction, but instead directly contain synchronous operation instructions with practical operational significance.

[0058] Furthermore, the task scheduler 21 executes multiple operation instructions according to their execution order. If an asynchronous operation instruction is executed, such as asynchronous operation instruction 1, then asynchronous operation instruction 1 is sent to the target device 24 for the target device 24 to initiate the corresponding asynchronous I / O operation (e.g., ...). Figure 2As shown in ③), and continues to execute the next operation instruction. If the next operation instruction is an asynchronous operation instruction, such as asynchronous operation instruction 2 following asynchronous operation instruction 1, then asynchronous operation instruction 2 is executed in the same manner as asynchronous operation instruction 1, and so on, until a synchronous operation instruction is executed. In this embodiment, since asynchronous operation instructions 1-n in group 1 are all before synchronous operation instruction 0, synchronous operation instruction 0 will only be executed after all asynchronous operation instructions 1-n in group 1 are sent to target device 24 for execution. The asynchronous operation instructions in group 1 are processed through the same target device 24, meaning that target device 24 is the execution device for the asynchronous operation instructions in group 1. Furthermore, if a synchronous operation instruction is executed, such as... Figure 2 If the synchronization operation instruction 0 is executed, the target task will enter a waiting state, and the next task will be scheduled. During this process, the context information of the target task will be saved, and the target task will be moved from the execution queue to the waiting queue (e.g., ...). Figure 2 As shown in ④, the next task is obtained from the execution queue, and the context information of the next task is restored. Then, the operation instructions included in the next task can be executed based on the context information of the next task, while waiting for the asynchronous operation instructions in the target task to be completed.

[0059] In this context, the target device acts as the execution device for asynchronous operation instructions. The asynchronous operation instructions currently received by the target device within the target task are referred to as target asynchronous operation instructions. Upon receiving a target asynchronous operation instruction from the target task, the device can execute the instruction and determine whether it belongs to a group. If a group is identified, the device continues to receive and execute other asynchronous operation instructions within that group. Once all asynchronous operation instructions within the group have been executed, a response signal is sent back to the computer device or task scheduler to trigger the task scheduler to put the target task into a waiting-for-schedule state, awaiting rescheduling.

[0060] In this embodiment, to facilitate identification of whether an asynchronous operation instruction belongs to a group, grouping information can be added to asynchronous operation instructions belonging to the same group. Then, the target device can determine whether an asynchronous operation instruction belongs to a group by judging whether it carries grouping information. Furthermore, if the asynchronous operation instruction is identified as belonging to a group based on the grouping information, it can also be determined whether all asynchronous operation instructions in the same group (e.g., group 1) have been executed completely.

[0061] In this application embodiment, the implementation method of adding grouping information to asynchronous operation instructions is not limited. Optionally, in one embodiment, a grouping attribute can be added to asynchronous operation instructions belonging to a group. That is, the asynchronous operation instruction includes a grouping attribute, which is a description of the grouping information and is used to identify the grouping information to which the asynchronous operation instruction belongs. The grouping attribute can be located in a specific field, and the grouping information of the asynchronous operation instruction can be identified based on the specific field. Based on this, the target device can obtain the attribute information of the target asynchronous operation instruction, and if the attribute information includes a grouping attribute, determine that the target asynchronous operation instruction belongs to a group.

[0062] Optionally, the grouping attribute includes the identifier information of the group to which the asynchronous operation instruction belongs and the number of instructions in the group. The number of instructions is used by the target device to determine whether all asynchronous operation instructions in the same group have been executed successfully. Based on this, the target device can obtain the attribute information of the target asynchronous operation instruction. If the attribute information includes a grouping attribute, it can determine the group to which the target asynchronous operation instruction belongs based on the group identifier information included in the grouping attribute. Furthermore, it can determine whether all asynchronous operation instructions in the same group have been executed successfully based on the number of instructions included in the grouping attribute. When the number of executed asynchronous operation instructions belonging to the group reaches the number of instructions included in the grouping attribute, it is determined that all asynchronous operation instructions in the same group have been executed successfully, and a response signal is then fed back.

[0063] Alternatively, in another optional embodiment, a grouping marker can be added to the asynchronous operation instruction. That is, the asynchronous operation instruction carries a grouping marker, which serves as a marker for group information and identifies the group to which the asynchronous operation instruction belongs. The grouping marker can be implemented as a flag bit in the asynchronous operation instruction. Different marker information on the flag bit can represent different group information. For example, adding a grouping marker to a certain flag bit in the asynchronous operation instruction: if the grouping marker on that flag bit is 1, it means that the asynchronous operation instruction belongs to group 1; if the grouping marker on that flag bit is 2, it means that the asynchronous operation instruction belongs to group 2. It should be understood that the use of numbers as grouping markers here is merely an example and does not constitute a limitation on this embodiment. Any grouping marker that can be used to identify asynchronous operation instructions falls within the protection scope of this embodiment. Based on this, the target device can parse the target asynchronous operation instruction to obtain a parsing result. If the parsing result includes a grouping marker, it is determined that the target asynchronous operation instruction belongs to a group. Further optionally, the grouping marker can also include the number of asynchronous operation instructions contained in the same group. The target device can determine whether all asynchronous operation instructions in the same group have been executed completely based on the number of instructions included in the grouping marker.

[0064] In this embodiment, upon receiving a response signal, the task scheduler controls the target task to enter a pending scheduling state, awaiting rescheduling. In an optional implementation, controlling the target task to enter the pending scheduling state requires consuming processing units. Therefore, controlling the target task to enter the pending scheduling state involves the following operations: saving the context information of the current task, adding the current task to the waiting queue to free up processing units; the processing unit saves the execution results of asynchronous operation instructions in the same group in the context of the target task, and moves the target task from the waiting queue to the execution queue, awaiting rescheduling for execution. Here, the target task being in the waiting queue means the target task has entered a waiting state, and the target task being in the execution queue means the target task has entered a pending scheduling state. Whether the target task will be immediately rescheduled after entering the pending scheduling state is not limited. If the target task will not be immediately rescheduled, the current task with the saved context information can continue to be called, or the next task can be scheduled, depending on the scheduling strategy. If the target task is rescheduled, the context of the target task containing the execution results will be restored; and the target task will continue to execute, that is, the synchronous operation instructions awaiting the execution results will resume execution.

[0065] It should be understood that when a response signal is received, the response signal is used to mark that the asynchronous operation instructions of a certain group in the target task have been completed, and does not mean that the target task will be scheduled immediately. It depends on the scheduling strategy.

[0066] In this application embodiment, the method of feedback response signal from the target device is not limited. Two methods of feedback response signal are given below.

[0067] In an optional embodiment, the feedback method can be preemptive, that is, the target device sends a response signal by sending an interrupt request. The interrupt request is triggered when all asynchronous operation instructions in the same group that the target device is responsible for executing have been completed. When the task scheduler receives the interrupt request, it looks up the interrupt vector corresponding to the interrupt request from the interrupt vector table, executes the corresponding interrupt service routine according to the interrupt vector, and saves the execution result of the asynchronous operation instructions in the same group in the context of the target task in the interrupt service routine, and moves the target task from the waiting queue to the execution queue to wait for rescheduling.

[0068] In another alternative embodiment, the feedback method can be non-preemptive, such as... Figure 2 As shown, the target device writes a notification event to event queue 26. This notification event is written after all asynchronous operation instructions in the same group executed by the target device have been completed (e.g., ...). Figure 2As shown in Figure ⑥, the event queue 26 may include one or more notification events, such as Figure 2 The event queue 26 shown includes notification events 1 through p, where p ≥ 1 and p is a natural number. Optionally, event queue 26 can be implemented as a First-In-First-Out (FIFO) queue, meaning that notification events added to event queue 26 first are processed first. Furthermore, the task scheduler can query event queue 26, and if a notification event written by the target device is found in event queue 26, it retrieves the notification event as a response signal, such as... Figure 2 As shown in section ⑦. The task scheduler can query the event queue 26 periodically, or it can query the event queue 26 based on event triggers, or it can query the event queue 26 at irregular intervals, without any limitation.

[0069] Optionally, the implementation of the task scheduler will vary depending on its implementation form, and the method for querying the event queue will also differ. Querying the event queue includes: periodically querying the event queue or querying it upon triggering a set event when the task scheduler is implemented as a target process or target thread; and querying the event queue in response to scheduling by the main thread to which the target coroutine belongs when the main thread schedules the target coroutine upon completion of the previous coroutine or upon the previous coroutine actively requesting a switch. Upon finding a notification event corresponding to an asynchronous operation instruction in the same group as the target task, the target task is moved from the waiting queue to the execution queue to await rescheduling (e.g., ...). Figure 2 (As shown in Figure ⑧).

[0070] Therefore, it can be seen that the preemptive feedback method moves the target task directly from the waiting queue to the execution queue; while the non-preemptive feedback method moves the target task from the waiting queue to the execution queue only when a notification event corresponding to a certain group of the target task is found.

[0071] It should be understood that, regardless of whether the feedback method is preemptive or non-preemptive, the response signal fed back by the target device is used to mark that the asynchronous operation instructions of a certain group in the target task have been completed, and does not mean that the target task will be scheduled immediately. It depends on the scheduling strategy.

[0072] To illustrate the task scheduling method provided in the embodiments of this application, an example of a target task is given below, and the task scheduling method provided in the embodiments of this application is introduced in conjunction with this example.

[0073] First, let's look at an example task, such as... Figure 3As shown, the exemplary task includes three asynchronous operation instructions, namely Ready1, Ready2 and Ready3; and one synchronous operation instruction, D = A + B + C.

[0074] In this embodiment, when the exemplary task is scheduled, three asynchronous operation instructions, Ready1, Ready2, and Ready3, are executed sequentially, namely AsyncGet(&A.wait), AsyncGet(&B.wait), and AsyncGet(&C.wait), respectively, to read data A, B, and C. Upon execution of any asynchronous operation instruction, that instruction is sent to the target device 24, and the next instruction following that instruction is executed. This process continues, looping through the three asynchronous operation instructions until a synchronous operation instruction is reached. At this point, the exemplary task is blocked, and the next task is scheduled from the execution queue to wait for the asynchronous operation instruction to complete, i.e., until data A, B, and C have all been read.

[0075] If a response signal is sent back to the task scheduler upon completion of any asynchronous operation instruction, then... Figure 3 The three response signals are as follows: When data A is read completely, a response signal 1 is sent to the task scheduler. Upon receiving this response signal 1, the task scheduler performs a context switch. At this time, because it needs to continue waiting for the execution results of the asynchronous operation instructions Ready2 and Ready3, the synchronous operation instructions cannot be executed, and another context switch is required to schedule the next task. When data B is read completely, a response signal 2 is sent to the task scheduler. Upon receiving this response signal 2, the task scheduler performs a context switch. At this time, because it needs to continue waiting for the execution result of the asynchronous operation instruction Ready3, the synchronous operation instructions cannot be executed, and another context switch is required to schedule the next task. When data C is read completely, a response signal 3 is sent to the task scheduler. Upon receiving this response signal 3, the task scheduler performs a context switch. At this time, the synchronous operation instructions can be executed, and thus, the execution of the synchronous operation instructions resumes, that is, the execution of D = A + B + C resumes.

[0076] However, in the above process, each asynchronous operation instruction will send back a response signal, such as Figure 3In this system, response signals include response signals 1 through 3. The synchronization operation command waits for data A, B, and C to be read completely, meaning it waits until all response signals 1 through 3 are received before executing the synchronization operation command. The arrival times of different response signals may vary, and each response signal triggers a context switch. This leads to frequent context switches, resulting in significant context switching overhead, reduced available processing time, and decreased overall system performance.

[0077] However, in the embodiments of this application, the above exemplary task is improved to obtain the following: Figure 4 The target task is shown. See also Figure 4 The target task includes a group (e.g., group 2), which contains three related asynchronous operation instructions: Ready1, Ready2, and Ready3; a wait instruction, "io_group.wait", which is executed after the last asynchronous operation instruction (i.e., Ready3) in the same group and is used to trigger a switch from the target task to the next task; and a synchronous operation instruction, D = A + B + C, which is used to wait for the execution result of the asynchronous operation instruction and process the execution result.

[0078] In this embodiment, a response signal is fed back to the task scheduler after all asynchronous operation instructions in group 2 have been executed, that is, after A, B, and C have all been read (e.g., Figure 4 (The response signal for group 2 in the code). Upon receiving this response signal, the task scheduler performs a context switch: saving the context information of the current task and adding it to the waiting queue; saving the execution result of the asynchronous operation instruction in group 2 in the context of the target task, and moving the target task from the waiting queue to the execution queue to await rescheduling. When the target task is rescheduled, the context of the target task is restored, and the execution of the synchronous operation instruction is resumed (i.e., execution of D = A + B + C is resumed). Based on the context information containing the execution result of the asynchronous operation instruction, the synchronous operation instruction is processed, thus achieving one context switch for each asynchronous operation instruction in the same group, reducing the number of context switches and improving the overall system performance.

[0079] Figure 5 This is a flowchart illustrating a task generation method, provided as another exemplary embodiment of this application. For example... Figure 5 As shown, the method includes:

[0080] S501: Based on the description information of the target task, generate multiple operation instructions required by the target task and determine the execution order among the multiple operation instructions. The multiple operation instructions include synchronous operation instructions and asynchronous operation instructions.

[0081] S502: Identify asynchronous operation instructions with a relationship from asynchronous operation instructions, group at least some of the asynchronous operation instructions with a relationship into the same group, and the same group includes two or more asynchronous operation instructions;

[0082] S503: Generate the target task based on the execution order of multiple operation instructions and the asynchronous operation instructions with related relationships in the same group.

[0083] In this embodiment, based on the parsing of the description information of the target task, multiple operation instructions and dependencies between multiple operation steps can be generated. These dependencies mean that the execution of any operation instruction depends on the execution result of other operation instructions. The execution order of multiple operation instructions can be determined through these dependencies. Optionally, during the parsing of the description information, based on the workflow of the target task, the target task is parsed into multiple operation instructions; instructions that initiate I / O operations are set as asynchronous operation instructions; and instructions other than asynchronous operation instructions in the multiple operation steps are set as synchronous operation instructions. The synchronous operation instructions may include instructions for processing the execution result of the asynchronous operation instructions. Furthermore, based on the dependencies between the multiple operation instructions in the description information, the execution order of the multiple operation instructions is determined.

[0084] Optionally, asynchronous operation instructions with related relationships can be identified from asynchronous operation instructions based on the dependencies between multiple operation steps. In this optional embodiment, taking the example that the execution of a synchronous operation instruction depends on the execution result of an asynchronous operation instruction, there is a dependency between synchronous and asynchronous operation instructions. Asynchronous operation instructions that are dependent on the synchronous operation step are grouped into the same group. Asynchronous operation instructions within the same group are related, meaning that the asynchronous operation instructions in the same group commonly depend on one or more synchronous operation instructions. Therefore, in this optional embodiment, when identifying asynchronous operation instructions with related relationships from asynchronous operation instructions, asynchronous operation instructions that are dependent on synchronous operation instructions are grouped into the same group, and asynchronous operation instructions within the same group are related.

[0085] Furthermore, a target task is generated based on the execution order of multiple operation instructions and the asynchronous operation instructions with related relationships in the same group.

[0086] In one optional embodiment, at least some asynchronous operation instructions with a relationship are grouped into the same group to obtain grouping information, including: adding a grouping attribute to the at least some asynchronous operation instructions with a relationship, the grouping attribute being used to identify the grouping information to which the asynchronous operation instruction belongs; or, adding a grouping tag to the at least some asynchronous operation instructions with a relationship, the grouping tag being used to identify the grouping information to which the asynchronous operation instruction belongs.

[0087] In one optional embodiment, the grouping attribute includes the identification information of the group to which the asynchronous operation instruction belongs and the number of instructions in the group to which the asynchronous operation instruction belongs. The number of instructions is used to determine whether all asynchronous operation instructions in the same group have been executed.

[0088] For a detailed description of the implementation process and technical effects of this method, please refer to the foregoing embodiments, which will not be repeated here.

[0089] Figure 6 This is a flowchart illustrating a task notification method, provided as another exemplary embodiment of this application. Figure 6 As shown, the method includes:

[0090] S601: Receive the target asynchronous operation instruction in the target task and execute the target asynchronous operation instruction, wherein at least some of the asynchronous operation instructions with a relationship in the target task are divided into the same group;

[0091] S602: If it is recognized that the target asynchronous operation instruction belongs to a group, continue to receive and execute other asynchronous operation instructions in the group;

[0092] S603: When all asynchronous operation instructions belonging to the group have been executed, a response signal is sent to the task scheduler to trigger the task scheduler to control the target task to enter the waiting state for rescheduling.

[0093] In this embodiment, at least some asynchronous operation instructions that are related in the target task are grouped into the same group, and the same group includes two or more asynchronous operation instructions.

[0094] In one optional embodiment, identifying that the target asynchronous operation instruction belongs to a group includes: obtaining attribute information of the target asynchronous operation instruction, and determining that the target asynchronous operation instruction belongs to a group if the attribute information includes a group attribute; or, parsing the target asynchronous operation instruction to obtain a parsing result, and determining that the target asynchronous operation instruction belongs to a group if the parsing result includes a group tag.

[0095] In one optional embodiment, when all asynchronous operation instructions belonging to the group have been executed, a response signal is fed back to the task scheduler, including: triggering an interrupt request to be sent to the task scheduler when all asynchronous operation instructions belonging to the group have been executed, wherein the interrupt request is the response signal; or, writing a notification event to the event queue of the task scheduler when all asynchronous operation instructions belonging to the group have been executed, wherein the notification event is the response signal.

[0096] For a detailed description of the implementation process and technical effects of this method, please refer to the foregoing embodiments, which will not be repeated here.

[0097] The above embodiments introduced a task scheduling method, a task notification method, and a task generation method. The following will combine... Figure 7 This paper introduces how to apply the above task scheduling methods in cloud scenarios.

[0098] Figure 7 This is a schematic diagram of the structure of a computer device provided for an exemplary embodiment of this application. For example... Figure 7 As shown in the embodiments of this application, the computer device includes hardware resources 71, such as, but not limited to, CPU, memory and GPU; in addition, the hardware resources 71 of the computer device also include various external devices 73 such as network card, memory, communication components, display, audio components, etc.

[0099] On top of hardware resource 71, a task scheduler 76 and a target program run. The target program has I / O devices and includes at least one task. The at least one task includes a target task. The target task includes multiple operation instructions, including synchronous operation instructions and asynchronous operation instructions. At least some of the asynchronous operation instructions that are related are grouped into the same group, and the same group includes two or more asynchronous operation instructions. Figure 7 In the illustrated embodiment, the task scheduler 76 is taken as the task scheduler 76 in the host machine's operating system 77.

[0100] The task scheduler 76 is used to schedule the target task and execute multiple operation instructions in the order of execution. If an asynchronous operation instruction is executed, the next operation instruction is executed. If a synchronous operation instruction is executed, the target task is controlled to enter a waiting state and the next task is scheduled to wait for the asynchronous operation instruction to be completed. When all asynchronous operation instructions in the same group have been completed, the target task is controlled to enter a waiting state to wait to be rescheduled.

[0101] In an alternative embodiment, such as Figure 7As shown, a virtualization manager 72 runs on the hardware resources 71 of the computer device. When the target program is implemented as a virtualization instance, one or more virtualization instances run on the virtualization manager 72. The virtualization instances can be cloud hosts, Elastic Compute Service (ECS), virtual machines, or containers, etc. The virtualization manager 72 is responsible for creating and maintaining these virtualization instances.

[0102] In an alternative embodiment, such as Figure 7 As shown, the virtualization manager 72 includes KVM (Kernel-based Virtual Machine) 75 and QEMU (Quick EMUlator) 74. QEMU 74 is a user-space virtualization software. KVM 75 relies on QEMU 74 to emulate I / O devices, such as virtual network cards and virtual disk controllers, to virtualize external devices 73 of the computer, thereby providing virtualized I / O devices for the virtualization instance. The combination of KVM 75 and QEMU 74 can provide a complete virtualization solution. Alternatively, passthrough technology can be used, allowing the virtualization instance to directly access the external devices 73 of the computer through the virtualization manager. In this case, the external devices 73 can act as passthrough I / O devices for the virtualization instance, avoiding the emulation and filtering by the virtualization manager. The virtualization instance's operation commands are directly sent to the peripheral devices, reducing performance overhead.

[0103] KVM 75 is located in the host machine's operating system 77, QEMU 74 is located in the host machine's user space, and the virtualization instance is located in the host machine's user space.

[0104] In this scenario, an application can run on a virtualized instance, and the application includes multiple tasks. Of course, as a software product, a virtualized instance can also include multiple tasks. Based on this, in this scenario, the target program mentioned above can be not only a virtualized instance, but also an application running on a virtualized instance; correspondingly, the I / O device of the target program is a pass-through I / O device or a virtualized I / O device.

[0105] Even when the target program is implemented as a virtualized instance or an application running within a virtualized instance, the task scheduling method provided in the above embodiments of this application can still be used to schedule tasks in the target program, such as... Figure 7 As shown. For a detailed implementation process of task scheduling, please refer to the aforementioned embodiments, which will not be repeated here.

[0106] In a virtualized scenario, at least some asynchronous operation instructions with a relationship in the target task are grouped into the same group. During the execution of asynchronous operation instructions in the same group, the task scheduler can schedule other tasks for execution. When all asynchronous operation instructions in the same group have been completed, the execution device of the asynchronous operation instructions uniformly feeds back a response signal, realizing the aggregation of response signals for asynchronous operation instructions. After receiving the response signal, the task scheduler performs a task context switch to switch back to the target task for continued execution. Compared with the scheme of feeding back a response signal and triggering a task context switch after each asynchronous operation instruction is completed, feeding back a response signal uniformly for asynchronous operation instructions in the same group by group can reduce the number of response signals, thereby reducing the number of task context switches, reducing the resources consumed by context switches, and improving the overall task execution performance.

[0107] The detailed implementation methods and beneficial effects of each step in this embodiment have been described in detail in the foregoing embodiments, and will not be elaborated here.

[0108] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 to 103 can be device A; or the execution subject of steps 101 and 102 can be device A, and the execution subject of step 103 can be device B; and so on.

[0109] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0110] Figure 8 This is a schematic diagram of the structure of an electronic device provided as another exemplary embodiment of this application. For example... Figure 8 As shown, the electronic device includes a memory 84 and a processor 85.

[0111] Memory 84 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device, contact data, phone book data, messages, pictures, videos, etc.

[0112] The memory 84 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0113] Processor 85, coupled to memory 84, is configured to execute a computer program in memory 84 for: scheduling a target task, the target task comprising a plurality of operation instructions, the plurality of operation instructions including synchronous operation instructions and asynchronous operation instructions, wherein at least some asynchronous operation instructions that are related are grouped into the same group, and the same group includes two or more asynchronous operation instructions; executing the plurality of operation instructions in the order of execution; if an asynchronous operation instruction is executed, continuing to execute the next operation instruction; if a synchronous operation instruction is executed, controlling the target task to enter a waiting state and scheduling the next task to wait for the asynchronous operation instructions to complete; and, if all asynchronous operation instructions in the same group have been executed, controlling the target task to enter a pending scheduling state to wait to be rescheduled.

[0114] In one optional embodiment, the asynchronous operation instruction includes a grouping attribute, which is used to identify the group information to which the asynchronous operation instruction belongs; or, the asynchronous operation instruction has a grouping tag, which is used to identify the group information to which the asynchronous operation instruction belongs.

[0115] In one optional embodiment, the grouping attribute includes the identifier information of the group to which the asynchronous operation instruction belongs and the number of instructions in the group to which the asynchronous operation instruction belongs. The number of instructions is used to determine whether all asynchronous operation instructions in the same group have been executed completely. In one optional embodiment, when the processor 85 controls the target task queue to enter a waiting state, it is specifically used to: add the target task to the waiting queue, the waiting queue being used to store tasks in a waiting state.

[0116] In an optional embodiment, when the processor 85 has completed the execution of all asynchronous operation instructions in the same group, it controls the target task to enter a waiting-to-schedule state to wait for rescheduling. Specifically, this is done by: upon receiving response signals from the target device for the asynchronous operation instructions in the same group, controlling the target task to enter a waiting-to-schedule state to wait for rescheduling; or, upon receiving a unified response signal from the target device for the asynchronous operation instructions in the same group, controlling the target task to enter a waiting-to-schedule state to wait for rescheduling.

[0117] In an optional embodiment, when the processor 85 receives a response signal from the target device regarding the unified feedback of asynchronous operation instructions in the same group, and controls the target task to enter a waiting-to-be-scheduled state to wait for rescheduling, specifically: upon receiving the unified feedback response signal from the target device, saving the context information of the current task and adding the current task to the waiting queue; saving the execution results of the asynchronous operation instructions in the same group in the context of the target task, and moving the target task from the waiting queue to the execution queue to wait for rescheduling, wherein the execution queue is used to store tasks in the waiting-to-be-scheduled state.

[0118] In an optional embodiment, when the processor 85 receives a response signal uniformly fed back by the target device, it is specifically configured to: receive an interrupt request triggered by the target device as the response signal, wherein the interrupt request is triggered when all asynchronous operation instructions in the same group executed by the target device have been completed; or, query the event queue, and if a notification event written by the target device is found in the event queue, obtain the notification event as the response signal, wherein the notification event is written when all asynchronous operation instructions in the same group executed by the target device have been completed.

[0119] In an optional embodiment, when the processor 85 saves the execution result of the asynchronous operation instructions in the same group in the context of the target task and moves the target task from the waiting queue to the execution queue, it is specifically configured to: execute the interrupt service routine corresponding to the interrupt request when the response signal is implemented as an interrupt request; in the interrupt service routine, save the execution result of the asynchronous operation instructions in the same group in the context of the target task and move the target task from the waiting queue to the execution queue.

[0120] In an optional embodiment, the method is applied to a task scheduler, which is implemented as a target process or target thread in an operating system responsible for task scheduling, or as a target coroutine in an application to which the target task belongs responsible for task scheduling; when the processor 85 queries the event queue, it includes: periodically querying the event queue or querying it under the triggering of a set event when the task scheduler is implemented as a target process or target thread; and querying the event queue in response to the scheduling of the main thread to which the target coroutine belongs when the task scheduler is implemented as a target coroutine, wherein the main thread schedules the target coroutine when the previous coroutine finishes execution or when the previous coroutine actively requests a switch.

[0121] In an optional embodiment, the synchronous operation instructions in the target task include: a waiting instruction adapted to the asynchronous operation instructions in the same group, wherein the execution order of the waiting instruction is after the last asynchronous operation instruction in the same group, so as to trigger a switch from the target task to the next task.

[0122] In one alternative embodiment, the target task is a task within a cloud service, cloud application, or cloud instance.

[0123] Furthermore, such as Figure 8 As shown, the electronic device also includes other components such as a communication component 86, a display 87, a power supply component 88, and an audio component 89. Figure 8 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 8 The components shown. Additionally... Figure 8 The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the electronic device. The electronic device in this embodiment can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT device, or a server-side device such as a conventional server, cloud server, or server array. If the electronic device in this embodiment is a terminal device such as a desktop computer, laptop computer, or smartphone, it may include... Figure 8 The components within the dashed box; if the electronic device in this embodiment is implemented as a conventional server, cloud server, or server array, etc., it may be omitted. Figure 8 The component within the dashed box.

[0124] This application also provides an electronic device, the implementation structure of which is similar to... Figure 8 The implementation structure of the electronic devices shown is the same or similar, and can be referred to accordingly. Figure 8 The structure of the electronic device shown is implemented. The electronic device provided in this embodiment is similar to... Figure 8The main difference between the electronic devices in the illustrated embodiments lies in the different functions implemented by the computer programs stored in the memory executed by the processors in the electronic devices. For the electronic device provided in this embodiment, the computer programs stored in the memory executed by its processor can be used to: generate multiple operation instructions required by the target task based on the description information of the target task, and determine the execution order of the multiple operation instructions, wherein the multiple operation instructions include synchronous operation instructions and asynchronous operation instructions; identify asynchronous operation instructions with related relationships from the asynchronous operation instructions, and group at least some of the asynchronous operation instructions with related relationships into the same group; and generate the target task based on the execution order of the multiple operation instructions and the asynchronous operation instructions with related relationships in the same group.

[0125] In one optional embodiment, when the processor divides at least some asynchronous operation instructions with a relationship into the same group to obtain grouping information, it specifically uses the following methods: adding a grouping attribute to the at least some asynchronous operation instructions with a relationship, the grouping attribute being used to identify the grouping information to which the asynchronous operation instructions belong; or, adding a grouping tag to the at least some asynchronous operation instructions with a relationship, the grouping tag being used to identify the grouping information to which the asynchronous operation instructions belong.

[0126] This application also provides an electronic device, the implementation structure of which is similar to... Figure 8 The implementation structure of the electronic devices shown is the same or similar, and can be referred to accordingly. Figure 8 The structure of the electronic device shown is implemented. The electronic device provided in this embodiment is similar to... Figure 8 The main difference between the electronic devices in the illustrated embodiments lies in the different functions implemented by the processors executing the computer programs stored in the memory. For the electronic device provided in this embodiment, the processor executing the computer programs stored in the memory can be used to: receive and execute target asynchronous operation instructions in a target task, wherein at least some asynchronous operation instructions with a relationship in the target task are grouped into the same group; upon recognizing that the target asynchronous operation instructions belong to a group, continue to receive and execute other asynchronous operation instructions in the group; and after all asynchronous operation instructions belonging to the group have been executed, send a response signal to the task scheduler to trigger the task scheduler to control the target task to enter a waiting-to-be-scheduled state, awaiting rescheduling.

[0127] In an optional embodiment, when the processor identifies that the target asynchronous operation instruction belongs to a group, it is specifically configured to: obtain attribute information of the target asynchronous operation instruction, and determine that the target asynchronous operation instruction belongs to a group if the attribute information includes a group attribute; or, parse the target asynchronous operation instruction to obtain a parsing result, and determine that the target asynchronous operation instruction belongs to a group if the parsing result includes a group tag.

[0128] In an optional embodiment, when the processor sends a response signal to the task scheduler after all asynchronous operation instructions belonging to the group have been executed, it is specifically configured to: send an interrupt request to the task scheduler after all asynchronous operation instructions belonging to the group have been executed, wherein the interrupt request is the response signal; or, write a notification event to the event queue of the task scheduler after all asynchronous operation instructions belonging to the group have been executed, wherein the notification event is the response signal.

[0129] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the methods described above.

[0130] This application also provides a computer program product, which includes a computer program / instructions that, when executed by a processor, enable the processor to implement the steps described in the above method embodiments.

[0131] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0132] The aforementioned communication components are configured to facilitate wired or wireless communication between the device containing the communication components and other devices. The device containing the communication components can access wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication components receive broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication components also include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.

[0133] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.

[0134] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.

[0135] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0136] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) containing computer-usable program code.

[0137] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0138] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0139] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0140] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.

[0141] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0142] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0143] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0144] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A task scheduling method, characterized by, The method comprises the following steps: Scheduling a target task, the target task comprising a plurality of operation instructions, the plurality of operation instructions comprising synchronous operation instructions and asynchronous operation instructions, and at least part of the asynchronous operation instructions having an association relationship being divided into a same group, and the same group comprising two or more asynchronous operation instructions; Executing the plurality of operation instructions according to an execution sequence between the plurality of operation instructions, if an asynchronous operation instruction is executed, continuing to execute a next operation instruction, if a synchronous operation instruction is executed, controlling the target task to enter a waiting state, and scheduling a next task to wait for the asynchronous operation instruction to be executed completely; In a case where all the asynchronous operation instructions in the same group are executed completely, controlling the target task to enter a state of being ready to be scheduled to wait for being scheduled again.

2. The method of claim 1, wherein, The asynchronous operation instruction comprises a group attribute, the group attribute being used for identifying group information to which the asynchronous operation instruction belongs; or the asynchronous operation instruction comprises a group mark, the group mark being used for identifying group information to which the asynchronous operation instruction belongs.

3. The method of claim 2, wherein, The group attribute comprises identification information of a group to which the asynchronous operation instruction belongs and a number of instructions in the group to which the asynchronous operation instruction belongs, and the number of instructions is used for determining whether all the asynchronous operation instructions in the same group are executed completely.

4. The method of claim 1, wherein, Controlling the target task queue to enter the waiting state comprises the following steps: Adding the target task to a waiting queue, the waiting queue being used for storing tasks in the waiting state.

5. The method of claim 4, wherein, In a case where all the asynchronous operation instructions in the same group are executed completely, controlling the target task to enter the state of being ready to be scheduled to wait for being scheduled again comprises the following steps: In a case where a response signal respectively fed back by a target device for the asynchronous operation instructions in the same group is received, controlling the target task to enter the state of being ready to be scheduled to wait for being scheduled again; Or In a case where a response signal uniformly fed back by the target device for the asynchronous operation instructions in the same group is received, controlling the target task to enter the state of being ready to be scheduled to wait for being scheduled again.

6. The method of claim 5, wherein, In a case where a response signal uniformly fed back by the target device for the asynchronous operation instructions in the same group is received, controlling the target task to enter the state of being ready to be scheduled to wait for being scheduled again comprises the following steps: In a case where the response signal uniformly fed back by the target device is received, saving context information of a current task, and adding the current task to the waiting queue; Saving an execution result of the asynchronous operation instructions in the same group in the context of the target task, and moving the target task from the waiting queue to an execution queue to wait for being scheduled again, the execution queue being used for storing tasks in the state of being ready to be scheduled.

7. The method of claim 5, wherein, Receiving the response signal uniformly fed back by the target device comprises the following steps: Receiving an interrupt request triggered by the target device as the response signal, the interrupt request being triggered in a case where all the asynchronous operation instructions in the same group executed by the target device are executed completely; Or In the case that the target device writes a notification event in the event queue, the notification event is obtained as the response signal, and the notification event is written in the case that all asynchronous operation instructions in the same group are executed.

8. The method of claim 7, wherein, The execution result of the asynchronous operation instructions in the same group is saved in the context of the target task, and the target task is moved from the waiting queue to the execution queue, including: In the case that the response signal is implemented as an interrupt request, an interrupt service program corresponding to the interrupt request is executed; In the interrupt service program, the execution result of the asynchronous operation instructions in the same group is saved in the context of the target task, and the target task is moved from the waiting queue to the execution queue.

9. The method of claim 7, wherein, The method is applied to a task scheduler, which is implemented as a target process or a target thread responsible for task scheduling in an operating system, or as a target coroutine responsible for task scheduling in an application to which the target task belongs; In the case that the task scheduler is implemented as a target process or a target thread, the event queue is queried periodically or upon triggering of a set event; In the case that the task scheduler is implemented as a target coroutine, the event queue is queried in response to scheduling of a main thread to which the target coroutine belongs, wherein the main thread schedules the target coroutine in the case that execution of a previous coroutine ends or in the case that the previous coroutine actively requests switching. The synchronous operation instruction in the target task includes a wait instruction adapted to the asynchronous operation instructions in the same group, and the execution order of the wait instruction is located after the last asynchronous operation instruction in the same group, so as to trigger switching from the target task to a next task.

10. The method according to any one of claims 1 to 9, characterized in that, The target task is a task in a cloud service, a cloud application or a cloud instance.

11. The method according to any one of claims 1 to 9, characterized in that, The method comprises:

12. A task generation method characterized by comprising: According to the description information of the target task, a plurality of operation instructions required by the target task are generated, and the execution order between the plurality of operation instructions is determined, wherein the plurality of operation instructions include synchronous operation instructions and asynchronous operation instructions; At least part of the asynchronous operation instructions having a correlation relationship are divided into the same group, and the same group includes two or more asynchronous operation instructions; The target task is generated according to the execution order between the plurality of operation instructions and the asynchronous operation instructions having a correlation relationship in the same group. At least part of the asynchronous operation instructions having a correlation relationship are divided into the same group, including:

13. The method of claim 12, wherein, A group attribute is added to at least part of the asynchronous operation instructions having a correlation relationship, and the group attribute is used to identify group information to which the asynchronous operation instructions belong; Or, a group mark is added to at least part of the asynchronous operation instructions having a correlation relationship, and the group mark is used to identify group information to which the asynchronous operation instructions belong. ​ 14. The method of claim 13, wherein, The group attribute includes identification information of a group to which the asynchronous operation instruction belongs and a number of instructions in the group to which the asynchronous operation instruction belongs, and the number of instructions is used to determine whether the asynchronous operation instructions in the same group are all executed.

15. A task notification method characterized by comprising: Comprise: Receiving a target asynchronous operation instruction in a target task, and executing the target asynchronous operation instruction, at least part of the asynchronous operation instructions with an association relationship in the target task are divided into the same group; In the case of identifying that the target asynchronous operation instruction belongs to a group, continue to receive and execute other asynchronous operation instructions in the group; In the case of all asynchronous operation instructions in the group being executed, a response signal is fed back to the task scheduler to trigger the task scheduler to control the target task to enter a scheduling state to wait to be scheduled again.

16. The method of claim 15, wherein, Identifying that the target asynchronous operation instruction belongs to a group comprises: Obtaining attribute information of the target asynchronous operation instruction, and in the case that the attribute information includes a group attribute, determining that the target asynchronous operation instruction belongs to a group; Or Analyzing the target asynchronous operation instruction to obtain an analysis result, and in the case that the analysis result includes a group marker, determining that the target asynchronous operation instruction belongs to a group.

17. The method according to claim 15 or 16, characterized in that In the case of all asynchronous operation instructions in the group being executed, a response signal is fed back to the task scheduler, comprising: In the case of all asynchronous operation instructions in the group being executed, an interrupt request is sent to the task scheduler, and the interrupt request is the response signal; Or In the case of all asynchronous operation instructions in the group being executed, a notification event is written into an event queue of the task scheduler, and the notification event is the response signal.

18. A computer device, comprising: Comprise: A host computer, the host computer running a task scheduler and a target program, the target program having an input and output (IO) device, the target program including at least one task, the at least one task including a target task, the target task including a plurality of operation instructions, the plurality of operation instructions including synchronous operation instructions and asynchronous operation instructions, and at least part of the asynchronous operation instructions with an association relationship being divided into the same group, and the same group including two or more asynchronous operation instructions; The task scheduler is configured to schedule the target task, execute the plurality of operation instructions according to an execution order between the plurality of operation instructions, continue to execute a next operation instruction if an asynchronous operation instruction is executed, control the target task to enter a waiting state and schedule a next task if a synchronous operation instruction is executed, wait for the execution of the asynchronous operation instruction to be completed, and control the target task to enter a scheduling state to wait to be scheduled again in the case of all asynchronous operation instructions in the same group being executed.

19. The computer device of claim 18, wherein, The host computer further runs a virtualization manager, the target program is a virtualization instance created by the virtualization manager or an application program running in the virtualization instance, and the IO device of the target program is a pass-through IO device or a virtualized IO device.

20. An electronic device, comprising: A computer program product comprising a computer readable medium having stored thereon instructions that, when executed by a computer, cause the computer to perform the steps of any of the methods of claims 1-11, claims 12-14, and claims 15-17.

21. A computer readable storage medium storing computer programs / instructions, characterized in that, A computer program product comprising a computer readable medium having stored thereon instructions that, when executed by a computer, cause the computer to perform the steps of any of the methods of claims 1-11, claims 12-14, and claims 15-17.

22. A computer program product, characterised in that, A computer program product comprising a computer readable medium having stored thereon instructions that, when executed by a computer, cause the computer to perform the steps of any of the methods of claims 1-11, claims 12-14, and claims 15-17. A computer program product comprising a computer readable medium having stored thereon instructions that, when executed by a computer, cause the computer to perform the steps of any of the methods of claims 1-11, claims 12-14, and claims 15-17.

Citation Information

Cited By

  • Communication processing method and apparatus, electronic device, storage medium, and program product

    CN121957943B