Scheduling method and device for large-scale concurrent tasks
By implementing a signal cache-based task scheduling method on the embedded processor, the problem of resource limitations and strict delay requirements is solved, and the processing efficiency and delay performance of large-scale concurrent tasks are improved.
Patent Information
- Application Number
- CN201811123827.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-09-26
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2038-09-26
AI Technical Summary
When handling large-scale concurrent tasks, embedded processors face resource limitations and strict task processing delay requirements, and existing operating systems are difficult to effectively schedule, resulting in too long delays in processing individual tasks.
Provides a task scheduling method that schedules tasks by obtaining signals and responding to resource availability. If resources are unavailable, the signal is added to the signal cache. The signal is obtained from the signal cache and the corresponding task processing unit is called. The signal type and signal cache are used. In one-to-one correspondence, the type is identified based on the signal value and the corresponding task is called.
It effectively shortens the processing delay of IO commands, avoids excessive processing delays of individual tasks, and improves the processing efficiency of large-scale concurrent tasks by embedded processors.
Smart Images

Figure CN110955500B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to task scheduling, and in particular, to a method and device for scheduling large-scale concurrent tasks processed on an embedded processor. Background Art
[0002] In some applications, embedded processors handle large-scale concurrent tasks, such as embedded processors used in network devices and storage devices, which handle multiple concurrent network packets or IO commands.
[0003] In desktop CPUs and server CPUs, the operating system is running, and the operating system schedules multiple processes and / or threads running on the CPU to handle tasks. Users do not need to intervene too much in the switching between processes / threads, and the operating system selects the appropriate process / thread for scheduling to fully utilize the CPU computing power. However, in embedded CPUs, available memory, CPU processing power and other resources are limited. In addition, some embedded systems have strict requirements on performance, especially task processing delay, and the operating system is difficult to apply to this scenario. Summary of the invention
[0004] Taking storage devices that process IO commands as an example, the processing of each IO command includes multiple stages, and each stage may not be processed consecutively in time due to waiting for hardware resources to be ready. Storage devices need to be able to process a large number of IO commands at the same time, and also need to try to shorten the processing delay of IO commands and avoid excessive processing delays for individual IO commands. Therefore, it is necessary to effectively schedule each IO command and the processing tasks of each stage of IO commands.
[0005] According to the first aspect of the present application, a first task scheduling method according to the first aspect of the present application is provided, which includes the following steps: acquiring a signal; in response to the availability of resources required for the task corresponding to the signal to process the signal, scheduling the task of processing the signal.
[0006] According to the second task scheduling method of the first aspect of the present application, a second task scheduling method of the first aspect of the present application is provided, wherein if resources for processing the task corresponding to the signal are unavailable, the signal is added to a signal cache.
[0007] According to the second task scheduling method of the first aspect of the present application, a third task scheduling method of the first aspect of the present application is provided, wherein a signal is obtained from a signal buffer, and a task for processing the obtained signal is called.
[0008] According to any one of the first to third task scheduling methods of the first aspect of the present application, a fourth task scheduling method of the first aspect of the present application is provided, wherein the types of signals correspond one-to-one to the signal caches.
[0009] According to the fourth task scheduling method of the first aspect of the present application, a fifth task scheduling method of the first aspect of the present application is provided, wherein the type of signal is identified according to the value of the signal, and each type of signal has a corresponding task for processing the signal.
[0010] According to the task scheduling method of any one of the first to fifth items of the first aspect of the present application, a sixth task scheduling method of the first aspect of the present application is provided, wherein, according to the type of the signal, the signal is added to a signal cache corresponding to the same signal type.
[0011] According to the sixth task scheduling method of the first aspect of the present application, a seventh task scheduling method of the first aspect of the present application is provided, wherein a signal is obtained from a signal cache, and a task corresponding to the same signal type is called according to the type of the signal.
[0012] According to the sixth task scheduling method of the first aspect of the present application, an eighth task scheduling method of the first aspect of the present application is provided, wherein the acquired signal is used as an index to obtain the scheduled task.
[0013] According to any one of the first to ninth task scheduling methods of the first aspect of the present application, a ninth task scheduling method of the first aspect of the present application is provided, wherein the signal cache is selected in a random, round-robin, weighted round-robin, or other manner.
[0014] According to the ninth task scheduling method of the first aspect of the present application, a tenth task scheduling method of the first aspect of the present application is provided, wherein the priority of the signal cache is set.
[0015] According to the task scheduling method of any one of the first to third items of the first aspect of the present application, an eleventh task scheduling method of the first aspect of the present application is provided, wherein the signal is used to process IO commands, and the signal cache corresponds one-to-one to the IO commands.
[0016] According to the eleventh task scheduling method of the first aspect of the present application, a twelfth task scheduling method of the first aspect of the present application is provided, wherein, in response to the availability of resources required for processing the task corresponding to the signal, it is identified whether processing of the IO command indicated by the signal has started.
[0017] According to the twelfth task scheduling method of the first aspect of the present application, a thirteenth task scheduling method of the first aspect of the present application is provided, wherein, if it is identified that the IO command indicated by the signal has not yet started, the signal is added to the signal cache corresponding to the IO command indicated by the signal.
[0018] According to the twelfth or thirteenth task scheduling method of the first aspect of the present application, a fourteenth task scheduling method of the first aspect of the present application is provided, wherein if it is recognized that the IO command indicated by the signal has started, a task for processing the acquisition signal is scheduled.
[0019] According to the task scheduling method of any one of items twelfth to fourteenth of the first aspect of the present application, a fifteenth task scheduling method of the first aspect of the present application is provided, wherein, if resources for processing the task corresponding to the signal are not available, according to the IO command corresponding to the signal, the signal is added to a signal cache corresponding to the IO command.
[0020] According to the fifteenth task scheduling method of the first aspect of the present application, a sixteenth task scheduling method of the first aspect of the present application is provided, wherein, in response to starting to process a new IO command, a new signal buffer is allocated for the new IO command.
[0021] According to the task scheduling method of any one of items twelfth to fourteenth of the first aspect of the present application, a seventeenth task scheduling method of the first aspect of the present application is provided, wherein a signal is obtained from a signal cache, and a task for processing the obtained signal is called.
[0022] According to the seventeenth task scheduling method of the first aspect of the present application, an eighteenth task scheduling method of the first aspect of the present application is provided, wherein the signal cache is selected according to the priority of the signal cache.
[0023] According to the eighteenth task scheduling method of the first aspect of the present application, a nineteenth task scheduling method of the first aspect of the present application is provided, wherein the priority of each signal cache is set according to the time when the IO command corresponding to the signal cache starts to be processed.
[0024] According to the eighteenth task scheduling method of the first aspect of the present application, a twentieth task scheduling method of the first aspect of the present application is provided, wherein the priority of the signal cache is set according to the order in which the IO commands are started to be processed.
[0025] According to the eighteenth or twentieth task scheduling method of the first aspect of the present application, a twenty-first task scheduling method of the first aspect of the present application is provided, wherein the sequence number of the processing of the recorded IO commands is incremented, and the priority of the signal cache is set using the incremented sequence number.
[0026] According to the task scheduling method of any one of items 11 to 21 of the first aspect of the present application, a twenty-second task scheduling method of the first aspect of the present application is provided, wherein, in response to the IO command being processed, the signal cache accommodating its corresponding signal is recycled or allocated to a new IO command.
[0027] According to the task scheduling method of any one of items 11 to 22 of the first aspect of the present application, a twenty-third task scheduling method of the first aspect of the present application is provided, wherein the IO command includes multiple stages, the signal indicates one of the stages of the IO command, and the signals corresponding to the multiple stages of the same IO command are processed according to the order of the multiple stages in the IO command.
[0028] According to the twenty-third task scheduling method of the first aspect of the present application, a twenty-fourth task scheduling method of the first aspect of the present application is provided, wherein processing the IO command includes sequential S1 and S2 stages.
[0029] According to the twenty-third or twenty-fourth task scheduling method of the first aspect of the present application, a twenty-fifth task scheduling method of the first aspect of the present application is provided, wherein if the signal indicates the S1 stage of the IO command, the processing of the IO command has not yet been started; if the signal indicates that the processing is the S2 stage of the IO command, the processing of the IO command has been started.
[0030] According to the task scheduling method of any one of items 1 to 25 of the first aspect of the present application, a twenty-sixth task scheduling method of the first aspect of the present application is provided, wherein the signal has a quota, and if the quota of the signal is greater than a threshold, the task of processing the acquired signal is scheduled.
[0031] According to the twenty-sixth task scheduling method of the first aspect of the present application, a twenty-seventh task scheduling method of the first aspect of the present application is provided, wherein if the quota of the signal is not greater than a threshold, the signal is added to a signal cache.
[0032] According to the twenty-sixth task scheduling method of the first aspect of the present application, a twenty-eighth task scheduling method of the first aspect of the present application is provided, wherein the task for processing the acquired signal is called to reduce the quota by a specified amount.
[0033] According to the task scheduling method of any one of items 1 to 28 of the first aspect of the present application, a twenty-ninth task scheduling method of the first aspect of the present application is provided, wherein, in response to obtaining a signal, the CPU or thread of the task corresponding to the running signal is identified, and the signal is added to the signal cache of the CPU or thread belonging to the task corresponding to the running signal.
[0034] According to the second aspect of the present application, a first task management unit is provided, which also includes a signal distribution unit, one or more signal caches and a task scheduling unit; the signal distribution unit adds the signal to one of the signal caches; the task scheduling unit selects one of the signal caches, takes the signal from the selected signal cache, and schedules one or more task processing units to process the task indicated by the signal.
[0035] According to the first task management unit of the second aspect of the present application, a second task management unit of the second aspect of the present application is provided, wherein the signal distribution unit schedules the task processing unit to process the task indicated by the signal in response to the availability of resources required for the task corresponding to the signal, without adding the signal to the signal cache.
[0036] According to the first task management unit of the second aspect of the present application, a third task management unit of the second aspect of the present application is provided, wherein the signal distribution unit adds the signal to the signal cache in response to the unavailability of resources required by the task corresponding to the signal.
[0037] According to the task management unit of any one of the first to third aspects of the second aspect of the present application, there is provided a fourth task management unit of the second aspect of the present application, wherein the signal distribution unit adds the signal to one of the signal buffers according to the signal type; the signal type corresponds to the signal buffer in a one-to-one manner;
[0038] According to the fourth task management unit of the second aspect of the present application, a fifth task management unit of the second aspect of the present application is provided, wherein the signal distribution unit adds the signal to a signal cache corresponding to the same signal type according to the signal type.
[0039] According to the fifth task management unit of the second aspect of the present application, a sixth task management unit of the second aspect of the present application is provided, wherein periodically, in response to an interrupt, or in response to the current task being processed to completion, the task scheduling unit selects one of the signal caches.
[0040] According to the sixth task management unit of the second aspect of the present application, a seventh task management unit of the second aspect of the present application is provided, wherein the task scheduling unit schedules the task processing unit to process the task indicated by the signal according to the type of the signal.
[0041] According to the task management unit of any one of the first to seventh items of the second aspect of the present application, an eighth task management unit of the second aspect of the present application is provided, wherein the task scheduling unit selects the signal cache in a random, round-robin, or weighted round-robin manner.
[0042] According to the eighth task management unit of the second aspect of the present application, a ninth task management unit of the second aspect of the present application is provided, wherein the priority of the signal cache is set.
[0043] According to the task management unit of any one of the first to ninth items of the second aspect of the present application, a tenth task management unit of the second aspect of the present application is provided, wherein the signal distribution unit receives a signal provided by the task processing unit or hardware, and the signal indicates the task processing unit that processes the task corresponding to the signal.
[0044] According to the task management unit of any one of the first to third items of the second aspect of the present application, an eleventh task management unit of the second aspect of the present application is provided, wherein the signal distribution unit obtains the IO command to which the task corresponding to the signal belongs according to the signal.
[0045] According to the eleventh task management unit of the second aspect of the present application, a twelfth task management unit of the second aspect of the present application is provided, wherein the signal distribution unit adds the acquired signal to a signal cache corresponding to the IO command corresponding to the signal, and the signal cache corresponds one-to-one to the IO command being processed.
[0046] According to the eleventh or twelfth task management unit of the second aspect of the present application, a thirteenth task management unit of the second aspect of the present application is provided, wherein the signal distribution unit schedules the task processing unit that processes the task corresponding to the signal in response to the availability of resources required for the task corresponding to the signal.
[0047] According to the task management unit of any one of items 11 to 13 of the second aspect of the present application, a fourteenth task management unit of the second aspect of the present application is provided, wherein the signal distribution unit directly schedules the task processing unit to process the task indicated by the signal in response to the fact that the IO command corresponding to the signal has started to be processed or the time when the IO command corresponding to the signal has started to be processed is long enough or long enough relative to other IO commands, without adding the signal to the signal cache.
[0048] According to the task management unit of any one of items 11 to 14 of the second aspect of the present application, a fifteenth task management unit of the second aspect of the present application is provided, wherein the task scheduling unit sets the priority of each signal cache according to the time when the IO command corresponding to the signal cache is started to be processed.
[0049] According to the task management unit of any one of items 11 to 15 of the second aspect of the present application, a sixteenth task management unit of the second aspect of the present application is provided, wherein the task scheduling unit sets the priority of the signal cache according to the order in which the IO commands are started to be processed.
[0050] According to the task management unit of any one of items 11 to 16 of the second aspect of the present application, a seventeenth task management unit of the second aspect of the present application is provided, wherein, in response to starting to process a new IO command, the signal distribution unit allocates a new signal cache for the new IO command to accommodate the signal corresponding to the IO command.
[0051] According to the seventeenth task management unit of the second aspect of the present application, an eighteenth task management unit of the second aspect of the present application is provided, wherein the sequence number of the currently recorded IO command is incremented, and the signal distribution unit uses the incremented sequence number to set the priority of the newly allocated signal cache.
[0052] According to the task management unit of any one of items 11 to 18 of the second aspect of the present application, a nineteenth task management unit of the second aspect of the present application is provided, wherein, in response to the IO command being processed, the signal cache accommodating its corresponding signal is recycled or allocated to a new IO command.
[0053] According to the task management unit of any one of items 11 to 19 of the second aspect of the present application, a twentieth task management unit of the second aspect of the present application is provided, wherein the task processing unit runs on multiple CPU cores or supports multi-threading and manages the CPU core or thread in which it is located.
[0054] According to the twentieth task management unit of the second aspect of the present application, a twenty-first task management unit of the second aspect of the present application is provided, wherein, in response to an acquisition signal, the signal distribution unit identifies on which CPU the task processing unit corresponding to the signal is running.
[0055] According to the twenty-first task management unit of the second aspect of the present application, a twenty-second task management unit of the second aspect of the present application is provided, wherein the signal distribution unit adds the signal to a signal cache that does not belong to the same CPU as the signal, and the task scheduling unit schedules the task processing unit of the same CPU as the task scheduling unit.
[0056] According to the task management unit of any one of items 20 to 22 of the second aspect of the present application, a twenty-third task management unit of the second aspect of the present application is provided, wherein one or more task processing units scheduled by the task scheduling unit in CPU 0 run on CPU 0, and one or more task processing units scheduled by the task scheduling unit in CPU 1 run on CPU 1. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0058] Figure 1A is a schematic diagram of task scheduling provided according to an embodiment of the present application;
[0059] Figure 1B is a block diagram of a task processing system provided according to an embodiment of the present application;
[0060] Figure 2 is a schematic diagram of a task management unit provided according to an embodiment of the present application;
[0061] Figure 3 is a schematic diagram of a task management unit provided according to another embodiment of the present application;
[0062] Figure 4A is a schematic diagram of a task management unit provided according to yet another embodiment of the present application;
[0063] Figure 4Bis a flow chart of a signal distribution unit distributing a signal according to an embodiment of the present application;
[0064] Figure 4C is a flow chart of a signal distribution unit distributing a signal according to yet another embodiment of the present application;
[0065] Figure 5A is a schematic diagram of a task provided according to another embodiment of the present application;
[0066] Figure 5B is a schematic diagram of a task management unit provided according to another embodiment of the present application. DETAILED DESCRIPTION
[0067] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0068] Figure 1A It is a schematic diagram of task scheduling according to an embodiment of the present application.
[0069] Figure 1A , the direction from left to right is the direction of time passage. A plurality of tasks (1-1, 2-1, 3-1, 1-2, 2-2 and 3-2) being processed are also shown, wherein in the reference numerals having the structure "ab", the preceding symbol a indicates a task, and the succeeding symbol b indicates a subtask included in the task. Figure 1A It shows that 3 tasks are processed in chronological order, and each task includes 2 subtasks.
[0070] The solid arrows indicate the time sequence of processing multiple tasks, and the dotted arrows indicate the logical sequence of task processing. For example, taking Task 1 as an example, its subtask 1-1 (Task 1-1) should be processed first, and then its subtask 1-2 (Task 1-2) should be processed. Figure 1A After processing task 1-1, task 1-2 cannot be processed immediately (because the required resources are not yet ready), so task 2-1 is scheduled for execution, and task 3-1 is then identified as having the required resources ready, and after processing task 3-1, task 1-2 is scheduled for execution.
[0071] On a processor, tasks are processed by executing code segments. For a single CPU, only one segment of code can be processed at any one time. For example, Figure 1AAs shown, for multiple tasks to be processed, the code segment for processing task 1-1 is executed first, the code segment for processing task 2-1 is executed next, the code segment for processing task 3-1 is executed next, the code segment for processing task 1-2 is executed next, the code segment for processing task 2-2 is executed next, and the code segment for processing task 3-2 is executed next. The logical order of task processing is indicated in the code segment for each processing task. For example, the logical order includes that task 1-2 is to be processed after task 1-1. As another example, in the code segment for processing task 1-1, it is indicated that the code segment whose logical order is to be processed later should be the code segment for processing task 1-2.
[0072] According to an embodiment of the present application, a code segment indicates a code segment to be executed later in the logical sequence by sending a signal. For example, the value of the signal is used as an index of the code segment to be executed.
[0073] Figure 1B It is a block diagram of a task processing system provided according to an embodiment of the present application.
[0074] See also Figure 1B The task processing system consists of two parts: software and hardware. The hardware includes, for example, one or more CPUs that run the software and other hardware resources that process related tasks (e.g., memory, codecs, interfaces, accelerators, interrupt controllers, etc.).
[0075] The code segment of the software running on the CPU is called a task processing unit. The task processing system includes multiple task processing units. Each task processing unit processes the same or different tasks. For example, task processing unit 0 processes the first subtask of the task (such as task 1-1, task 2-1 and task 3-1), while task processing unit 1, task processing unit 2 and task processing unit 3 process the second subtask of the task (such as task 1-2, task 2-2 and task 3-2).
[0076] The software also includes a task management unit for scheduling one of the task processing units to run on the hardware.
[0077] When executed by the CPU, the task management unit provides an API (Application Programming Interface) to the task processing unit. The task processing unit informs the task management unit of other task processing units that should be scheduled later by calling the API. The task management unit checks whether the resources required by the other task processing units are ready, and schedules the other task processing units when the resources are ready.
[0078] The resources required by the task processing unit include, for example, storage space, data to be read, an indication of completion of a data write operation, and the like.
[0079] By using the task management unit and the API provided to the task processing unit, the task processing unit only needs to specify its successor task processing unit according to the logical order of the task, and the task management unit efficiently schedules the task processing unit while meeting the requirements of the logical order.
[0080] In the embodiment according to the present application, the task processing unit does not need to check resource availability and does not need to maintain the order between multiple task processing units, which improves CPU utilization and reduces the complexity of the task processing unit.
[0081] Figure 2 It is a schematic diagram of a task management unit provided according to an embodiment of the present application.
[0082] The task management unit includes a signal distribution unit 210 , one or more signal buffers ( 220 , 222 . . . 22 n ) and a task scheduling unit 240 .
[0083] The task scheduling unit 240 schedules one or more task processing units (260, 262, ... 26n) to process the tasks indicated by the signals. As an example, the signals correspond one to one with the task processing units.
[0084] The signal distribution unit 210 receives a signal provided by a task processing unit or hardware, and the signal indicates a task processing unit that needs to be scheduled to process the task indicated by the signal. For example, the task processing unit provides a signal to the signal distribution unit 210 by calling an API; or the hardware provides a signal to the signal distribution unit 210 through an interrupt.
[0085] There are many types of signals. For example, the type of signal is identified according to the value of the signal. Each signal has a corresponding task processing unit. The task management unit provides a signal cache for each signal. For example, signal cache 220 is used to carry signal 0, signal cache 222 is used to carry signal 2, and signal cache 22n is used to carry signal n. The signal cache includes multiple entries, each entry is used to accommodate an instance of a signal. The signal instances in the cache are sorted in the order in which they are added to the cache. Signals are added to the cache from the end of the queue, and signals are taken from the head of the queue.
[0086] In response to receiving the signal, the signal distribution unit 210 adds the signal to the signal buffer corresponding to the type of the signal according to the type of the received signal. And optionally, the API for providing the signal returns without blocking the caller of the API.
[0087] Periodically, in response to an interrupt, in response to the current task being processed, or for other reasons, the task scheduling unit 240 has the opportunity to schedule a task processing unit based on a signal in a signal buffer. The task scheduling unit 240 takes a signal from one of the signal buffers and schedules one of the task processing units to process the signal. In one example, the task scheduling unit 240 calls a task processing unit corresponding to the type of signal based on the type of the signal taken out. As another example, the task scheduling unit 240 uses the taken out signal as an index to obtain the scheduled task processing unit.
[0088] Optionally, the task scheduling unit 240 selects the signal buffer in a random, round-robin, weighted round-robin, etc. Priority can be set for each signal buffer. Priority of each signal buffer can be adjusted.
[0089] Figure 3 is a schematic diagram of a task management unit provided according to another embodiment of the present application.
[0090] Some processors include multiple CPU cores or support multithreading. According to an embodiment of the present application, a task management unit is set for each CPU core or each thread. The task processing unit manages the task processing unit belonging to the CPU core or thread in which it is located. For the purpose of simplicity, the following description is taken as an example of a processor including multiple CPU cores. Those skilled in the art will appreciate that the task management unit applied to a processor including multiple CPU cores is also applicable to a multithreaded system because the thread provides a virtual CPU core for the program it runs.
[0091] See also Figure 3 , the processor includes CPU 0 and CPU 1. CPU 0 and CPU 1 each include a task management unit. The task management unit of CPU 0 includes a signal distribution unit 310, one or more signal buffers and a task scheduling unit 340; the task management unit of CPU 1 includes a signal distribution unit 312, one or more signal buffers and a task scheduling unit 342. One or more task processing units (360, 362...36n) scheduled by the task scheduling unit 340 run on CPU 0, and one or more task processing units (370, 372...37n) scheduled by the task scheduling unit 342 run on CPU 1.
[0092] The task processing unit (360, 362 ... 36n) running on CPU 0 can send signals to the task processing units (360, 362 ... 36n) belonging to CPU 0 by calling the API provided by the task management unit also running on CPU 0, and can also send signals to the task processing units (370, 372 ... 37n) belonging to CPU 1. Conversely, the task processing unit (370, 372 ... 37n) running on CPU 1 can send signals to the task processing units (370, 372 ... 37n) belonging to CPU 1 by calling the API provided by the task management unit also running on CPU 1, and can also send signals to the task processing units (360, 362 ... 36n) belonging to CPU 0.
[0093] In response to receiving the signal, the signal distribution unit (310, 312) identifies which CPU is running the task processing unit indicated by the signal. Taking the signal distribution unit 310 as an example, if the identification signal is to be sent to the task processing unit (360, 362...36n) running on CPU 0, the signal is added to the corresponding signal cache (320, 322...32n); if the identification signal is to be sent to the task processing unit (370, 372...37n) running on CPU 1, the signal is added to the corresponding signal cache (330, 332...33n). For the signal distribution unit 312, if the identification signal is to be sent to the task processing unit (360, 362...36n) running on CPU 0, the signal is added to the corresponding signal cache (320, 322...32n); if the identification signal is to be sent to the task processing unit (370, 372...37n) running on CPU 1, the signal is added to the corresponding signal cache (330, 332...33n).
[0094] according to Figure 3 In the embodiment, the signal distribution unit (310, 312) can add the signal to the signal cache of the CPU that does not belong to the same CPU as the signal distribution unit. However, the task scheduling unit (340, 342) can only schedule the task processing unit that belongs to the same CPU as the task processing unit.
[0095] Figure 4A is a schematic diagram of a task management unit provided according to yet another embodiment of the present application.
[0096] The task management unit includes a signal distribution unit 410 , one or more signal buffers ( 420 , 422 . . . 22 n ) and a task scheduling unit 450 .
[0097] In response to receiving the signal, the signal distribution unit 410 identifies whether the task processing unit (452, 452...45n) corresponding to the signal has sufficient resources to process the task. For example, whether there is sufficient storage space, whether the hardware resources required for processing the task are idle, whether the data required for the task is ready, etc. If the task processing unit has sufficient resources to process the task, the signal distribution unit 410 calls the task processing unit corresponding to the signal to process the task indicated by the signal without adding the signal to the signal cache. If the task processing unit corresponding to the signal does not have sufficient resources to process the task, the signal distribution unit 410 adds the signal to the corresponding signal cache.
[0098] In this way, tasks indicated by some signals can be processed earlier without going through the process of being added to and taken out of the signal buffer, thereby shortening the time for processing the tasks indicated by the signals.
[0099] Figure 4B It is a flow chart of signal distribution by a signal distribution unit provided in an embodiment of the present application.
[0100] Signal distribution unit (410) (see also Figure 4A ) In response to obtaining the signal to be distributed (460), it is identified whether the resources of the task corresponding to the processing signal are all ready (462). In the case that the resources required for the task corresponding to the processing signal are all ready, the task processing unit of the task corresponding to the processing signal is called (464). If in step 462, it is identified that the resources required for the task corresponding to the processing signal are not all ready, the signal is added to the corresponding signal buffer (468).
[0101] Figure 4C This is a flowchart of a signal distribution unit distributing a signal according to another embodiment of the present application.
[0102] Some tasks processed by electronic devices include multiple stages. For tasks that have been started, it is hoped that they will be completed as soon as possible to shorten the time that the resources for processing the tasks are occupied by the tasks. Taking a storage device that processes IO commands as an example, processing IO commands includes two stages, such as operating the storage medium (denoted as S1) and providing the processing results to the host (denoted as S2). Each stage is composed of a task processing unit (420, 422, ... 42n) (see also Figure 4A After the task processing unit completes the S1 stage, it sends a signal to indicate that the S2 stage will be processed next.
[0103] See also Figure 4C , signal distribution unit (410) (see also Figure 4A) In response to obtaining the signal to be distributed (480), it is identified whether the resources of the task corresponding to the processing signal are all ready (482). In the case that the resources required for the task corresponding to the processing signal are all ready, it is further identified whether the processing of the IO command indicated by the signal to be distributed has been started (484). For example, if the signal to be distributed indicates that the processing is the S1 stage of the IO command, it means that the processing of the IO command has not been started; if the signal to be distributed indicates that the processing is the S2 stage of the IO command, it means that the processing of the IO command has been started.
[0104] In response to identifying that the processing of the IO command indicated by the signal to be distributed has been started, the task processing unit of the task S2 stage corresponding to the processing signal is called (486). If in step 484, in response to identifying that the processing of the IO command indicated by the signal to be distributed has not been started, the signal is added to the corresponding signal cache (488). Optionally, in step 484, it is determined whether to prioritize the scheduling of the task processing unit corresponding to the signal based on some other conditions. For example, the signal is set with a specified high priority. As another example, the signal has a quota, and the quota of the signal has not been exhausted; and in response to the quota, in step 484, the task processing unit corresponding to the processing signal is called to reduce the quota by a specified amount. By setting a quota, some signals can be processed preferentially under a specified load, but if such signals appear frequently and the quota is exhausted, the signal is added to the signal cache for unified scheduling.
[0105] If, at step 482, it is identified that the resources required for processing the task corresponding to the signal are not all ready, the signal is also added to the corresponding signal buffer (488).
[0106] Figure 5A It is a schematic diagram of a task provided according to another embodiment of the present application.
[0107] Take IO commands as an example of a task. Storage devices usually process multiple IO commands at the same time. Figure 5A In the example, the IO command (500, 502, 504) includes multiple stages (S1, S2 and S3). The three stages belonging to the same IO command need to be processed in the order of S1, S2 and S3. Between stages S1, S2 and S3, it may be necessary to wait for some time to wait for the resources required to process the IO command to be ready. Multiple IO commands can be processed in parallel. After the task processing unit processes stage S1 of the IO command 500, it sends a signal to indicate that stage S2 should be processed next, and also indicates through a signal that stage S2 is stage S2 of the IO command 500.
[0108] According to the embodiments of the present application, it is hoped that more IO commands can be processed simultaneously with limited resources, and it is also hoped that the processing time of each IO command can be as short as possible, so as to avoid the signal indicating the subsequent stage (S2 or S3) of the IO command that has been started to be waited for too long and cannot be scheduled, and it is hoped that the signal indicating the subsequent stage (S2 or S3) of the IO command that has been started can be processed as early as possible.
[0109] The above purpose is achieved through various means. For example, a higher priority is set for a signal indicating a subsequent stage (S2 or S3) of an IO command that has been started for processing, a higher priority is set for a signal indicating an IO command that has been started for processing, and priorities are set for signals corresponding to the same IO command according to the order in which multiple IO commands are started for processing so that the signal corresponding to the IO command that is started for processing earlier has a higher priority.
[0110] Figure 5B is a schematic diagram of a task management unit provided according to another embodiment of the present application.
[0111] The task management unit includes a signal distribution unit 510 , one or more signal buffers ( 520 , 522 . . . 52 n ) and a task scheduling unit 540 .
[0112] As an example, the signals correspond one-to-one to the task processing units.
[0113] The signal buffers (520, 522, ... 52n) correspond one to one with the IO commands being processed. For example, signal buffer 520 is dedicated to accommodating signals indicating the processing of IO command 500 (or its various stages); signal buffer 522 is dedicated to accommodating signals indicating the processing of IO command 502 (or its various stages); signal buffer 52n is dedicated to accommodating signals indicating the processing of IO command 50n (or its various stages). The number of signal buffers is independent of the type of signal.
[0114] according to Figure 5B The task management unit of the embodiment schedules multiple task processing units (550, 552, ..., 55m). The number of task processing units does not have to be the same as the number of signal buffers. Optionally, the number of task processing units depends on the type of signal, and at least a corresponding task processing unit is provided for each signal. Still optionally, multiple task processing units are provided for each signal.
[0115] The signal distribution unit 510 receives a signal provided by a task processing unit or hardware, and the signal indicates a task processing unit that needs to be scheduled to process the task indicated by the signal. The IO command to which the task indicated by the signal belongs can also be obtained according to the signal. The signal distribution unit 510 adds the obtained signal to the signal cache corresponding to the IO command corresponding to the signal.
[0116] Optionally, the signal distribution unit 510 further identifies whether the resources of the task corresponding to the processing signal are ready. If the resources required by the task corresponding to the processing signal are ready, the task processing unit (550, 552, ..., 55m) of the task corresponding to the processing signal is called.
[0117] Still optionally, when the resources required for processing the task corresponding to the signal are ready, the signal distribution unit further determines whether to directly schedule the task processing unit (550, 552 ... 55m) for processing the task corresponding to the signal according to other conditions, instead of adding the signal to the signal cache. For example, if the IO command corresponding to the signal has been started to be processed (the IO command stage corresponding to the signal is not stage S1, but stage S2 or S3), or the time for the IO command corresponding to the signal to be started to be processed is long enough or long enough relative to other IO commands, the task processing unit (550, 552 ... 55m) for processing the task corresponding to the signal is directly scheduled.
[0118] The task scheduling unit 540 obtains the signal from the signal buffer and schedules the task processing unit according to the signal.
[0119] Optionally, the task scheduling unit 540 selects the signal cache in a random, round-robin, weighted round-robin, etc. manner. Optionally, the priority of each signal cache is set according to the time when the IO command corresponding to the signal cache is started to be processed. The signal cache corresponding to the IO command that is started to be processed earlier is set with a higher priority, so that when the task scheduling unit 540 selects the signal cache according to the priority, it will give priority to the IO command that is started to be processed earlier.
[0120] Optionally, the priority of the signal buffer is set according to the order in which the IO commands are started to be processed. In response to starting to process a new IO command, a new signal buffer is allocated to the new IO command to accommodate the signal corresponding to the IO command. And the sequence number of the current record is incremented, and the priority of the newly allocated signal buffer is set with the incremented sequence number. And in response to the IO command being processed, the signal buffer accommodating its corresponding signal is recycled or allocated to a new IO command.
[0121] In addition to being applied to storage devices, the embodiments of the present application are also applicable to task scheduling in other electronic devices such as computers, servers, and network devices.
[0122] An embodiment of the present application also provides a program including program code. When the program is loaded into an electronic device and executed on the electronic device, the program code enables the electronic device to execute the method described above.
[0123] It should be understood that each block of the block diagram and the flow chart and the combination of blocks of the block diagram and the flow chart can be implemented by various devices including program instructions, respectively. These program instructions can be loaded onto a general-purpose computer, a special-purpose computer or other programmable data control device to produce a machine, so that the instructions executed on the computer or other programmable data control device create a device for implementing the functions specified in one or more flow chart blocks.
[0124] Thus, the blocks of the block diagrams and flow charts support a combination of means for performing a specified function, a combination of operations for performing a specified function, and a combination of program instruction means for performing a specified function. It should also be understood that each block of the block diagrams and flow charts and the combination of blocks of the block diagrams and flow charts can be implemented by a hardware-based special-purpose computer system that performs the specified function or operation, or by a combination of special-purpose hardware and computer instructions.
[0125] At least a portion of the different blocks, operations, and techniques described above may be performed using hardware, a control device executing firmware instructions, a control device executing software instructions, or any combination thereof. When performed using a control device that executes firmware and software instructions, the software or firmware instructions may be stored in any computer-readable storage medium, such as a disk, an optical disk, or other storage medium, in RAM or ROM or flash memory, a control device, a hard disk, an optical disk, a disk, or the like. Similarly, the software and firmware instructions may be transmitted to a user or system by any known or desired transmission method. The software or firmware instructions may include machine-readable instructions that, when executed by a control device, cause the control device to perform different actions.
[0126] When implemented in hardware, the hardware may include one or more discrete components, an integrated circuit, an application specific integrated circuit (ASIC), and the like.
[0127] It should be understood that the present application can be implemented in pure software, pure hardware, firmware, and various combinations thereof. The hardware may be, for example, a control device, a dedicated integrated circuit, a large-scale integrated circuit, and the like.
[0128] Although the present application is described with reference to examples, this is for illustrative purposes only and is not intended to limit the present application, and changes, additions and / or deletions to the embodiments may be made without departing from the scope of the present application.
[0129] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A task scheduling method, characterized in that: Including the following steps: Get the signal; In response to the availability of resources required for the task corresponding to the processing of the signal, scheduling the task for processing the signal; The signal has a quota. If the quota of the signal is greater than a threshold, the task of processing the acquired signal is scheduled. By setting the quota, the signal can be processed preferentially under a specified load. If the quota of the signal is not greater than the threshold, the signal is added to the signal cache for unified scheduling; if the resource for processing the task corresponding to the signal is unavailable, the signal is added to the signal cache; The signal is used to process IO commands, and the signal buffer corresponds to the IO command one by one; In response to the fact that resources required for processing the task corresponding to the signal are available, identifying whether processing of the IO command indicated by the signal has started; If it is identified that the IO command indicated by the signal has not started, then adding the signal to the signal buffer corresponding to the IO command indicated by the signal; If it is recognized that the IO command indicated by the signal has started, a task for processing the acquisition signal is scheduled.
2. The task scheduling method according to claim 1, characterized in that: in, The type of the signal is identified according to the value of the signal, and each type of the signal has a corresponding task for processing the signal.
3. The task scheduling method according to claim 1, characterized in that: in, According to the type of signal, the signal is added to the signal buffer corresponding to the same signal type.
4. The task scheduling method according to claim 3, characterized in that: in, Get the signal from the signal buffer and call the task corresponding to the signal type according to the signal type.
5. The task scheduling method according to claim 3, characterized in that: in, Use the obtained signal as the index to get the scheduled task.
6. The task scheduling method according to claim 1, characterized in that: in, The signal buffer is selected in a random, round-robin or weighted round-robin manner.
7. The task scheduling method according to claim 6, characterized in that: in, Set the priority of the signal buffer.
8. The task scheduling method according to claim 1, characterized in that: in, The types of signals correspond to the signal buffers one by one.
9. The task scheduling method according to claim 1, characterized in that: in, If the resource for processing the task corresponding to the signal is unavailable, according to the IO command corresponding to the signal, the signal is added to a signal cache corresponding to the IO command.
10. The task scheduling method according to claim 9, characterized in that: In response to starting to process a new IO command, a new signal buffer is allocated for the new IO command.
11. The task scheduling method according to claim 1, characterized in that: in, Gets a signal from the signal buffer and calls the task that handles the obtained signal.
12. The task scheduling method according to claim 11, characterized in that: in, A signal buffer is selected based on its priority.
13. The task scheduling method according to claim 12, characterized in that: in, The priority of each signal buffer is set according to the time when the IO command corresponding to the signal buffer starts to be processed.
14. The task scheduling method according to claim 12, characterized in that: in, Set the priority of the signal buffer according to the order in which IO commands are started to be processed.
15. The task scheduling method according to claim 12, characterized in that: in, The sequence number of the recorded IO command processing is incremented, and the priority of the signal cache is set with the incremented sequence number.
16. The task scheduling method according to claim 8, characterized in that: in, In response to the IO command being processed, the signal buffer accommodating the corresponding signal is recycled or allocated to a new IO command.
17. The task scheduling method according to claim 8, characterized in that: The IO command includes multiple stages, the signal indicates one of the stages of the IO command, and the signals corresponding to the multiple stages of the same IO command are processed according to the order of the multiple stages in the IO command.
18. The task scheduling method according to claim 17, characterized in that: in, Processing the IO command includes sequential S1 and S2 stages; wherein the S1 stage is to operate the storage medium; and the S2 stage is to provide the processing result to the host.
19. The task scheduling method according to claim 17, characterized in that: in, If the signal indicates the S1 stage of the IO command, the processing of the IO command has not yet started; if the signal indicates that the processing is the S2 stage of the IO command, the processing of the IO command has already started.
20. The task scheduling method according to claim 1, characterized in that: in, Calls the task that handles the acquired signal, decrementing the quota by the specified amount.
21. The task scheduling method according to claim 1, characterized in that: In response to acquiring the signal, a CPU or a thread executing a task corresponding to the signal is identified, and the signal is added to a signal cache belonging to the CPU or the thread executing the task corresponding to the signal.
22. A task management system, characterized in that: It includes a signal distribution unit, one or more signal buffers and a task scheduling unit; The signal distribution unit, in response to the availability of resources required by the task corresponding to the signal, schedules the task processing unit to process the task indicated by the signal without adding the signal to the signal cache; in response to the unavailability of resources required by the task corresponding to the signal, adds the signal to the signal cache; The task scheduling unit selects one of the signal buffers, takes out a signal from the selected signal buffer, and schedules one or more task processing units to process the task indicated by the signal; The signal has a quota. If the quota of the signal is greater than a threshold, the task of processing the acquired signal is scheduled. By setting the quota, the signal can be processed preferentially under a specified load. If the quota of the signal is not greater than the threshold, the signal is added to the signal cache for unified scheduling; The signal is used to process IO commands, and the signal buffer corresponds to the IO command one by one; In response to the fact that resources required by the task corresponding to the signal are available, identifying whether processing of the IO command indicated by the signal has started; If it is identified that the IO command indicated by the signal has not started, then adding the signal to the signal buffer corresponding to the IO command indicated by the signal; If it is recognized that the IO command indicated by the signal has started, a task for processing the acquisition signal is scheduled.
23. The task management system according to claim 22, characterized in that: in, The signal distribution unit adds the signal to one of the signal buffers according to the signal type; the signal type corresponds to the signal buffer in a one-to-one manner.
24. The task management system according to claim 23, characterized in that: in, The signal distribution unit adds the signal to a signal buffer corresponding to the signal type according to the signal type.
25. The task management system according to claim 24, characterized in that: in, Periodically, in response to an interrupt, or in response to the current task being processed to completion, the task scheduling unit selects one of the signal buffers.
26. The task management system according to claim 25, characterized in that: in, The task scheduling unit schedules the task processing unit to process the task indicated by the signal according to the type of the signal.
27. The task management system according to claim 22, characterized in that: in, The task scheduling unit selects the signal buffer in a random, round-robin or weighted round-robin manner.
28. The task management system according to claim 27, characterized in that: in, Set the priority of the signal buffer.
29. The task management system according to claim 22, characterized in that: in, The signal distribution unit receives a signal provided by a task processing unit or hardware, and the signal indicates a task processing unit that processes a task corresponding to the signal.
30. The task management system according to claim 22, characterized in that: Among them, the signal distribution unit obtains the IO command to which the task corresponding to the signal belongs according to the signal.
31. The task management system according to claim 30, characterized in that: in, The signal distribution unit adds the acquired signal to the signal buffer corresponding to the IO command corresponding to the signal, and the signal buffer corresponds to the IO command being processed one by one.
32. The task management system according to claim 30, characterized in that: in, In response to the availability of resources required by the task corresponding to the signal, the signal distribution unit schedules a task processing unit to process the task corresponding to the signal.
33. The task management system according to claim 30, characterized in that: in, In response to the fact that the IO command corresponding to the signal has started to be processed or the time when the IO command corresponding to the signal has started to be processed is long enough or long enough relative to other IO commands, the signal distribution unit directly schedules the task processing unit to process the task indicated by the signal without adding the signal to the signal cache.
34. The task management system according to claim 30, characterized in that: in, The task scheduling unit sets the priority of each signal buffer according to the time when the IO command corresponding to the signal buffer starts to be processed.
35. The task management system according to claim 30, characterized in that: in, The task scheduling unit sets the priority of the signal buffer according to the order in which the IO commands are started to be processed.
36. The task management system according to claim 30, characterized in that: in, In response to starting to process a new IO command, the signal distribution unit allocates a new signal buffer for the new IO command to accommodate a signal corresponding to the IO command.
37. The task management system according to claim 36, characterized in that: in, The sequence number of the currently recorded IO command is incremented, and the signal distribution unit sets the priority of the newly allocated signal buffer with the incremented sequence number.
38. The task management system according to claim 30, characterized in that: in, In response to the IO command being processed, the signal buffer accommodating the corresponding signal is recycled or allocated to a new IO command.
39. The task management system according to claim 30, characterized in that: in, A task processing unit that runs on multiple CPU cores or supports multi-threading and manages the CPU core or thread in which it is located.
40. The task management system according to claim 39, characterized in that: in, In response to acquiring the signal, the signal distribution unit identifies on which CPU the task processing unit corresponding to the signal is running.
41. The task management system according to claim 39, characterized in that: in, The signal distribution unit adds the signal to a signal cache that does not belong to the same CPU as the signal distribution unit, and the task scheduling unit schedules the task processing unit that belongs to the same CPU as the task scheduling unit.
42. The task management system according to claim 39, characterized in that: in, One or more task processing units scheduled by the task scheduling unit in CPU 0 run on CPU 0 , and one or more task processing units scheduled by the task scheduling unit in CPU 1 run on CPU 1 .
Citation Information
Patent Citations
Use of a data engine within a data processing apparatus
US20060271712A1