Task processing method, device, storage device and storage medium

By real-time detection and inserting the task queue in the SSD controller, and scheduling the task queue according to priority, the problem of low task processing and data reading and writing efficiency in the prior art is solved, and more efficient data reading and writing and task processing is achieved.

CN115657959BActive Publication Date: 2025-07-29SHENZHEN CITY TECHWIN SEMICONDUCTOR COMPANY LIMITED
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211397569.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-09
Publication Date
2025-07-29
Estimated Expiration
2042-11-09

AI Technical Summary

Technical Problem

When existing SSD controllers process commands in the task queue, they cannot detect new pending commands in real time, resulting in data read and write rate loss, and low flexibility and efficiency in task processing and data read and write.

Method used

Maintain multiple task queues through real-time updates, detect and insert target commands based on the task identification number and priority. Commands with high priority are processed first, and task queues are scheduled according to priority levels to avoid re-execution of the entire program flow.

Benefits of technology

Improves the speed of data reading and writing, enhances the flexibility and efficiency of task processing, and reduces the time from detecting new target commands to processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115657959B_ABST
    Figure CN115657959B_ABST
Patent Text Reader

Abstract

This application relates to the field of data processing, and discloses a task processing method, device, storage device, and storage medium. The method includes: obtaining and identifying a task identification number and a priority of a target task, where the target task is a task that needs to be processed currently; sequentially detecting whether there is a first target command corresponding to the task identification number in descending order of priority; if so, inserting the first target command at the tail position of the corresponding task queue, and sequentially processing each first target command in the order of the positions in the task queue; if not, stopping the task processing flow. The embodiments of this application achieve real-time detection of target commands and insertion thereof into the corresponding task queues, and scheduling is performed among the task queues according to priorities, so that new target commands can be processed in a timely manner, and target commands with higher priorities are executed preferentially, thereby improving the flexibility and efficiency of task processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and in particular, to a task processing method, apparatus, storage device, and storage medium. Background Art

[0002] In the SSD (Solid State Disk) architecture, due to the limited CPU core frequency and real-time requirements, the SSD controller code runs without an OS (operating system). The SSD controller's read / write data scheduling algorithm needs to be implemented independently.

[0003] In the existing read / write data scheduling algorithms, when the processor processes the commands in the task queue, it cannot simultaneously detect whether there are new commands to be processed and insert them into the corresponding task queue. During this process, if a new command arrives, the program can only detect whether there are new commands to be processed after the entire task processing flow is completed. In this case, to execute the new command, the entire program flow needs to be executed again, resulting in a loss in the read / write data rate, and the flexibility and efficiency of task processing and data read / write are relatively low. Summary of the Invention

[0004] In view of this, to solve the problems of the prior art, this application provides a task processing method, apparatus, storage device, and storage medium.

[0005] In a first aspect, this application provides a task processing method. The processor updates and maintains multiple task queues in real time, and each of the task queues is used to store corresponding target commands. The method includes:

[0006] Obtain and identify the task identification number and priority of a target task, where the target task is the task to be processed currently;

[0007] Sequentially detect whether there is a first target command corresponding to the task identification number in descending order of priority; the first target command is at least one of a control command, a read data command, and a write data command;

[0008] If so, insert the first target command into the tail position of the corresponding task queue, and sequentially process each of the first target commands in the position order of the task queue;

[0009] If not, stop the task processing flow.

[0010] In an optional embodiment, the method further includes:

[0011] Real-time detect whether there is a second target command with a priority higher than that of the first target command being processed currently; the second target command is at least one of a control command, a read data command, and a write data command;

[0012] If so, output the task identification number corresponding to the second target command to switch to processing the second target command;

[0013] If not, continue to process the first target command.

[0014] In an alternative embodiment, after successively processing each of the first target commands in the order of the positions in the task queue, it further includes:

[0015] After processing the first target command and / or the second target command, detect whether there is a third target command to be processed; the third target command is at least one of a control command, a read data command, and a write data command;

[0016] If so, output the task identification number corresponding to the third target command;

[0017] If not, stop the task processing flow.

[0018] In an alternative embodiment, the task queue includes a priority queue, a read data queue, and a write data queue;

[0019] The priority queue is used to store control commands, the read data queue is used to store read data commands, and the write data queue is used to store write data commands;

[0020] The priorities of the read data command and the write data command are equal, and the priority of the control command is higher than that of the read data command and the write data command respectively.

[0021] In an alternative embodiment, the method further includes:

[0022] When processing the read data command, if there is no read data command in the read data queue and there is a write data command in the write data queue, output the task identification number corresponding to the write data command to switch to processing the write data command; or,

[0023] When processing the write data command, if there is no read data command in the write data queue and there is a read data command in the read data queue, output the task identification number corresponding to the read data command to switch to processing the read data command.

[0024] In an alternative embodiment, the method further includes:

[0025] When processing the read data command, a counter is used to count the tasks of the corresponding target task; when the task count reaches a predetermined first count threshold, if there is a write data command in the write data queue, the task identification number corresponding to the write data command is output to switch to processing the write data command; or,

[0026] When processing the write data command, a counter is used to count the tasks of the corresponding target task; when the task count reaches a predetermined second count threshold, if there is a read data command in the read data queue, the task identification number corresponding to the read data command is output to switch to processing the read data command.

[0027] In an alternative embodiment, the method further includes:

[0028] When processing the read data command, when the task count reaches the first count threshold, if there is no write data command in the write data queue, the task processing flow is stopped; or,

[0029] When processing the write data command, when the task count reaches the second count threshold, if there is no read data command in the read data queue, the task processing flow is stopped.

[0030] In a second aspect, the present application provides a task processing device, including:

[0031] An acquisition module, configured to acquire and identify the task identification number and priority of a target task, where the target task is a task to be processed currently;

[0032] A detection module, configured to sequentially detect whether there is a first target command corresponding to the task identification number in order from high to low in priority; the first target command is at least one of a control command, a read data command, and a write data command;

[0033] A processing module, configured to, if there is a first target command corresponding to the task identification number, insert the first target command at the tail position of the corresponding task queue, and sequentially process each of the first target commands according to the position order of the task queue;

[0034] A stop module, configured to stop the task processing flow if there is no first target command corresponding to the task identification number.

[0035] In a third aspect, the present application provides a storage device, where the storage device includes a memory and at least one processor, the memory stores a computer program, and the processor is configured to execute the computer program to implement the foregoing task processing method.

[0036] Fourthly, the present application provides a computer storage medium storing a computer program, which, when executed, implements the task processing method described above.

[0037] The embodiments of the present application have the following beneficial effects:

[0038] The embodiments of the present application provide a task processing method, including obtaining and identifying a task identification number and a priority of a target task, where the target task is a task that needs to be processed currently; sequentially detecting whether there is a first target command corresponding to the task identification number in descending order of priority, where the first target command is at least one of a control command, a read data command, and a write data command; if so, inserting the first target command into the tail position of the corresponding task queue, and sequentially processing each first target command according to the position order of the task queue; if not, stopping the task processing flow. The embodiments of the present application realize real-time detection of the target command and insert it into the corresponding task queue, and the task queues are scheduled according to the priority order, so that the new target command can be processed in time, without the need to re-execute the entire program flow, avoiding the loss in the data reading and writing rate, thus saving the time from detecting the new target command to processing the new target command, and the target command with a higher priority is executed first, thereby greatly improving the data reading and writing speed in the solid-state drive, and further improving the flexibility and processing efficiency of task processing and data reading and writing. Description of the Drawings

[0039] To more clearly illustrate the technical solutions of the present application, the drawings required for the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the protection scope of the present application. In each drawing, similar components are numbered similarly.

[0040] Figure 1 It shows a schematic diagram of the first implementation manner of the task processing method in the embodiments of the present application;

[0041] Figure 2 It shows a schematic diagram of the second implementation manner of the task processing method in the embodiments of the present application;

[0042] Figure 3 It shows a schematic diagram of the third implementation manner of the task processing method in the embodiments of the present application;

[0043] Figure 4 It shows a schematic diagram of the structure of the task processing device in the embodiments of the present application. Detailed Embodiments

[0044] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments.

[0045] Generally, the components of the embodiments of the present application described and illustrated herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but merely represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts fall within the scope of protection of the present application.

[0046] In the following, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are only intended to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0047] In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0048] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the various embodiments of the present application belong. Terms (such as those defined in a general use dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or being overly formal, unless clearly defined in the various embodiments of the present application.

[0049] In the SSD (Solid State Disk) architecture, due to the limited CPU core frequency and real-time requirements, the operating environment of the SSD controller code does not have an OS (Operating System). The read and write data scheduling algorithm of the SSD controller needs to be implemented independently. In the existing read and write data scheduling algorithms, the program checks whether there are control commands to be processed. If it detects that there are control commands to be processed, it inserts the control commands into the tail of the PQ (Prior Queue), and then the program continues to check whether there are control commands to be processed. Otherwise, the program will execute the next detection condition. The program checks whether there are read data commands to be processed. If it detects that there are read data commands to be processed, it inserts the read data commands into the tail of the RQ (Read Queue), and then the program continues to check whether there are read data commands to be processed. Otherwise, the program will execute the next detection condition. The program checks whether there are write data commands to be processed. If it detects that there are write data commands to be processed, it inserts the write data commands into the tail of the WQ (Write Queue), and then the program continues to check whether there are write data commands to be processed. Otherwise, the program will execute the next task queue processing flow.

[0050] When the program jumps to the task queue processing flow, it first checks whether there are control commands to be processed in the PQ queue. If there are control commands to be processed, it calls the control command processing function. After the control command processing is completed, it continues to check whether there are still control commands to be processed in the PQ queue. Otherwise, the program will execute the next step, which is to check whether there are read data commands to be processed in the RQ queue. When it detects that there are read data commands to be processed in the RQ queue, it calls the read data command processing function. After the read data command processing is completed, it continues to check whether there are read data commands to be processed in the RQ queue. Otherwise, the program will execute the next step of checking whether there are write data commands to be processed in the WQ queue. When it detects that there are write data commands to be processed in the WQ queue, it calls the write data command processing function. After the write data command processing is completed, it continues to check whether there are write data commands to be processed in the WQ queue. Otherwise, it exits the task processing flow, that is, stops the task processing flow.

[0051] Furthermore, in the SSD processing command scheduling algorithm, when detecting whether there are corresponding commands, it cannot process the corresponding commands in the task queue. When processing the commands in the task queue, it cannot detect new commands and insert them into the corresponding task queue. During this process, if new commands arrive, the program can only check whether there are new commands to be processed after the entire task processing flow is completed. In this case, to execute new commands, the entire program flow needs to be executed again, resulting in a loss in the read and write data rate, and reducing the task processing efficiency and flexibility.

[0052] Based on this, an embodiment of the present application provides a task processing method to improve the flexibility of task processing and data reading and writing, and improve the efficiency of task processing and data reading and writing.

[0053] Embodiment 1

[0054] Please refer to Figure 1 , an embodiment of the present application provides a task processing method, and the method will be described in detail below.

[0055] S10. Obtain and identify the task identification number and priority of the target task, where the target task is the task to be processed currently.

[0056] The processor updates and maintains multiple task queues in real time, and each task queue is used to store corresponding target commands.

[0057] When the processor detects that there is a target task to be processed currently, that is, when it determines that the task processing process needs to be executed, it identifies the task identification number of the target task and the priority corresponding to the target task; where the target task in this embodiment is the task to be processed currently.

[0058] In one embodiment, the task queues include a priority queue (Prior Queue, PQ queue), a read data queue (Read Queue, RQ queue), and a write data queue (Write Queue, WQ queue); the priority queue is used to store control commands to be processed currently, the read data queue is used to store read data commands to be processed currently, and the write data queue is used to store write data commands to be processed currently; the priorities of the read data commands and the write data commands can be set to be equal or unequal, which is not limited here; but the priority of the control command is higher than that of the read data command and the write data command respectively. Different commands correspond to different tasks, and the task identification numbers of each task are not equal. When processing the target task, multiple commands in the task queue corresponding to the target task can be processed in sequence. That is, the processor switches to process the control commands in the priority queue, the read data commands in the read data queue, and the write data commands in the write data queue.

[0059] In this embodiment, a scheduler (or queue task scheduling module) is responsible for scheduling (switching) multiple target tasks, so as to process the target commands corresponding to the target task in time. Specifically, when the main program in the processor calls the scheduler, the scheduler will schedule the target tasks with higher priorities in sequence according to the priorities of the respective target tasks, and process the commands corresponding to the target task.

[0060] S20. Detect in sequence whether there is a first target command corresponding to the task identification number in descending order of priority.

[0061] Detect whether there is a target command corresponding to the task identification number for one or more target tasks in descending order of priority; further, the target commands in the corresponding target tasks can be processed in descending order of priority; in this process, the target command to be processed is used as the first target command. Wherein, the first target command is at least one of a control command, a read data command, and a write data command.

[0062] If the target task is one, directly detect whether there is a first target command corresponding to the task identification number; if the target task is multiple, that is, the target task is the target task corresponding to at least two of a control command, a read data command, and a write data command, then in descending order of the priority corresponding to the target task, sequentially detect whether there is a first target command corresponding to the task identification number, so as to process the corresponding first target commands in descending order of priority.

[0063] S30, if there is a first target command corresponding to the task identification number, insert the first target command into the tail position of the corresponding task queue, and process each first target command in the order of the position in the task queue.

[0064] If there is a first target command corresponding to the task identification number in the current processor memory, insert the first target command into the tail position of the corresponding task queue, and process the first target commands stored in the task queue in the order of the positions of each first target command in the task queue.

[0065] Further, since when processing each target command, each target command is processed in the order of the position in the corresponding task queue, the order of the positions of each target command in the task queue determines the order of processing of each target command, and the target command arranged at the head position of the task queue is preferentially processed. Therefore, when inserting the first target command into the task queue, each target command is inserted into the task queue in sequence at the tail position.

[0066] In this embodiment, when the scheduler is called for the first time, the target command to be processed corresponding to the target task with the highest priority is preferentially processed. After the target command with the highest priority has been processed, continue to process the target commands corresponding to other target tasks until it is determined that there is no target command to be processed currently, then stop the task processing flow. If after processing all the target commands to be processed, it is detected that there are no other tasks to be processed, return a null value (Null) to the processor, and this null value indicates that there are no target tasks to be processed currently.

[0067] In an implementation manner, as Figure 2 shown, this embodiment further includes the following steps:

[0068] S50. Detect in real time whether there is a second target command whose priority is higher than that of the first target command being currently processed.

[0069] S51. If there is a second target command whose priority is higher than that of the first target command being currently processed, output the task identification number corresponding to the second target command to switch to processing the second target command.

[0070] S52. If there is no second target command whose priority is higher than that of the first target command being currently processed, continue to process the first target command.

[0071] When processing the first target command, detect in real time whether there is a second target command whose priority is higher than that of the first target command being currently processed inside the processor. When it is determined that there is a second target command with a higher priority, output the task identification number corresponding to the second target command. The scheduler switches the current task processing flow to the task processing flow corresponding to the task identification number according to this task identification number to process the second target command with a higher current priority in a timely manner. If it is determined that there is no second target command with a higher priority, continue to process the first target command until it is determined that there is no first target command to be processed in the current processor. Among them, the second target command is at least one of a control command, a read data command, and a write data command. And if the priorities of the read data command and the write data command are set to the same level, the second target command is a control command.

[0072] Insert the second target commands into the tail positions of the corresponding task queues in sequence. The number of the second target commands is not limited here, and the processor processes the second target commands in the order of their positions in the task queue in sequence.

[0073] For example, if a read data command is being processed currently and it is detected during this process that there is a control command to be processed, switch to the task processing flow corresponding to the control command to give priority to processing the control command with the highest priority, and then switch back to the task processing flow corresponding to the read data command to continue processing the read data command until it is determined that there is no read data command to be processed currently.

[0074] In an embodiment, as Figure 3 shown, this embodiment further includes the following steps:

[0075] S60. After processing the first target command and / or the second target command, detect whether there is a third target command to be processed.

[0076] S61. If there is a third target command to be processed, output the task identification number corresponding to the third target command.

[0077] S62. If there is no third target command to be processed, stop the task processing flow.

[0078] After processing the first target command and / or the second target command, that is, if there is no first target command or second target command to be processed in the current processor, it is detected whether there is any other target command to be processed in the processor, and this target command is taken as the third target command. Among them, the third target command is at least one of a control command, a read data command, and a write data command.

[0079] If it is detected that there is a third target command to be processed inside the current processor, the task identification number corresponding to the third target command is output, and the scheduler switches the current task processing flow to the task processing flow corresponding to the third target command according to this task identification number, and inserts the third target command into the tail position of the corresponding task queue in sequence. The quantity of the third target command is not limited here, and the processor processes the third target commands in sequence according to the position order of the third target commands in this task queue.

[0080] For example, if the first target command is a read data command and the second target command is a control command, after processing the second target command, if it is detected that there is a read data command or a write data command to be processed currently, then the task processing flow is switched to the task processing flow corresponding to the read data command or the write data command to process the corresponding target command.

[0081] Furthermore, the third target commands to be processed in the current processor include new target commands and target commands already stored in other task queues; if it is a new target command, then this new target command needs to be inserted into the tail position of the corresponding task queue to process each target command in this task queue correspondingly; if it is a target command already stored in other task queues, then the target commands can be directly processed in sequence according to the position order of the target commands in this task queue.

[0082] In this embodiment, it is possible to use the detection event task function (CheckEvent task) of the scheduler to detect in real time whether there is a new target command to be processed currently.

[0083] For example, the task identification number (TaskId) of the target task corresponding to the control command is denoted as Task1, the task identification number of the target task corresponding to the read data command is denoted as Task2, and the task identification number of the target task corresponding to the write data command is denoted as Task3.

[0084] When the scheduler executes for the first time, it will default to executing Task1 to process the control commands in the priority queue (PQ queue), and then call the CheckEvent task to detect whether there are new target commands to be processed. If there are new target commands to be processed, the new target commands will be added to the corresponding task queue, and then a TaskId corresponding to the new target command will be returned to the scheduler. The scheduler will schedule the next task to be processed according to the returned TaskId.

[0085] For example, call the CheckEvent task to detect whether there are new control commands or other target commands to be processed. If there are new control commands, insert the control commands into the priority queue. After processing all control commands, if the CheckEvent task detects new other target commands (such as read data commands), insert the read data commands into the read data queue, and then return a corresponding TaskId to the scheduler. The scheduler will schedule the next task to be processed according to the returned TaskId.

[0086] Specifically, in Task1, detect whether there are control commands to be processed in the PQ queue. If there are control commands, process the control commands in order according to the positions in the PQ queue, and then return a null value to the scheduler to indicate that there are no other tasks to be processed currently; otherwise, return Task2 or Task3 accordingly. If TaskId = Task2, detect whether there are read data commands in the RQ queue in Task2, and if there are read data commands, process the read data commands.

[0087] The scheduling strategy of the CheckEvent task will control the return of the TaskId after the end of the current task processing flow, so that the scheduler can schedule the next task to be processed according to the TaskId.

[0088] Task1 indicates to process the control commands in the PQ queue. Since the priority of the control commands is the highest, if it is detected that there are control commands to be processed in the PQ queue when executing Task2 or Task3, the processing flow of Task1 needs to be switched to the current task processing flow to process the control commands in the priority queue.

[0089] Furthermore, in Task1, detect whether there are control commands in the PQ queue. If there are control commands, process all the control commands in the PQ queue, and then if no new target commands to be processed are currently detected, return null to make the scheduler exit the entire current task processing flow; otherwise, return the task identification number corresponding to the new target command, such as Task2, so that the scheduler can switch Task2 to the current task to be processed.

[0090] Task 2 task instruction processes the read data command in the RQ queue, and Task 3 task instruction processes the write data command in the WQ queue.

[0091] Further, when processing the read data command, if there is no read data command in the read data queue and there is a write data command in the write data queue, the task identification number corresponding to the write data command is output to switch to processing the write data command; or, when processing the write data command, if there is no read data command in the write data queue and there is a read data command in the read data queue, the task identification number corresponding to the read data command is output to switch to processing the read data command.

[0092] If the current target task being processed is the Task 2 task, first detect whether there is a read data command in the RQ queue. If there is no read data command, return Null or the corresponding TaskId; otherwise, process the read data command in the RQ queue. During this process, synchronously call the CheckEvent task to detect whether there is a new target command (such as a read data command, a write data command, or a control command) that needs to be processed. If there is a new target command that needs to be processed, add the new command to the corresponding task queue. At the same time, the scheduler is responsible for managing the switching of the task processing flow to be executed next time to return the corresponding TaskId. In the Task 2 task, if the TaskId returned by the CheckEvent task is Task 2, continue to process the command in the RQ queue; otherwise, return the TaskId corresponding to the new target command.

[0093] If the current target task being processed is the Task 3 task, first detect whether there is a write data command in the WQ queue. If there is no write data command, return Null or the corresponding TaskId; otherwise, process the write data command in the WQ queue. During this process, synchronously call the CheckEvent task to detect whether there is a new target command (such as a read data command, a write data command, or a control command) that needs to be processed. If there is a new target command that needs to be processed, add the new command to the corresponding task queue. At the same time, the scheduler is responsible for managing the switching of the task processing flow to be executed next time to return the corresponding TaskId. In the Task 3 task, if the TaskId returned by the CheckEvent task is Task 3, continue to process the command in the WQ queue; otherwise, return the TaskId corresponding to the new target command.

[0094] Furthermore, in this embodiment, the CheckEvent task is responsible for detecting whether there is a new target command that needs to be processed and for scheduling the switching of the four tasks of Null, Task1, Task2, and Task3. Among them, the Null task is to indicate to stop the task processing flow.

[0095] In one embodiment, when processing read data commands and write data commands, a counter can also be used for task counting. That is, when processing a read data command once or during the task processing flow of a read data command, a count is incremented. The specific counting method is not limited herein. When the counted value reaches a predetermined counting threshold and there is a target command stored in other task queues, the current task processing flow is switched to the task processing flow corresponding to that other task queue.

[0096] Furthermore, when processing a read data command, a counter is used to perform task counting on the corresponding target task. When the task counting reaches a predetermined first counting threshold, if there is a write data command in the write data queue, the task identification number corresponding to the write data command is output to switch to processing the write data command. Or, when processing a write data command, a counter is used to perform task counting on the corresponding target task. When the task counting reaches a predetermined second counting threshold, if there is a read data command in the read data queue, the task identification number corresponding to the read data command is output to switch to processing the read data command.

[0097] Further, when processing a read data command, when the task counting reaches the first counting threshold, if there is no write data command in the write data queue, the task processing flow is stopped. Or, when processing a write data command, when the task counting reaches the second counting threshold, if there is no read data command in the read data queue, the task processing flow is stopped.

[0098] Among them, the first counting threshold and the second counting threshold can be equal or not equal, and their specific values are not limited herein.

[0099] Exemplarily, the CheckEvent task first detects whether there is a new control command to be processed. If there is a new control command, it returns Task1. Otherwise, it detects whether there is a read data command. If a read data command is detected, the read data command is inserted into the RQ queue, and then it continues to detect whether there is a write data command. If a write data command is detected, the write data command is inserted into the WQ queue, and then the task processing scheduling process is executed to return the corresponding TaskId, thereby switching the corresponding task processing flow.

[0100] In one embodiment, a task processing order can be set, such as first processing control commands, then processing read data commands, and finally processing write data commands. When the previous target task reaches a predetermined condition, the predetermined next target task is executed until all write data commands are processed, and Null is returned to indicate the stop of the task processing flow.

[0101] Specifically, after processing all control commands, first detect whether the current CheckEvent task is called by Task2 or Task3, that is, determine whether the current task processing flow is Task2 or Task3. If the CheckEvent task is called by Task2, start the Task2 task counter. When there is a write data command stored in the WQ queue and the Task2 counter reaches the first counting threshold (such as 16, etc.), or there is no read data command in the RQ queue, return to Task3; otherwise, return to Task2. If the CheckEvent task is called by Task3, start the Task3 task counter. When there is a read data command stored in the RQ queue and the Task3 counter reaches the second counting threshold, or there is no write data command in the WQ queue, return to Task2; otherwise, detect whether there is a write data command in the WQ queue. If there is a write data command in the WQ queue, return to Task3; otherwise, return to Null.

[0102] S40. If there is no first target command corresponding to the task identification number, stop the task processing flow.

[0103] If there is currently no first target command corresponding to the task identification number, it means that there is no target command to be processed currently, and thus the task processing flow can be stopped.

[0104] In this embodiment, two scheduling strategies are provided through the scheduler and the CheckEvent task. One is to timely receive new target commands and insert them into the corresponding task queues; the other is to schedule between each task queue according to the priority order. Under these two scheduling strategies, the newly received control commands can always be preferentially executed. When executing Task2 corresponding to the read data command and Task3 corresponding to the write data command, the corresponding new target commands can always be timely supplemented into the RQ queue and the WQ queue. Therefore, the new target commands can also be immediately executed without having to execute the entire program flow again, thus saving the time from detecting the new target command to processing the new target command, greatly improving the data reading and writing speed in the solid-state drive, and further improving the flexibility and processing efficiency of task processing and data reading and writing.

[0105] Embodiment 2

[0106] Please refer to Figure 4 , this embodiment of the present application provides a task processing device, which includes:

[0107] An acquisition module 100, configured to acquire and identify the task identification number and priority of a target task, where the target task is the task to be processed currently;

[0108] The detection module 200 is configured to sequentially detect whether there is a first target command corresponding to the task identification number in the order of decreasing priority; the first target command is at least one of a control command, a read data command, and a write data command;

[0109] The processing module 300 is configured to, if there is a first target command corresponding to the task identification number, insert the first target command into the tail position of the corresponding task queue, and sequentially process each of the first target commands in the order of the positions in the task queue;

[0110] The stop module 400 is configured to stop the task processing flow if there is no first target command corresponding to the task identification number.

[0111] The above task processing device corresponds to the task processing method of Embodiment 1; any optional items in Embodiment 1 are also applicable to this embodiment and will not be elaborated here.

[0112] An embodiment of the present application further provides a storage device (such as a solid-state drive, etc.), which includes a memory and at least one processor. The memory stores a computer program, and the processor is configured to execute the computer program to implement the task processing method of the above embodiment.

[0113] The memory may include a program storage area and a data storage area. Among them, the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created according to the use of the storage device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0114] An embodiment of the present application further provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and run by a processor, the computer-executable instructions cause the processor to run the steps of the task processing method of the above embodiment.

[0115] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0116] In addition, each functional module or unit in various embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0117] If the above functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0118] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered by the protection scope of the present application.

Claims

1. A task processing method, characterized in that, Applied to a solid-state drive, a processor updates and maintains multiple task queues in real time, and each of the task queues is used to store corresponding target commands. The method includes: Obtain and identify the task identification number and priority of a target task, where the target task is the task to be processed currently; Sequentially detect whether there is a first target command corresponding to the task identification number in descending order of priority; the first target command is at least one of a control command, a read data command, and a write data command; if so, insert the first target command into the tail position of the corresponding task queue, and sequentially process each of the first target commands according to the position order of the task queue; if not, stop the task processing flow; Detect in real time whether there is a second target command with a priority higher than the first target command being processed currently; the second target command is at least one of a control command, a read data command, and a write data command; if so, output the task identification number corresponding to the second target command to switch to processing the second target command; if not, continue to process the first target command.

2. The task processing method according to claim 1, wherein After sequentially processing each of the first target commands according to the position order of the task queue, it further includes: After processing the first target command and / or the second target command, detect whether there is a third target command to be processed; the third target command is at least one of a control command, a read data command, and a write data command; If so, output the task identification number corresponding to the third target command; If not, stop the task processing flow.

3. The task processing method according to claim 1, characterized in that The task queues include a priority queue, a read data queue, and a write data queue; The priority queue is used to store control commands, the read data queue is used to store read data commands, and the write data queue is used to store write data commands; The priorities of the read data command and the write data command are equal, and the priority of the control command is higher than that of the read data command and the write data command respectively.

4. The task processing method according to claim 3, wherein, The method further includes: When processing the read data command, if there is no read data command in the read data queue and there is a write data command in the write data queue, output the task identification number corresponding to the write data command to switch to processing the write data command; or, When processing the write data command, if there is no read data command in the write data queue and there is a read data command in the read data queue, output the task identification number corresponding to the read data command to switch to processing the read data command.

5. The task processing method according to claim 3, wherein The method further includes: When processing the read data command, use a counter to perform task counting on the corresponding target task; when the task counting reaches a predetermined first counting threshold, if there is a write data command in the write data queue, output the task identification number corresponding to the write data command to switch to processing the write data command; or, When processing the write data command, use a counter to perform task counting on the corresponding target task; when the task counting reaches a predetermined second counting threshold, if there is a read data command in the read data queue, output the task identification number corresponding to the read data command to switch to processing the read data command.

6. The task processing method according to claim 5, wherein The method further includes: When processing the read data command, when the task count reaches the first count threshold, if there is no write data command in the write data queue, stop the task processing flow; or, When processing the write data command, when the task count reaches the second count threshold, if there is no read data command in the read data queue, stop the task processing flow.

7. A task processing device, characterized in that, The task processing device is applied to a solid state drive, and the device includes: An acquisition module, configured to acquire and identify a task identification number and a priority of a target task, where the target task is a task to be processed currently; A detection module, configured to sequentially detect whether there is a first target command corresponding to the task identification number in order from high to low priority; the first target command is at least one of a control command, a read data command, and a write data command; A processing module, configured to, if there is a first target command corresponding to the task identification number, insert the first target command to the tail position of the corresponding task queue, and sequentially process each of the first target commands according to the position order of the task queue; A stop module, configured to stop the task processing flow if there is no first target command corresponding to the task identification number; A switching module, configured to detect in real time whether there is a second target command with a priority higher than that of the first target command being currently processed; the second target command is at least one of a control command, a read data command, and a write data command; when detecting that there is a second target command with a priority higher than that of the first target command being currently processed, output the task identification number corresponding to the second target command to switch to processing the second target command; The processing module is further configured to continue processing the first target command if there is no second target command with a priority higher than that of the first target command being currently processed.

8. A storage device, characterized in that, The storage device includes a memory and at least one processor, the memory stores a computer program, and the processor is configured to execute the computer program to implement the task processing method according to any one of claims 1-6.

9. A computer storage medium, characterized in that, It stores a computer program, and when the computer program is executed, it implements the task processing method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Systems And Methods For Dynamic Priority Control

    CN104160384A

  • SSD instruction scheduling method and system based on storage content priority

    CN113821175A