Scheduling method and device for large-scale constrained concurrent tasks based on signals and slots
By adopting a signal-slot-based task scheduling method in embedded CPUs, the problem of excessive delay when handling large-scale concurrent IO commands is solved, and more efficient task scheduling and processing efficiency is achieved.
Patent Information
- Application Number
- CN201811160925.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-09-30
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2038-09-30
AI Technical Summary
In embedded CPUs, when processing large-scale concurrent IO commands, it is difficult for the prior art to effectively schedule various IO commands and tasks in their processing stages, resulting in too long processing delays.
The signal-slot-based task scheduling method is adopted to realize effective scheduling of IO commands and their processing stage tasks through steps such as obtaining signals, responding to resource availability, adding signals to cache, and obtaining signals from cache.
This method can effectively shorten the processing delay of IO commands, improve processing efficiency, and avoid the processing delay of individual IO commands being too long.
Smart Images

Figure CN110968418B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to task scheduling, and in particular, to scheduling of large-scale constrained concurrent tasks based on signals and slots. Background Art
[0002] In some applications, 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 run, 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 of the prior art is difficult to apply to this scenario. Summary of the invention
[0004] Taking a storage device that processes IO commands as an example, the storage device processes a large number of concurrent IO commands at the same time. For example, at the same time, there are hundreds, thousands or more IO commands to be processed or being processed. The processing of each IO command includes multiple stages, and each stage may not be processed consecutively in time due to waiting for software and / or hardware resources.
[0005] 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 delay of individual IO commands. Therefore, it is necessary to effectively schedule the processing tasks of each IO command and each stage of the IO command.
[0006] 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.
[0007] 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.
[0008] 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.
[0009] 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.
[0010] 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.
[0011] 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.
[0012] 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.
[0013] 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.
[0014] 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.
[0015] 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.
[0016] 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.
[0017] 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.
[0018] 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.
[0019] 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.
[0020] 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.
[0021] 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.
[0022] 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.
[0023] 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.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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.
[0028] 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.
[0029] 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.
[0030] 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.
[0031] 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.
[0032] 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.
[0033] 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.
[0034] 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.
[0035] 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.
[0036] 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.
[0037] 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.
[0038] 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;
[0039] 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.
[0040] 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.
[0041] 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.
[0042] 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.
[0043] 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.
[0044] 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.
[0045] 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.
[0046] 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.
[0047] 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.
[0048] 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 been started to be processed or the time when the IO command corresponding to the signal has been started to be processed is long enough or long enough relative to other IO commands, without adding the signal to the signal cache.
[0049] 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 starts to be processed.
[0050] 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.
[0051] 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.
[0052] 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.
[0053] 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.
[0054] 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.
[0055] 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.
[0056] 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.
[0057] 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.
[0058] According to a third aspect of the present application, a first task scheduling method according to the third aspect of the present application is provided, comprising: acquiring a signal; in response to the signal being in a "ready" state, scheduling a task for processing the signal.
[0059] According to the first task scheduling method of the third aspect of the present application, a second task scheduling method according to the third aspect of the present application is provided, further comprising: if the processing of the signal is in a "waiting" state, recording the signal in a signal cache.
[0060] According to the first or second task scheduling method of the third aspect of the present application, a third task scheduling method according to the third aspect of the present application is provided, which also includes: obtaining a signal in a "ready" state from a signal cache, and calling a task to process the obtained signal.
[0061] According to one of the first to third task scheduling methods of the third aspect of the present application, a fourth task scheduling method according to the third aspect of the present application is provided, wherein the types of signals correspond one-to-one to the signal caches.
[0062] According to one of the second to fourth task scheduling methods of the third aspect of the present application, a fifth task scheduling method according to the third aspect of the present application is provided, wherein, according to the type of the signal, the signal is recorded in a signal cache corresponding to the same signal type.
[0063] According to the third or fourth task scheduling method of the third aspect of the present application, a sixth task scheduling method according to the third aspect of the present application is provided, wherein a signal is obtained from a signal cache, and tasks corresponding to the signal type are scheduled according to the type of the signal.
[0064] According to one of the first to sixth task scheduling methods of the third aspect of the present application, a seventh task scheduling method according to the third aspect of the present application is provided, wherein the signal cache is selected in a random, round-robin or weighted round-robin manner.
[0065] According to one of the first to seventh task scheduling methods according to the third aspect of the present application, an eighth task scheduling method according to the third aspect of the present application is provided, wherein the signal cache has a priority.
[0066] According to the first task scheduling method of the third aspect of the present application, a ninth task scheduling method according to the third aspect of the present application is provided, wherein the signal is used to process IO commands, and the signal cache corresponds one-to-one with the IO commands.
[0067] According to the ninth task scheduling method of the third aspect of the present application, a tenth task scheduling method according to the third aspect of the present application is provided, wherein, if the signal is in a "ready" state and if the IO command indicated by the signal has not yet begun to be processed, the signal is added to a signal cache corresponding to the IO command indicated by the signal.
[0068] According to the ninth task scheduling method of the third aspect of the present application, an eleventh task scheduling method according to the third aspect of the present application is provided, wherein, if the IO command indicated by the signal has begun to be processed, a task for processing the acquisition signal is scheduled.
[0069] According to one of the ninth to eleventh task scheduling methods of the third aspect of the present application, a twelfth task scheduling method according to the third aspect of the present application is provided, wherein if the signal is processed in a "waiting" state, the signal is added to a signal cache corresponding to the IO command.
[0070] According to the twelfth task scheduling method of the third aspect of the present application, a thirteenth task scheduling method according to the third 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.
[0071] According to one of the ninth to thirteenth task scheduling methods according to the third aspect of the present application, a fourteenth task scheduling method according to the third aspect of the present application is provided, wherein the signal cache is selected according to the priority of the signal cache.
[0072] According to the fourteenth task scheduling method of the third aspect of the present application, a fifth task scheduling method according to the third 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 is started to be processed.
[0073] According to the fourteenth task scheduling method of the third aspect of the present application, a sixteenth task scheduling method according to the third 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.
[0074] According to one of the ninth to sixteenth task scheduling methods of the third aspect of the present application, a seventeenth task scheduling method according to the third aspect of the present application is provided, wherein the IO command includes multiple stages, a 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.
[0075] According to one of the first to seventeenth task scheduling methods of the third aspect of the present application, an eighteenth task scheduling method according to the third aspect of the present application is provided, which also includes: in response to acquiring a signal, identifying the process of the task corresponding to the running signal, and adding the signal to the signal cache of the process belonging to the task corresponding to the running signal.
[0076] According to the eighteenth task scheduling method of the third aspect of the present application, a nineteenth task scheduling method according to the third aspect of the present application is provided, which also includes: identifying the execution status of the process of the task corresponding to the running signal, and if the process is in a dormant state, waking up the process.
[0077] According to the nineteenth task scheduling method of the third aspect of the present application, a twentieth task scheduling method according to the third aspect of the present application is provided, wherein if the process is in a running state, there is no need to wake up the process again.
[0078] According to the nineteenth or twentieth task scheduling method of the third aspect of the present application, a twenty-first task scheduling method according to the third aspect of the present application is provided, wherein the first processor where the process of the task corresponding to the running signal is located is identified, and if the first processor is a remote processor relative to the current processor and the process is in a sleep state, an interrupt is sent to the first processor.
[0079] According to the twenty-first task scheduling method of the third aspect of the present application, a twenty-second task scheduling method according to the third aspect of the present application is provided, which also includes: the interrupt processing unit of the first processor obtains the first process and / or the second process with signals to be processed in response to receiving an interrupt, and wakes up the first process and / or the second process.
[0080] According to one of the eighteenth to twenty-second task scheduling methods of the third aspect of the present application, a twenty-third task scheduling method according to the third aspect of the present application is provided, which also includes: in response to acquiring a signal, identifying the process of the task corresponding to the running signal, and setting the process as having a signal to be processed in the process status table.
[0081] According to the twenty-third task scheduling method of the third aspect of the present application, a twenty-fourth task scheduling method according to the third aspect of the present application is provided, wherein the interrupt handler of the first processor obtains the first process and / or the second process with signals to be processed through the process status table.
[0082] According to one of the first to twenty-fourth task scheduling methods of the third aspect of the present application, a twenty-fifth task scheduling method according to the third aspect of the present application is provided, wherein the signal includes multiple switches, and a signal in which all switches are closed is a signal in a "ready" state; wherein the switches correspond to resources required to process the signal.
[0083] According to the twenty-fifth task scheduling method of the third aspect of the present application, there is provided a twenty-sixth task scheduling method according to the third aspect of the present application, wherein any signal of any switch being disconnected among all switches is a signal in a "waiting" state.
[0084] According to the twenty-fifth or twenty-sixth task scheduling method of the third aspect of the present application, a twenty-seventh task scheduling method according to the third aspect of the present application is provided, further comprising: in response to the first resource required to process the first signal being available, closing the switch corresponding to the first resource of the first signal.
[0085] According to one of the twenty-fifth to twenty-seventh task scheduling methods of the third aspect of the present application, a twenty-eighth task scheduling method according to the third aspect of the present application is provided, further comprising: in response to the first resource required to process the first signal being unavailable, disconnecting the switch corresponding to the first resource of the first signal.
[0086] According to the twenty-eighth task scheduling method of the third aspect of the present application, a twenty-ninth task scheduling method according to the third aspect of the present application is provided, further comprising: in response to the task of processing the first signal or the second signal consuming the first resource, the first resource becomes unavailable.
[0087] According to one of the first to twenty-ninth task scheduling methods according to the third aspect of the present application, a thirtieth task scheduling method according to the third aspect of the present application is provided, further comprising: clearing all signals in the signal cache.
[0088] According to one of the first to thirty-first task scheduling methods of the third aspect of the present application, a thirty-first task scheduling method according to the third aspect of the present application is provided, which also includes: in response to obtaining a signal, determining whether to directly schedule a task for processing the signal or to add the signal to a signal cache based on an API providing the signal or parameters associated with the signal.
[0089] According to the thirty-first task scheduling method of the third aspect of the present application, a thirty-second task scheduling method according to the third aspect of the present application is provided, which also includes: in response to determining to directly schedule a task to process a signal, if the signal is in a "waiting" state, adding the signal to a signal cache.
[0090] According to one of the first to thirty-second task scheduling methods of the third aspect of the present application, a thirty-third task scheduling method according to the third aspect of the present application is provided, which also includes: in response to obtaining a signal, determining the order in which the signal is processed based on the API providing the signal or the parameters associated with the signal.
[0091] According to the thirty-third task scheduling method of the third aspect of the present application, a thirty-fourth task scheduling method according to the third aspect of the present application is provided, which also includes: in response to the signal being processed in sequence, adding the signal to a signal cache in the form of a queue.
[0092] According to the thirty-third task scheduling method of the third aspect of the present application, a thirty-fifth task scheduling method according to the third aspect of the present application is provided, which also includes: in response to the signal being processed in sequence and the task of processing the signal being directly scheduled, in response to the signal being in a "ready" state, scheduling the task of processing the signal.
[0093] According to the thirty-fifth task scheduling method of the third aspect of the present application, a thirty-sixth task scheduling method according to the third aspect of the present application is provided, which also includes: in response to a signal being processed in sequence and a task for directly scheduling processing of the signal, in response to the signal being in a "waiting" state, the signal is added to a signal cache in the form of a queue.
[0094] According to a fourth aspect of the present application, an information processing device according to the fourth aspect of the present application is provided, comprising a control component and a memory, wherein the control component is used to execute one of the task scheduling methods according to the third aspect of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0095] 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.
[0096] Figure 1A is a schematic diagram of task scheduling provided according to an embodiment of the present application;
[0097] Figure 1B is a block diagram of a task processing system provided according to an embodiment of the present application;
[0098] Figure 2 is a schematic diagram of a task management unit provided according to an embodiment of the present application;
[0099] Figure 3 A schematic diagram showing a signal according to an embodiment of the present application;
[0100] Figure 4A is a schematic diagram of a task management unit according to another embodiment of the present application;
[0101] Figure 4B A flow chart of distributing signals according to an embodiment of the present application is shown;
[0102] Figure 5A is a schematic diagram of a task management unit provided according to another embodiment of the present application;
[0103] Figure 5B is a flow chart of a signal distribution unit distributing a signal according to an embodiment of the present application;
[0104] Fig. 6A is a schematic diagram of a task management unit provided according to another embodiment of the present application;
[0105] Figure 6B is a flow chart of a signal distribution unit distributing a signal according to another embodiment of the present application;
[0106] Fig. 7A is a schematic diagram of a task management unit provided according to yet another embodiment of the present application;
[0107] Figure 7B is a flow chart of a signal distribution unit distributing a signal according to an embodiment of the present application;
[0108] Figure 7C is a flow chart of a signal distribution unit distributing a signal according to another embodiment of the present application;
[0109] Fig. 8A is a schematic diagram of a task provided according to another embodiment of the present application; and
[0110] Figure 8B is a schematic diagram of a task management unit provided according to another embodiment of the present application. DETAILED DESCRIPTION
[0111] 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.
[0112] Figure 1A It is a schematic diagram of task scheduling according to an embodiment of the present application.
[0113] 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.
[0114] 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.
[0115] On a processor, tasks are processed by executing code segments. A single CPU (or CPU core) processes only a single task 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.
[0116] According to an embodiment of the present application, a code segment indicates a code segment that should be executed later in a logical sequence by sending a signal.
[0117] For example, the value of a signal is used as an index to the code section to be executed.
[0118] Figure 1B It is a block diagram of a task processing system provided according to an embodiment of the present application.
[0119] 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.).
[0120] 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).
[0121] The software also includes a task management unit for scheduling one of the task processing units to run on the hardware.
[0122] 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.
[0123] 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.
[0124] By using the task management unit, an API is provided to the task processing unit, so that 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.
[0125] In the embodiment of the present application, the task processing unit does not need to poll or wait for 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.
[0126] Figure 2 It is a schematic diagram of a task management unit provided according to an embodiment of the present application.
[0127] 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 .
[0128] 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.
[0129] 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.
[0130] 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.
[0131] 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.
[0132] 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.
[0133] 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.
[0134] Still optionally, the task management unit also clears the signals in the signal buffer. For example, in response to receiving a shutdown or power-off request, the task management unit clears all signals in the signal buffer to terminate the processing of the signals.
[0135] Figure 3 A schematic diagram of signals according to an embodiment of the present application is shown.
[0136] Signal 310 includes, optionally, one or more parameters (320, 322), one or more switches (340, 342, 344, 346), and / or a task slot 350. Still optionally, signal 310 includes a signal identifier (not shown) that uniquely identifies the signal.
[0137] Parameters are used to carry information or data that a signal transmits to a task processing unit. A signal may not include parameters.
[0138] The switches indicate whether a task processing unit should be scheduled to process the signal. Each switch indicates two states, "open" and "closed". The task scheduling unit 240 (see also FIG. 240 ) is scheduled to process the signal only when all switches of the signal are in the "closed" state. Figure 2 ) to schedule the task processing unit to process the signal. A signal whose all switches are in the "closed" state is called a signal in the "ready" state. When any switch of a signal is in the "open" state, it means that the execution condition of the signal has not been met, and such a signal will not be processed at present. A signal whose all switches are not in the "closed" state is called a signal in the "waiting" state.
[0139] As an example, a switch represents whether the resources required to process a signal are available. For example, switch S1 represents whether the decoder resources are available, and switch S2 represents whether the cache resources are available. When the resources become available, the corresponding switches are set to the "closed" state. Thus, when all the resources required to process the signal are available, the task scheduling unit 240 will recognize that the signal is in the "ready" state and schedule the corresponding task processing unit to process the signal. Optionally or further, in response to the task processing unit processing the signal, the resources are used. If the resources are no longer available, the corresponding switches are set to the "off" state, so that the signals to which these switches belong are in the "waiting" state. The task scheduling unit 240 will not schedule the task processing unit to process the signal in the "waiting" state.
[0140] The task slot indicates the task processing unit, and the task scheduling unit 240 schedules the task processing unit to process the signal according to the indication of the task slot. Optionally, some signals do not include a task slot. The task processing unit obtains the task processing unit that processes the signal according to the identifier of the signal or the signal buffer where the signal is located.
[0141] Optionally, the signal 310 also includes information indicating a priority.
[0142] Figure 4A is a schematic diagram of a task management unit according to another embodiment of the present application.
[0143] The task management unit includes a signal distribution unit 410 , one or more signal buffers ( 420 , 422 . . . 42 n ), a task scheduling unit 440 and a resource management unit 450 .
[0144] The signal includes multiple switches. Figure 4A In the example, each entry of the signal cache represents a signal, and each signal includes four switches, as indicated by the squares in the entry of the signal cache.
[0145] The task scheduling unit 440 schedules one or more task processing units ( 460 , 462 . . . 46 n ) to process the task indicated by the signal.
[0146] The signal distribution unit 410 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. In response to receiving the signal, the signal distribution unit 410 adds the signal to a signal buffer corresponding to the type of the signal according to the type of the received signal.
[0147] The task scheduling unit 440 schedules the task processing units according to the signals in the signal buffers. The task scheduling unit 440 takes out a signal from one of the signal buffers and schedules one of the task processing units to process the signal.
[0148] In response to one or more resources being available, the resource management unit 450 sets the switches corresponding to the available resources to a "closed" state. For example, in response to one resource being available, the resource management unit 450 sets all switches corresponding to the resource to a "closed" state.
[0149] Still optionally, the task processing unit (460, 462...46n) processes the indicated task and consumes resources. In response to one or more resources becoming unavailable due to being consumed, the resource management unit 450 also sets the switch corresponding to the unavailable resource to the "off" state.
[0150] The task scheduling unit 440 is only a signal scheduling task processing unit in a “ready” state, and is not a signal scheduling task processing unit in a “waiting” state.
[0151] In one example, in response to a resource being available, the resource management unit 450 sets the switches corresponding to the resource of multiple signals to the "closed" state, so that two signals (represented as S1 and S2) become "ready" state. In this example, the resource management unit does not process the number of available resources. Even if the number of available resources is one, the corresponding switches of the two signals are set to the "closed" state. The task scheduling unit 440 selects signal S1 from signals S1 and S2, and schedules the task processing unit to process signal S1, consuming the resource. In response to the resource being unavailable, the resource management unit 450 sets the switches corresponding to the resource of multiple signals to the "disconnected" state, causing the signal (S2) to change from the "ready" state to the "waiting" state. And when the task scheduling unit 440 performs scheduling again, signal S2 cannot be processed because it is in the "waiting" state.
[0152] In another example, the resource management unit 450 reserves resources for one or more signals. For example, resource R1 is reserved for signal S1. In response to resource R1 being available, the resource management unit 450 identifies the available quantity of resource R1. If signal S1 is in the signal buffer, the resource management unit 450 sets the switch of resource R1 corresponding to signal S1 to a "closed" state according to the availability of resource R1, and although resource R1 has not been used and is still available, the resource management unit 450 calculates the available quantity of resource R1 according to the specified quantity of resource R1 consumed by signal S1. If the specified quantity of resource R1 is consumed by S1, the resource management unit 450 identifies that resource R1 is not available, and sets the switch of resource R1 corresponding to signal S2 to an "off" state. In this way, the resource management unit 450 reserves resources for signal S1.
[0153] In another example, the resource management unit 450 allocates resources to one or more signals. The resource management unit 450 maintains the number of available resources, and in response to setting the switches of one or more signals corresponding to the resources to the "closed" state according to the available resources, the number of available resources is decremented. Thus, setting the switch to the "closed" state represents that the resource is allocated to the processing of the corresponding signal (and will not be allocated to other signals).
[0154] In another example, the task processing unit or hardware recognizes that resources are available and sets a corresponding switch for a signal that the resources are needed, thereby sharing the work of the resource management unit 450 or eliminating the resource management unit 450.
[0155] Figure 4B A flow chart of distributing signals according to an embodiment of the present application is shown.
[0156] Signal distribution unit (410) (see also Figure 4A ) In response to obtaining the signal to be distributed, the signal is added to the corresponding signal buffer (460, 462...46n).
[0157] Optionally, the signal distribution unit 410 also checks the availability of each resource required by the signal, sets the switch of the signal corresponding to the available resource to the "closed" state, and sets the switch of the signal corresponding to the unavailable resource to the "open" state. When submitting the signal to the signal distribution unit 410, the signal sender also optionally sets the state of one or more switches of the signal according to the availability of the resources.
[0158] For the signals in the signal buffer, the resource management unit 450, the task processing unit, or the hardware providing the resources obtains the availability of one or more resources (490). In response to the resources being available, the switches corresponding to the resources for the signals requiring the available resources are set (492). Alternatively, in response to the resources being consumed and becoming unavailable, the switches corresponding to the resources for the signals requiring the corresponding resources are also set to the "off" state.
[0159] The task scheduling unit 440 obtains the signal in the "ready" state from the signal buffer (494). When all switches of the signal are "closed", the signal is in the "ready state". Optionally, the task scheduling unit 440 also selects the signal in the "ready" state according to randomness, rotation, weighted rotation and / or signal priority.
[0160] The task scheduling unit 440 schedules the task processing unit corresponding to the acquired signal to process the task indicated by the signal ( 496 ).
[0161] Figure 5A is a schematic diagram of a task management unit provided according to another embodiment of the present application.
[0162] Some processors run multiple processes. According to an embodiment of the present application, a task management unit is set for each process. When a process running on a processor is switched, the operating system or underlying software backs up the running context including architecture registers for the process swapped out, and restores the running context for the process swapped in. A process includes multiple task processing units. When task processing units belonging to the same process are switched, the operating system or underlying software does not switch the context for the task processing units. The task management unit manages or schedules the task processing units belonging to the process to which it belongs.
[0163] See also Figure 5A , processor CPU 0 runs process 0 and process 1, and each process includes a task management unit.
[0164] The task management unit of process 0 includes a signal distribution unit 510, one or more signal buffers (520, 522 ... 52n) and a task scheduling unit 540; the task management unit of process 1 includes a signal distribution unit 512, one or more signal buffers (530, 532 ... 53n) and a task scheduling unit 542. One or more task processing units (560, 562 ... 56n) scheduled by the task scheduling unit 540 run in process 0, and one or more task processing units (570, 572 ... 57n) scheduled by the task scheduling unit 542 run in process 1.
[0165] The task processing unit (560, 562 ... 56n) running on process 0 can send signals to the task processing units (560, 562 ... 56n) belonging to process 0 by calling the API provided by the task management unit also running on process 0, and can also send signals to the task processing units (570, 572 ... 57n) belonging to process 1. Conversely, the task processing unit (570, 572 ... 57n) running on process 1 can send signals to the task processing units (570, 572 ... 57n) belonging to process 1 by calling the API provided by the task management unit also running on process 1, and can also send signals to the task processing units (560, 562 ... 56n) belonging to process 0.
[0166] In response to receiving the signal, the signal distribution unit (510, 512) identifies the task processing unit in which the signal indicates which process is running. Taking the signal distribution unit 510 as an example, if the identification signal is to be sent to the task processing unit (560, 562...56n) running in process 0, the signal is added to the corresponding signal cache (520, 522...52n); if the identification signal is to be sent to the task processing unit (570, 572...57n) running in process 1, the signal is added to the corresponding signal cache (530, 532...53n). For the signal distribution unit 512, if the identification signal is to be sent to the task processing unit (560, 562...56n) running in process 0, the signal is added to the corresponding signal cache (520, 522...52n); if the identification signal is to be sent to the task processing unit (570, 572...57n) running in process 1, the signal is added to the corresponding signal cache (530, 532...53n).
[0167] according to Figure 5A In the embodiment, the signal distribution unit (510, 512) can add the signal to the signal cache of the process that does not belong to the same process as it, while the task scheduling unit (540, 542) can only schedule the task processing unit that belongs to the same CPU as it.
[0168] Figure 5B It is a flow chart of signal distribution by a signal distribution unit provided in an embodiment of the present application.
[0169] The signal distribution unit (510) (see also Figure 5A ), in response to obtaining a signal to be distributed (580), it is identified whether the task processing unit to receive the signal belongs to its own process or another process (582). If the signal indicates that the signal is to be processed by the task processing unit belonging to its own process (582), the signal distribution unit 510 adds the signal to the signal cache of its own process (584). If the signal indicates that the signal is to be processed by the task processing unit belonging to another process (582), the signal distribution unit 510 adds the signal to the signal cache of the other process (586).
[0170] Optionally, in order to prevent other processes receiving signals from being in a dormant state and causing the signal to be unable to be processed for a long time, the signal distribution unit 510 caches the other process after adding the signal to the signal cache of the other process (588). For example, the signal distribution unit 510 wakes up the other process by sending an interrupt signal to the other process. Still optionally, the signal distribution unit 510 infers whether process 1 is in a dormant state based on whether a signal has been added to the signal cache of process 1. For example, if there is no signal to be processed in any signal cache of process 1, the signal distribution unit 510 considers that process 1 is in a dormant state; if there is a task to be processed in any signal cache of process 1, the signal distribution unit 510 considers that process 1 is running and there is no need to wake up process 1.
[0171] Fig. 6A is a schematic diagram of a task management unit provided according to another embodiment of the present application.
[0172] Some processors include multiple CPU cores. According to an embodiment of the present application, a task management unit is set for a process running on each CPU core. A task processing unit manages a task processing unit of a process belonging to the CPU core where 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 multi-threaded system because a thread provides a virtual CPU core for the program it runs.
[0173] See also Fig. 6A , the processor includes CPU 0 and CPU 1. CPU 0 and CPU 1 each include two processes. CPU 0 runs process 612 and process 618, while CPU 1 runs process 622 and process 628. Each process includes a task management unit. The task management unit of process 612 of CPU 0 includes a signal distribution unit 610, one or more signal buffers, and a task scheduling unit 640; the task management unit of process 618 of CPU 0 includes a signal distribution unit 615, one or more signal buffers, and a task scheduling unit 642. One or more task processing units scheduled by the task scheduling unit 640 run in process 612 of CPU 0, while one or more task processing units scheduled by the task scheduling unit 642 run in process 618 of CPU 0.
[0174] The task management unit of the process 622 of CPU 1 includes a signal distribution unit 620, one or more signal buffers, and a task scheduling unit 650; the task management unit of the process 628 of CPU 1 includes a signal distribution unit 625, one or more signal buffers, and a task scheduling unit 652. One or more task processing units scheduled by the task scheduling unit 650 run in the process 622 of CPU 1, and one or more task processing units scheduled by the task scheduling unit 652 run in the process 628 of CPU 1.
[0175] The task processing unit of process 612 can send signals to task processing units belonging to the same process 612 by calling an API provided by a task management unit also running on process 612, and can also send signals to task processing units belonging to other processes (including other processes 618 of CPU 0, and other processes 622 and process 628 of CPU 1). The task processing unit belonging to process 622 running on CPU 1 can send signals to task processing units belonging to the same process 622 by calling an API provided by a task management unit belonging to process 622 also running on CPU 1, and can also send signals to task processing units belonging to other processes.
[0176] In response to receiving the signal, the signal distribution unit (610, 615, 620, 625) identifies the task processing unit on which the signal indicates the process is running. Taking the signal distribution unit 610 as an example, if the identification signal is to be sent to the task processing unit of the process 612 running on CPU 0, the signal is added to the corresponding signal cache of the process 612; if the identification signal is to be sent to the task processing unit of the process 628 running on CPU 1, the signal is added to the corresponding signal cache (330, 332...33n) of the process 628. Optionally, the signal cache is provided by a shared memory accessible to each CPU and each process. Still optionally, the signal cache is provided by a private memory maintained by each CPU, and access to the private memory belonging to other CPUs is provided by the operating system, underlying software or hardware.
[0177] according to Fig. 6A In the embodiment, the signal distribution unit (610, 615, 620, 625) can add a signal to a signal cache of a CPU that does not belong to the same CPU as the signal distribution unit. However, the task scheduling unit (640, 642, 650, 652) can only schedule the task processing unit that belongs to the same CPU as the task processing unit.
[0178] CPU 0 and CPU 1 each include a process wake-up unit (619, 629). Optionally, each process includes a process wake-up unit.
[0179] The process wake-up unit is used to wake up other processes to schedule the task processing unit to process signals.
[0180] According to an embodiment of the present application, a process state table is also maintained. The process state table is provided by a shared memory accessible to both CPU 0 and CPU 1. The process state table includes a plurality of entries, each of which indicates the execution state of one of the processes. The execution state of a process includes, for example, a "sleep" state and a "running" state.
[0181] In response to a signal distribution unit (e.g., signal distribution unit 615) sending a signal to other processes (e.g., process 622), process awakening unit 619 queries the state of process 622 through the process state table. If process 622 is in the "sleeping" state, the remote awakening unit modifies the entry of process 622 in the process state table to record the "working" state, and the remote awakening unit also sends an interrupt to CPU 1 where process 622 is located. In the interrupt processing unit of CPU 1, the process state table is accessed to obtain the execution state of each process running in itself, and the process in the "working" state is awakened.
[0182] If the remote wake-up unit 619 finds through the process status table that the process 622 is in the "working" state, no further processing is required.
[0183] When a process enters the dormant state, the "dormant" state is set in the entry of the process state table corresponding to the process.
[0184] Optionally, the remote awakening unit infers the execution state of the target process according to whether the signal buffer of the target process receiving the signal is empty, and awakens the target process in the "sleeping" state, while the target process in the "working" state does not need to be further processed.
[0185] Figure 6B This is a flowchart of a signal distribution unit distributing a signal according to another embodiment of the present application.
[0186] The signal distribution unit (610) (see also Fig. 6A ), in response to obtaining a signal to be distributed to the target process of the remote CPU 1 (680), the signal is added to the signal cache of the target process (682). The signal distribution unit (610) (or the remote wake-up unit 619) identifies whether the remote CPU 1 or the target process of the remote CPU 1 is in the "running" state (684).
[0187] If the remote CPU 1 or the target process is not in the "running" state (684), the signal distribution unit (610) (or the remote wake-up unit 619) sets the working state of the target process to the "running" state in the process state table, and also sends an interrupt to the remote CPU 1 (686). The interrupt processing function of the remote CPU 1 accesses the process state table and wakes up the target process according to the process state table (688).
[0188] If the remote CPU 1 or the target process is in the "running" state (684), the signal distribution unit (610) (or the remote wake-up unit 619) does not need further processing and distributes the process result of the signal (690).
[0189] In response to being awakened, the task scheduling unit of the target process starts working.
[0190] Fig. 7A is a schematic diagram of a task management unit provided according to yet another embodiment of the present application.
[0191] The task management unit includes a signal distribution unit 710 , one or more signal buffers ( 720 , 722 . . . 22 n ) and a task scheduling unit 750 .
[0192] In response to receiving the signal, the signal distribution unit 710 identifies whether there are sufficient resources to process the task. For example, whether there is sufficient storage space, whether the hardware resources required to process the task are idle, whether the data required for the task is ready, etc. Each resource required to process the signal has a corresponding switch. A signal with all switches "closed" is in a "ready" state, indicating that there are sufficient resources to process the signal.
[0193] If the received signal is already in the "ready" state, the signal distribution unit 710 calls the task processing unit (752, 754, ... or 75n) corresponding to the signal to process the task indicated by the signal without adding the signal to the signal buffer. If the received signal is already in the "waiting" state, the signal distribution unit 710 adds the signal to the corresponding signal buffer.
[0194] 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.
[0195] The resource management unit 740, the task processing unit, or the hardware providing the resources obtains the availability of one or more resources. In response to the availability of the resources, the switch corresponding to the resource of the signal requiring the available resources is set to a "closed" state. Alternatively, in response to the resource being consumed and becoming unavailable, the switch corresponding to the resource of the signal requiring the corresponding resource is also set to an "open" state.
[0196] The task scheduling unit 750 obtains the signal in the "ready" state from the signal buffer. Optionally, the task scheduling unit 750 also selects the signal in the "ready" state according to randomness, round-robin, weighted round-robin and / or signal priority. The task scheduling unit 750 schedules the task processing unit corresponding to the obtained signal to process the task indicated by the signal.
[0197] Still optionally, the API for sending signals provided by the task management unit to the task processing unit includes multiple types, or multiple parameters can be specified. The signal distribution unit 710 chooses whether to directly call the task processing unit corresponding to the signal in the "ready" state or add the signal to the signal cache according to the type or parameters of the API used by the task processing unit. It can be understood that even if the API used by the task processing unit indicates to directly call the task processing unit corresponding to the signal, if the signal is in the "waiting" state, the signal distribution unit 710 still adds the signal to the signal cache.
[0198] Still optionally, the API for sending signals provided by the task management unit to the task processing unit also specifies whether the signals are to be processed in sequence. The sequence is, for example, the sequence in which the task processing unit calls the API for sending signals. If the API indicates that the signals are to be processed in sequence, the signal distribution unit 710 may optionally still directly call the task processing unit corresponding to the signal in the "ready" state, and add the signal in the "waiting" state to the signal cache, and mark the sequence of the signal in the signal cache. For example, in a signal cache with a queue structure, the signal is added to the end of the queue, and the task scheduling unit 750 only obtains the signal in the "ready" state from the head of the queue.
[0199] In one example, the signal buffer includes both signals to be processed sequentially and signals that do not need to be processed sequentially. The signal distribution unit 710 adds signals to be processed sequentially to the signal buffer of the queue structure, and adds signals that do not need to be processed sequentially to other signal buffers.
[0200] Optionally, the priority of the signal buffer is adjusted according to the data of the signal in the signal buffer. In response to the number of signals in a certain signal buffer being greater than a threshold or its increment being greater than a threshold, the priority of the signal buffer is increased. In response to the number of signals in a certain signal buffer being less than a threshold or its increment being less than a threshold, the priority of the signal buffer is decreased.
[0201] Figure 7B It is a flow chart of signal distribution by a signal distribution unit provided in an embodiment of the present application.
[0202] Signal distribution unit (710) (see also Fig. 7A) In response to obtaining the signal to be distributed (760), it is identified whether the resources of the task corresponding to the processing signal are all ready (the signal is in the "ready" state) (762). 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 (764). If in step 762, 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 (768).
[0203] For the signals in the signal buffer, the resource management unit, the task processing unit, or the hardware providing the resources obtains the availability of one or more resources (770). In response to the resources being available, the switches corresponding to the resources are set to wait for the signals of the available resources (772). Alternatively, in response to the resources being consumed and becoming unavailable, the switches corresponding to the resources are also set to the "off" state for the signals requiring the corresponding resources.
[0204] The task scheduling unit 750 obtains a signal in the "ready" state from the signal buffer (774). When all switches of the signal are "closed", the signal is in the "ready state". The task scheduling unit 750 schedules the task processing unit corresponding to the obtained signal to process the task indicated by the signal (776).
[0205] Figure 7C This is a flowchart of a signal distribution unit distributing a signal according to another embodiment of the present application.
[0206] 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 (752, 754, ... 75n) (see also Fig. 7A After the task processing unit completes the S1 stage, it sends a signal to indicate that the S2 stage will be processed next.
[0207] See also Figure 7C , signal distribution unit (710) (see also Fig. 7A ) In response to obtaining the signal to be distributed (780), it is identified whether the processing signal is in the "ready" state (782). In the case where the signal is in the "ready" state, it is further identified whether the processing of the IO command indicated by the signal to be distributed has been started (784). 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.
[0208] 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 (786). If in step 784, 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 (788). Optionally, in step 784, 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 784, the task processing unit corresponding to the processing signal is called to reduce the quota by a specified amount. By setting the 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. Still optionally, in step 784, it is determined whether to directly schedule the task processing unit corresponding to the signal without adding the signal to the signal cache based on the type of API used to send the signal.
[0209] If, at step 782, it is identified that the processing signal is in the "waiting" state, the signal is added to the corresponding signal buffer (788).
[0210] Fig. 8A It is a schematic diagram of a task provided according to another embodiment of the present application.
[0211] Take IO commands as an example of a task. Storage devices usually process multiple IO commands at the same time. Fig. 8A In the example, the IO command (800, 802, 804) 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 800, 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 800.
[0212] 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.
[0213] 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.
[0214] Figure 8B is a schematic diagram of a task management unit provided according to another embodiment of the present application.
[0215] The task management unit includes a signal distribution unit 810 , one or more signal buffers ( 820 , 822 . . . 82 n ), a resource management unit 830 and a task scheduling unit 840 .
[0216] As an example, the signals correspond one-to-one to the task processing units.
[0217] The signal buffers (820, 822, ... 82n) correspond one to one with the IO command being processed. For example, signal buffer 820 is dedicated to accommodating signals indicating the processing of IO command 800 (or its various stages); signal buffer 822 is dedicated to accommodating signals indicating the processing of IO command 802 (or its various stages); signal buffer 82n is dedicated to accommodating signals indicating the processing of IO command 80n (or its various stages). The number of signal buffers is independent of the type of signal.
[0218] according to Figure 8B The task management unit of the embodiment schedules multiple task processing units (850, 852, ... 85m). 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.
[0219] The signal distribution unit 810 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 810 adds the obtained signal to the signal cache corresponding to the IO command corresponding to the same signal.
[0220] Optionally, the signal distribution unit 810 further identifies whether the signal is in a "ready" state. If the signal is in a "ready" state, a task processing unit (850, 852, ..., 85m) for processing the task corresponding to the signal is called.
[0221] Still optionally, when the signal is in the "ready" state, the signal distribution unit 810 also determines whether to directly schedule the task processing unit (850, 852 ... 85m) that processes 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, then the task processing unit (850, 852 ... 85m) that processes the task corresponding to the signal is directly scheduled.
[0222] The resource management unit 830, the task processing unit, or the hardware providing the resources obtains the availability of one or more resources. In response to the availability of the resources, the switch corresponding to the resource of the signal requiring the available resources is set to a "closed" state. Alternatively, in response to the resource being consumed and becoming unavailable, the switch corresponding to the resource of the signal requiring the corresponding resource is also set to an "open" state.
[0223] The task scheduling unit 850 obtains the signal in the "ready" state from the signal buffer. Optionally, the task scheduling unit 850 also selects the signal in the "ready" state according to randomness, round-robin, weighted round-robin and / or signal priority. The task scheduling unit 850 schedules the task processing unit corresponding to the obtained signal to process the task indicated by the signal.
[0224] Optionally, the task scheduling unit 840 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.
[0225] 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.
[0226] 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.
[0227] 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.
[0228] 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.
[0229] 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.
[0230] 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.
[0231] 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.
[0232] 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.
[0233] 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.
[0234] 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: include: Get the signal; In response to the signal being in a "ready" state, directly scheduling a task for processing the signal without adding the signal to a signal buffer; The task scheduling unit selects the signal in the "ready" state for processing according to randomness, round-robin, weighted round-robin and / or signal priority; If the processing of the signal is in a "waiting" state, the signal is recorded in a signal buffer; Among them, an API is provided to the task processing unit, and the task processing unit informs the task management unit of other task processing units that should be scheduled subsequently by calling the API; the task processing unit does not need to poll or wait for resource availability, and does not need to maintain the order between multiple task processing units; so that the task processing unit only needs to specify its subsequent task processing unit according to the logical order of the task, and the task management unit schedules the task processing unit under the requirement of satisfying the logical order; The task processing unit is used to process the same or different tasks, and the logical order of task processing is indicated in the code segment of each task; Wherein, a process includes multiple task processing units. When a task processing unit belonging to the same process is switched, the operating system or underlying software does not switch the context for the task processing unit; the task management unit manages or schedules the task processing unit belonging to the process to which it belongs; By calling the API provided by the task management unit running on the process, a signal can be sent to the task processing unit of the same process, or to the task processing unit of other processes; In response to acquiring the signal, identifying a process running a task corresponding to the signal, and adding the signal to a signal cache belonging to the process running the task corresponding to the signal.
2. The method according to claim 1, characterized in that: Also includes: Gets a signal in the "ready" state from the signal buffer and calls the task that handles the obtained signal.
3. The method according to claim 1, characterized in that in, There is a one-to-one correspondence between signal types and signal buffers.
4. The method according to claim 3, characterized in that in, According to the type of the signal, the signal is recorded in a signal buffer corresponding to the type of the signal.
5. The method according to claim 3 or 4, characterized in that: Get the signal from the signal buffer and schedule the task corresponding to the signal type according to the signal type.
6. The method according to claim 5, characterized in that The signal buffer is selected in a random, round-robin or weighted round-robin manner.
7. The method according to claim 1, wherein: Signals are used to process IO commands, and signal buffers correspond one-to-one to IO commands.
8. The method according to claim 3, wherein: If the signal is in the “ready” state and if the IO command indicated by the signal has not started to be processed, the signal is added to the signal buffer corresponding to the IO command indicated by the signal.
9. The method according to claim 8, characterized in that If the IO command indicated by the signal has started to be processed, a task for processing the acquired signal is scheduled.
10. The method according to claim 9, characterized in that If the signal is in a "waiting" state, the signal is added to a signal buffer corresponding to the IO command.
11. The method according to claim 10, characterized in that In response to starting to process a new IO command, a new signal buffer is allocated for the new IO command.
12. The method according to claim 7, characterized in that Signal buffers have priorities.
13. The method according to claim 12, characterized in that A signal buffer is selected based on its priority.
14. The method according to claim 13, characterized in that 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.
15. The method according to claim 14, characterized in that Set the priority of the signal buffer according to the order in which IO commands are started to be processed.
16. The method according to claim 15, 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.
17. The method according to claim 1, further comprising: Identify the execution state of the process of the task corresponding to the running signal, and if the process is in a dormant state, wake up the process.
18. The method according to claim 17, wherein A first processor where a process of the task corresponding to the running signal is located is identified, and if the first processor is a remote processor relative to the current processor and the process is in a dormant state, an interrupt is sent to the first processor.
19. The method according to claim 18, characterized in that It also includes: the interrupt processing unit of the first processor obtains the first process and / or the second process with signals to be processed in response to receiving the interrupt, and wakes up the first process and / or the second process.
20. The method according to claim 19, characterized in that The method further includes: in response to acquiring the signal, identifying the process of the task corresponding to the running signal, and setting the process as having a signal to be processed in the process status table.
21. The method according to claim 20, characterized in that The interrupt processing unit of the first processor obtains the first process and / or the second process having signals to be processed through the process status table.
22. The method of claim 18, wherein A signal includes a plurality of switches, and a signal in which all switches are closed is a signal in a "ready" state; wherein the switches correspond to resources required to process the signal; Among them, any signal of the switches being disconnected is a signal in the "waiting" state.
23. The method according to claim 22, further comprising: In response to a first resource required for processing the first signal being available, a switch of the first signal corresponding to the first resource is closed.
24. The method according to claim 23, characterized in that Also includes: In response to a first resource required for processing the first signal being unavailable, a switch of the first signal corresponding to the first resource is opened.
25. The method according to claim 24, characterized in that Also includes: In response to a task processing the first signal or the second signal consuming the first resource, the first resource becomes unavailable.
26. The method according to claim 25, characterized in that Also includes: Clears all signals from the signal cache.
27. The method according to claim 26, characterized in that Also includes: In response to determining to directly schedule the task to process the signal, if the signal is in a “wait” state, the signal is added to a signal buffer.
28. The method according to claim 27, characterized in that Also included is: in response to acquiring the signals, determining the order in which the signals are processed based on an API providing the signals or parameters associated with the signals.
29. The method according to claim 28, characterized in that Also includes: In response to the signals being processed in sequence, the signals are added to a signal buffer in the form of a queue.
30. The method according to claim 29, characterized in that The method further comprises: in response to the signal being processed in sequence and directly scheduling the task for processing the signal, and in response to the signal being in a "ready" state, scheduling the task for processing the signal.
31. The method according to claim 30, characterized in that The method further comprises: in response to the signal being processed in sequence and the task for processing the signal being directly scheduled, and in response to the signal being in a "waiting" state, adding the signal to a signal buffer in the form of a queue.
32. A storage device, comprising a control component and a non-volatile memory, wherein the control component is used to execute the method according to any one of claims 1-31.
Citation Information
Patent Citations
Process management method
CN1320240A
Systems and methods for idle driven scheduling
EP3010207A1
Task processing management method, operating system and computer program
JP2007200112A
Use of a data engine within a data processing apparatus
US20060271712A1
Distributing processing tasks within a processor
US7865894B1