A task scheduling mechanism method for weighted round-robin arbitration in a dual-core mode
By adopting the weighted circular arbitration task scheduling mechanism in dual-core mode in the SSD software system, dynamically adjusting the weight and status of the task, solving the problems of low task scheduling efficiency and unstable performance in traditional SSD software, and achieving efficient and stable task execution.
Patent Information
- Application Number
- CN202211573653.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-12-08
AI Technical Summary
In traditional SSD software, task scheduling efficiency is low, and the operation performance is unstable. It is impossible to adjust the execution order and number of functions according to different needs, resulting in mutual blockage.
The weighted circular arbitration task scheduling mechanism in dual-core mode is adopted. By assigning task ID, initial weight and status to each functional module, determining whether to execute tasks based on the scheduling weight and task status, and dynamically adjusting the weight and status in the global circular scheduling, function execution similar to time slice rotation is achieved.
It effectively avoids unnecessary function calls, reduces blockage between functional modules, and improves the operating efficiency and performance stability of the SSD software system.
Smart Images

Figure CN115794349B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer storage, and particularly relates to a task scheduling mechanism method for weighted round-robin arbitration in a dual-core mode. Background Art
[0002] With the rapid development of cloud computing and big data technologies, the growth of multi-faceted application data poses new challenges to computer storage systems. Due to its high performance, low power consumption and other advantages, the solid-state drive (SSD) based on flash memory has brought opportunities for innovation to computer architectures and software. After years of development, SSD technology has also made great progress. Currently, the market applications have put forward higher and higher requirements for the real-time performance of SSDs.
[0003] However, the basic approach of traditional SSD software is to use a main loop to serially execute corresponding functions. In this way, not only does it lead to frequent judgments and function calls in the main loop, resulting in mutual blocking among various modules, but it also cannot adjust the order and number of function executions according to different requirements during the operation of the SSD. As a result, the efficiency of SSD software is relatively low and the running performance is unstable. Summary of the Invention
[0004] In order to solve the above problems existing in the related technologies, the present invention provides a task scheduling mechanism method for weighted round-robin arbitration in a dual-core mode. The technical problems to be solved by the present invention are realized through the following technical solutions:
[0005] The present invention provides a task scheduling mechanism method for weighted round-robin arbitration in a dual-core mode, including:
[0006] Regarding each functional module corresponding to the first processor and the second processor in the SSD software system as a task, assigning a task ID, an initial weight, and an initial state, and respectively determining the scheduling weights of the first processor and the second processor; the initial state is used to represent whether the task is executable;
[0007] When the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, it determines the currently scheduled task according to its corresponding task and task ID, and determines whether to execute the currently scheduled task according to the relationship between the initial state of the currently scheduled task, its own scheduling weight, and the initial weight of the currently scheduled task. When not executing, it updates the initial state of the currently scheduled task based on the execution result of the previously executed scheduled task, and completes the scheduling of the currently scheduled task; then, it determines the next scheduled task for scheduling until, when traversing all its corresponding tasks, it reduces its own scheduling weight, and based on the reduced scheduling weight, re-traverses and schedules its corresponding tasks until its own scheduling weight is reduced to a preset value, and completes the current global loop scheduling;
[0008] Update the initial weights and initial states of at least one task corresponding to itself based on the current running situation;
[0009] Based on the updated weights and states of the at least one task, the initial weights and initial states of the tasks that have not been updated among the tasks corresponding to itself, and its own scheduling weight, continue to perform the next global loop scheduling on the tasks corresponding to itself until the command is completed.
[0010] The present invention has the following beneficial technical effects:
[0011] During the execution of the command, by determining whether to execute each task according to the state and weight of the task and the scheduling weight of the scheduler, functions of some tasks that do not need to be executed will not be called, effectively avoiding excessive function calls in the main loop of the SSD software system; and, by executing the command in this cyclic scheduling manner, the effect of implementing the function of the SSD software system in a manner similar to time slice rotation is achieved, thus reasonably avoiding the situation where each functional module blocks each other, and improving the running efficiency of the SSD software system; and, by updating the weights and states of some tasks (functional modules) according to the running situation of the SSD software system, and continuing cyclic scheduling according to the updated weights and states, the execution times of the corresponding functional modules within a certain period of time can be dynamically adjusted according to the actual running situation, thereby reducing the situation where each functional module is evenly called within a certain period of time, and improving the stability of the overall performance of the SSD software system.
[0012] The following will further describe the present invention in detail with reference to the drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1An optional flowchart of the task scheduling mechanism method for weighted round-robin arbitration in the dual-core mode provided by the embodiments of the present invention;
[0014] Figure 2 An operating architecture diagram of an exemplary SSD software system provided by the embodiments of the present invention. Detailed implementation manners
[0015] The present invention will be further described in detail below in conjunction with specific embodiments, but the implementation manners of the present invention are not limited thereto.
[0016] In the description of the present invention, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, "a plurality of" means two or more, unless otherwise specifically defined.
[0017] In the description of this specification, the descriptions referring to terms such as "an embodiment", "some embodiments", "example", "specific example", or "some examples" etc. mean that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification.
[0018] Although the present invention is described herein in conjunction with various embodiments, however, in the process of implementing the claimed present invention, those skilled in the art can understand and realize other variations of the disclosed embodiments by viewing the accompanying drawings, the disclosed content, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude a plurality of situations. A single processor or other unit can implement several functions recited in the claims. Certain measures are recited in mutually different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0019] Figure 1 It is an optional flowchart of the task scheduling mechanism method for weighted round-robin arbitration in the dual-core mode provided by the embodiments of the present invention. As Figure 1 shown, the method includes the following steps:
[0020] S101. Take each functional module corresponding to the first processor and the second processor in the SSD software system as a task, assign a task ID, an initial weight, and an initial state, and respectively determine the scheduling weights of the first processor and the second processor; the initial state is used to represent whether the task is executable.
[0021] In an embodiment of the present invention, the SSD software system may be a software system with dual cores (dual processors); among them, the functional modules corresponding to the first processor and the functional modules corresponding to the second processor are different. The functional modules corresponding to the first processor include the front end of the SSD and the functional modules in the flash translation layer. For example, the front end command processing module, the front end command dispatching module, the garbage collection module, and the flash block management module; the functional modules corresponding to the second processor include the functional modules in the back end of the SSD, mainly including the operation module for the flash, such as the command request module for the flash operation and the command status reply module.
[0022] In an embodiment of the present invention, the initialization module in the SSD software system takes each functional module corresponding to the first processor and the second processor as a task respectively, and assigns a task ID (identifier) to each task. Among them, a unique task ID can be assigned to each task, or the same task ID can be assigned to two or more tasks; and, according to the priority of the function of the functional module corresponding to each task, set the initial weight and the initial state for this task; and, according to the number of tasks corresponding to the first processor, set the scheduling weight for the first processor, and according to the number of tasks corresponding to the second processor, set the scheduling weight for the second processor.
[0023] Here, when a unique task ID is assigned to each task, the execution of unnecessary tasks can be reduced; when the same task ID is assigned to two or more tasks, the number of tasks corresponding to the first processor or the second processor can be reduced, so that the scheduling efficiency can be improved when performing task scheduling.
[0024] Here, a high initial weight can be set for the functional module with a high priority, a low initial weight can be set for the functional module with a low priority (the specific value of the weight can be set according to actual needs), and the initial state of the functional module with a high priority is set to the active state, while the initial state of the functional module with a low priority is set to the suspended state. For example, when the SSD software system is initialized, first, it is necessary to receive front end instructions, and it is not necessary to execute the garbage collection task. Therefore, the initial state of the command receiving module (command receiving task) in the SSD software system can be set to the active state, and the initial state of the garbage collection module can be set to the suspended state.
[0025] Here, when the initial state of a task is the active state or the idle state, it means that the task can be executed when the execution condition (weight is greater than or equal to the scheduling weight) is met; when the initial state of the task is the paused state, it means that the task cannot be executed even when the execution condition is met.
[0026] Here, when determining the scheduling weight of the first processor, the total number of tasks corresponding to the first processor can be determined as the scheduling weight of the first processor, or the scheduling weight of the first processor can be set to a value greater than the total number of tasks corresponding to the first processor. Similarly, when determining the scheduling weight of the second processor, the total number of tasks corresponding to the second processor can be determined as the scheduling weight of the second processor, or the scheduling weight of the second processor can be set to a value greater than the total number of tasks corresponding to the second processor.
[0027] In some embodiments, each task also corresponds to a waiting count, and the waiting counts of some tasks need to be adjusted according to the running situation. For example, when some functional modules at the backend of the SSD software system perform read or write operations, the command dispatching functional module at the front end of the SSD may enter the paused state. At this time, the waiting count can indicate how many read or write operations at the backend have not been processed yet. And each time a read or write operation is successfully executed at the backend, the waiting count of this command dispatching functional module is decreased by 1. When the waiting count is decreased to 0, this command dispatching functional module can be activated by the task scheduler.
[0028] S102. When the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, determine the current task to be scheduled according to the tasks and task IDs corresponding to itself. Determine whether to execute the current task to be scheduled according to the size relationship between the initial state of the current task to be scheduled, its own scheduling weight, and the initial weight of the current task to be scheduled. When not executing, update the initial state of the current task to be scheduled based on the execution result of the previous executed task to be scheduled, and complete the scheduling of the current task to be scheduled; then, determine the next task to be scheduled for scheduling until after traversing all the tasks corresponding to itself, reduce its own scheduling weight, and based on the reduced scheduling weight, re-traverse and schedule the tasks corresponding to itself until its own scheduling weight is reduced to a preset value, and complete the current global loop scheduling.
[0029] In the embodiments of the present invention, the command received by the first processor can be a user's command, and the command received by the second processor can be a preset command sent by the first processor to the second processor in the process of global loop scheduling through shared memory; after the second processor completes the preset command, it feeds back the completion result to the first processor through shared memory.
[0030] Exemplarily, the preset command may be a command for performing read, write, and erase operations on the flash memory. Specifically, when a task in the first processor needs to perform read, write, and erase operations on the flash memory, it can notify the second processor to process the corresponding command through the shared memory. Then, the task in the second processor corresponding to executing the flash memory operation command sends the corresponding command to the flash memory, and after sending the command, it does not need to wait for the status of this command and can continue to receive other commands from the first processor and dispatch them to the flash memory. When the second processor receives the response that the command processing is completed, it executes its own status reply task and feeds back the execution result to the first processor in the same way of shared memory.
[0031] In the present invention, the task scheduling mechanism employed by the first processor or the second processor queries in a rotating rest manner whether there are new commands to be processed and whether there are new statuses to be replied. If so, it calls the corresponding tasks to execute and replies with the execution results.
[0032] In the embodiments of the present invention, the scheduling mechanism of the present invention is adopted in both cores of the SSD software system to execute various functions, greatly improving the operating efficiency of the SSD software.
[0033] In the embodiments of the present invention, the preset value can be set according to actual needs. For example, it can be 0.
[0034] In the embodiments of the present invention, the scheduling weight can be subtracted by a preset value each time. For example, the scheduling weight is subtracted by 1 each time.
[0035] In some embodiments, when the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, it determines the current task to be scheduled according to its corresponding task and task ID, and determines whether to execute the current task to be scheduled according to the size relationship between the initial state of the current task to be scheduled, its own scheduling weight, and the initial weight of the current task to be scheduled. When not executing, it updates the initial state of the current task to be scheduled based on the execution result of the previous executed task to be scheduled, and completes the scheduling of the current task to be scheduled, which can be implemented through S1021~S1024:
[0036] S1021. When the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, it determines the current task to be scheduled from its corresponding tasks according to the task ID of its corresponding task.
[0037] In an embodiment of the present invention, when the first processor or the second processor receives a command, the command can be executed by cyclically scheduling all the tasks corresponding to the first processor itself or the second processor itself. For example, when the first processor starts to execute the received command, that is, performs the first global cyclic scheduling, it can first select a task ID from the task IDs of all the tasks corresponding to itself, and use the task corresponding to the selected task ID as the current to-be-scheduled task, and schedule the current to-be-scheduled task through the following steps S1022 to S1024.
[0038] S1022. When the initial state of the current to-be-scheduled task is an active state or an idle state, and the scheduling weight of the first processor or the second processor itself is less than or equal to the initial weight of the current to-be-scheduled task, execute the current to-be-scheduled task by calling the callback function of the current to-be-scheduled task.
[0039] S1023. When the scheduling weight of itself is greater than the initial weight of the current to-be-scheduled task, update the initial state of the current to-be-scheduled task according to the execution result of the previous to-be-scheduled task executed by the current to-be-scheduled task.
[0040] Here, the first processor or the second processor can first determine whether the initial state of the current to-be-scheduled task is an active state or an idle state, and when the initial state of the current to-be-scheduled task is an active state or an idle state, it knows that the current to-be-scheduled task can be executed when the execution conditions are met, so it can compare the size between its own scheduling weight and the initial weight of the current to-be-scheduled task, and when its own scheduling weight is less than or equal to the initial weight of the current to-be-scheduled task, execute the current to-be-scheduled task by calling the callback function of the current to-be-scheduled task; and when its own scheduling weight is greater than the initial weight of the current to-be-scheduled task, it can update the initial state of the current to-be-scheduled task according to the execution result of the previous to-be-scheduled task executed by the current to-be-scheduled task.
[0041] In some embodiments, updating the initial state of the current to-be-scheduled task according to the execution result of the previous to-be-scheduled task executed by the current to-be-scheduled task may specifically include the following situations:
[0042] 1) When the execution result of the previous to-be-scheduled task executed by the current to-be-scheduled task is empty, do not update the initial state of the current to-be-scheduled task.
[0043] Here, when the execution result of the previous scheduled task of the current scheduled task is empty, it may mean that the current scheduled task is the first scheduled task. That is to say, after receiving the command, the first processor or the second processor has not executed any tasks before this current scheduled task.
[0044] 2) When the execution result of the previous scheduled task of the current scheduled task is not empty and the execution result is related to the current scheduled task, update the initial state of the current scheduled task to the active state or the idle state.
[0045] Here, when the execution result of the previous scheduled task of the current scheduled task is not empty, it may mean that the first processor or the second processor has executed at least one scheduled task after receiving the command and before this current scheduled task; and the previous scheduled task of the current scheduled task refers to the last scheduled task executed among the at least one scheduled task that has been executed.
[0046] Here, when the execution result of the previous scheduled task needs to be processed by the current scheduled task, it can be determined that the execution result of the previous scheduled task of the current scheduled task is related to the current scheduled task; otherwise, there is no relation.
[0047] Here, updating the initial state of the current scheduled task to the active state or the idle state may mean: when the initial state of the current scheduled task is the paused state, changing the initial state of the current scheduled task to the active state or the idle state, or when the initial state of the current scheduled task is the active state or the idle state, keeping the initial state of the current scheduled task as the active state or the idle state.
[0048] 3) When the execution result of the previous scheduled task of the current scheduled task is not empty and the execution result is not related to the current scheduled task, update the initial state of the current scheduled task to the paused state.
[0049] Similarly, here, updating the initial state of the current scheduled task to the paused state may mean: when the initial state of the current scheduled task is the paused state, keeping the initial state of the current scheduled task as the paused state, or when the initial state of the current scheduled task is the active state or the idle state, changing the initial state of the current scheduled task to the paused state.
[0050] S1024. After calling the callback function of the current task to be scheduled or updating the status of the current task to be scheduled, it is determined that the scheduling of the current task to be scheduled is completed.
[0051] In some embodiments, the determination of the next task to be scheduled for scheduling in S102 above is performed until, when traversing all the tasks corresponding to itself, its own scheduling weight is reduced. Based on the reduced scheduling weight, the tasks corresponding to itself are traversed and scheduled again until its own scheduling weight is reduced to a preset value, and the current global loop scheduling is completed. This can be implemented through S1025 to S1027:
[0052] S1025. According to the task ID of the tasks corresponding to itself, determine the next task to be scheduled for scheduling from the tasks other than the current task to be scheduled.
[0053] Here, the principle of S1025 is the same as that of S1021 to S1024 above.
[0054] S1026. When the scheduling of the next task to be scheduled is completed, according to the task ID of the tasks corresponding to itself, determine the next-next task to be scheduled for scheduling from the tasks corresponding to itself until, when traversing all the tasks corresponding to itself, its own scheduling weight is reduced by a preset weight.
[0055] Here, after the first processor or the second processor completes the scheduling of a task to be scheduled, it can continue to select a task to be scheduled from the tasks corresponding to itself until all the tasks corresponding to itself are traversed once, and then its own scheduling weight is reduced by a preset weight.
[0056] S1027. Based on the reduced scheduling weight, traverse and schedule the tasks corresponding to itself again until its own scheduling weight is decremented to 0, and the current global loop scheduling is completed.
[0057] Here, after the first processor or the second processor reduces its own scheduling weight by a preset weight, it can, according to the obtained new scheduling weight, adopt the principles of S1021 to S1026 above to traverse the tasks corresponding to itself again, and continue to reduce its own scheduling weight by a preset weight after traversing. Such iterative loop is performed until its own scheduling weight is decremented to 0, and a global loop scheduling is completed.
[0058] S103. Based on the current running situation, update the initial weights and initial statuses of at least one task corresponding to itself.
[0059] In an embodiment of the present invention, each time a global loop scheduling is performed, the first processor or the second processor can update the initial weights and initial states of at least one task corresponding to itself based on the current running situation of the SSD software system.
[0060] Exemplarily, when the current data write volume of the SSD software system is empty, update the initial state of the task for command execution in the tasks corresponding to itself to the active state, update the initial state of the garbage collection task in the tasks corresponding to itself to the paused state, increase the weight of the task for command execution, and reduce the weight of the garbage collection task. That is to say, when the SSD software system is an empty disk, the priority of the task for processing host commands is the highest. Therefore, the weight corresponding to the task for processing host commands should also be the largest. At this time, the task for processing host commands can be in the active state, and the weight of the task for processing host commands can be increased.
[0061] Exemplarily, when the current data write volume of the SSD software system reaches the preset data volume, update the initial state of the garbage collection task to the active state and increase the weight of the garbage collection task. That is to say, during the operation of the SSD software system, when the written data volume reaches a certain amount, it is necessary to trigger the garbage collection task and perform garbage collection a certain number of times. Therefore, the initial state of the garbage collection task can be in the active state, and the weight of the garbage collection task can be increased.
[0062] Through such adjustment, it helps to dynamically adjust the execution order of some functions of the SSD software according to the application scenario, so that the performance of the SSD can be relatively stable.
[0063] In some embodiments, the preset data volume at least includes: a first preset sub-volume and a second preset sub-volume, and the first preset sub-volume is less than the second preset sub-volume. Based on this, the first processor or the second processor can update the initial state of the garbage collection task to the active state and increase the weight of the garbage collection task to the first preset recovery weight when the current data write volume of the SSD software system reaches the first preset sub-volume; and when the current data write volume of the SSD software system reaches the second preset sub-volume, keep the state of the garbage collection task as the active state and increase the weight of the garbage collection task to the second preset recovery weight; where the first preset recovery weight is less than the second preset recovery weight, and the first preset execution weight is greater than the second preset execution weight. In this way, as the written data volume in the SSD software system increases (the remaining space becomes smaller), the weight of the garbage collection task can be gradually increased to release a certain amount of space.
[0064] S104. Based on the updated weights and statuses of at least one task, the initial weights and initial statuses of the tasks that have not been updated in the tasks corresponding to itself, and its own scheduling weight, continue to perform the next global loop scheduling on the tasks corresponding to itself until the command is completed.
[0065] In the embodiments of the present invention, after the first processor or the second processor updates the initial weights and initial statuses of at least one task corresponding to itself based on the current running situation, based on the updated weights and statuses of at least one task, the initial weights and initial statuses of the tasks that have not been updated in the tasks corresponding to itself, and its own scheduling weight, continue to perform the next global loop scheduling on the tasks corresponding to itself using the same principle as S102 above, and continue to update the weights and statuses of the tasks corresponding to itself using the same principle as S103 above. In this way, loop iteration is performed until the received command is completed.
[0066] Here, when no task is executed in a certain global loop scheduling or consecutive global loop schedulings, it can be considered that the currently received command is completed, and the execution result of the command can be output.
[0067] In some embodiments, the process of performing the next global loop scheduling can be implemented through S1041 to S1044:
[0068] S1041. When performing the next global loop scheduling, determine the currently schedulable task according to the tasks corresponding to itself and the task IDs.
[0069] The principle of S1041 here is the same as the principle of S1021 above.
[0070] S1042. When the currently schedulable task has updated weights and statuses, determine whether to execute the currently schedulable task according to the relationship between the status of the currently schedulable task, its own scheduling weight, and the updated weight of the currently schedulable task. When not executing, update the status of the currently schedulable task based on the execution result of the previous executed schedulable task of the currently schedulable task, and complete the scheduling of the currently schedulable task.
[0071] Here, when the initial status and initial weight of the currently schedulable task are updated, that is, when it has updated weights and statuses, the scheduling of the currently schedulable task can be completed according to the same principles as S1022 to S1024 above.
[0072] S1043. When the current task to be scheduled has an initial weight and an initial state, determine whether to execute the current task to be scheduled according to the size relationship between the initial state of the current task to be scheduled, its own scheduling weight, and the initial weight of the current task to be scheduled. When not executing, update the initial state of the current task to be scheduled based on the execution result of the previous executed task to be scheduled of the current task to be scheduled, and complete the scheduling of the current task to be scheduled.
[0073] Here, when the initial state and initial weight of the current task to be scheduled are not updated, the scheduling of the current task to be scheduled can be completed according to the same principle as S1022 - S1024 above.
[0074] S1044. When the scheduling of the current task to be scheduled is completed, determine the next task to be scheduled for scheduling. Until after traversing all the tasks corresponding to itself, reduce its own scheduling weight. Based on the reduced scheduling weight, re - traverse and schedule the tasks corresponding to itself until the scheduling weight is reduced to a preset value, and complete the next global loop scheduling.
[0075] Here, the principle of S1044 is the same as that of S1026 - S1027 above.
[0076] In the embodiment of the present invention, during the command execution process, by determining whether to execute each task according to the status and weight of the task, as well as the scheduling weight, functions of some tasks that do not need to be executed will not be called, effectively avoiding calling too many functions in the main loop of the SSD software system; and, by executing commands in this cyclic scheduling manner, the effect of implementing the function of the SSD software system in a way similar to time - slice rotation is achieved, thus reasonably avoiding the situation where each functional module blocks each other, improving the running efficiency of the SSD software system; and, by updating the weights and states of some tasks (functional modules) according to the running situation of the SSD software system, and continuing cyclic scheduling according to the updated weights and states, the execution times of the corresponding functional modules within a certain period can be dynamically adjusted according to the actual running situation, thereby reducing the situation where each functional module is evenly called within a certain period, and improving the stability of the overall performance of the SSD software system.
[0077] The following is Figure 2 for further illustration of the task scheduling method of the present invention. Figure 2 It is an operation architecture diagram of an exemplary SSD software system provided by the present invention. As The following is Figure 2As shown, the SSD software system may include a first processor Core0, a second processor Core1, functional modules A to E, and functional modules a to e. Moreover, Core0 corresponds to functional modules A to E, and Core1 corresponds to functional modules a to e. Both Core0 and Core1 perform scheduling of the corresponding functional modules through a scheduler Task scheduler. The task ID corresponding to functional module A is TASK1, the task ID corresponding to functional module B is TASK2, the task IDs corresponding to functional modules C and D are both TASK3, and the task IDs corresponding to functional module E are TASK4 and TASK5. Additionally, each functional module has a corresponding state State and weight Weight. The task IDs, corresponding states, and weights of all functional modules corresponding to Core0 are stored in the table corresponding to Core0 in sequence according to the ascending order of the task IDs. The task ID corresponding to functional module a is TASK11, the task ID corresponding to functional module b is TASK22, the task ID corresponding to functional module c is TASK33, the task ID corresponding to functional module d is TASK44, and the task ID corresponding to functional module e is TASK55. Also, each functional module has a corresponding state State and weight Weight. The task IDs, corresponding states, and weights of all functional modules corresponding to Core1 are also stored in the table corresponding to Core1 in sequence according to the ascending order of the task IDs.
[0078] When Core0 receives a user's command, during each global loop scheduling, it can select a functional module corresponding to a task ID in sequence according to the order of the task IDs stored in the corresponding table through its own scheduler. After each global loop scheduling is completed, it determines whether to update the state and weight of the task ID in the corresponding table according to the current running situation of the SSD software system. Then, based on the updated state and weight, it continues the next global loop scheduling. Also, when Core0 executes the received user's command and needs Core1 to execute some functions, it can send a command (REQUEST) to Core1. When Core1 receives the command from Core0, during each global loop scheduling, it can also select a functional module corresponding to a task ID in sequence according to the order of the task IDs stored in the corresponding table through its own scheduler. After each global loop scheduling is completed, it determines whether to update the state and weight of the task ID in the corresponding table according to the current running situation of the SSD software system. Then, based on the updated state and weight, it continues the next global loop scheduling until the command is completed, and then it sends a result feedback (RESUME) to Core0. Core0 continues to execute the command according to the result feedback from Core1 until the execution result is obtained, and then it outputs the result to the user.
[0079] The present invention adopts a cyclic arbitration design method. According to the running situation of the software, the weight of tasks that do not need to be frequently executed is reduced, so that the execution frequency of this task will be reduced in the task scheduling mechanism, and thus it is possible to avoid calling too many functions in the main loop. At the same time, for different application scenarios, the execution frequencies of different tasks are adjusted, ultimately improving the real-time performance, efficiency and stability of the SSD software system. In addition, through the above-mentioned task scheduling mechanism, the present invention provides a unified function interface and arbitration mechanism, which also facilitates the software to control each function.
[0080] The above content is a further detailed description of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is only limited to these descriptions. For those of ordinary skill in the technical field to which the present invention pertains, without departing from the concept of the present invention, several simple deductions or substitutions can still be made, and all should be regarded as belonging to the protection scope of the present invention.
Claims
1. A task scheduling mechanism method for weighted round-robin arbitration in dual-core mode, characterized in that: include: Taking each functional module corresponding to the first processor and the second processor in the SSD software system as a task, assigning a task ID, an initial weight, and an initial state, and determining the scheduling weights of the first processor and the second processor respectively; The initial state is used to indicate whether the task is executable; When the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, it determines the current task to be scheduled according to its own corresponding task and task ID, and determines whether to execute the current task to be scheduled according to the initial state of the current task to be scheduled, the relationship between its own scheduling weight and the initial weight of the current task to be scheduled, and when not executed, updates the initial state of the current task to be scheduled based on the execution result of the last executed task to be scheduled, and completes the scheduling of the current task to be scheduled; thereafter, determines the next task to be scheduled for scheduling, and reduces its own scheduling weight when traversing its own corresponding tasks, and re-traverses and schedules its own corresponding tasks based on the reduced scheduling weight until its own scheduling weight is reduced to a preset value, completing the current global loop scheduling; Based on the current running status, update the initial weight and initial state of at least one task corresponding to itself; Based on the updated weight and status of the at least one task, the initial weight and initial status of the tasks that have not been updated in its corresponding tasks, and its own scheduling weight, continue to perform the next global cycle scheduling on its corresponding tasks until the command is completed.
2. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: When the first processor or the second processor receives a command and performs the current global loop scheduling according to the command, the first processor or the second processor determines the current task to be scheduled according to its own corresponding task and task ID, and determines whether to execute the current task to be scheduled according to the initial state of the current task to be scheduled and the relationship between its own scheduling weight and the initial weight of the current task to be scheduled. If the task is not executed, the initial state of the current task to be scheduled is updated based on the execution result of the last executed task to be scheduled, thereby completing the scheduling of the current task to be scheduled, including: When the first processor or the second processor receives a command and performs current sub-global cycle scheduling according to the command, the first processor or the second processor determines the current task to be scheduled from the tasks corresponding to the first processor according to the task ID of the task corresponding to the first processor; When the initial state of the current task to be scheduled is an active state or an idle state, and the scheduling weight of the first processor or the second processor itself is less than or equal to the initial weight of the current task to be scheduled, executing the current task to be scheduled by calling the callback function of the current task to be scheduled; When its own scheduling weight is greater than the initial weight of the current task to be scheduled, the initial state of the current task to be scheduled is updated according to the execution result of the previous task to be scheduled before the current task to be scheduled; After calling the callback function of the current task to be scheduled or updating the status of the current task to be scheduled, it is determined that the scheduling of the current task to be scheduled is completed.
3. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 2, characterized in that: The initial state includes an idle state, an active state and a pause state; The updating of the initial state of the current task to be scheduled according to the execution result of the last task to be scheduled of the current task to be scheduled includes: When the execution result of the last executed task to be scheduled of the current task to be scheduled is empty, the initial state of the current task to be scheduled is not updated; When the execution result of the last executed task to be scheduled of the current task to be scheduled is not empty, and the execution result is associated with the current task to be scheduled, updating the initial state of the current task to be scheduled to the active state or the idle state; When the execution result of the last executed task to be scheduled of the current task to be scheduled is not empty, and the execution result is not associated with the current task to be scheduled, the initial state of the current task to be scheduled is updated to the pause state.
4. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The updating of the initial weight and initial state of at least one task corresponding to the task itself based on the current running situation includes: When the current data write amount of the SSD software system is empty, the initial state of the task for executing commands in the corresponding task is updated to the activated state, the initial state of the garbage collection task in the corresponding task is updated to the suspended state, the weight of the task for executing commands is increased, and the weight of the garbage collection task is reduced; or When the current data writing amount of the SSD software system reaches the preset data amount, the initial state of the garbage collection task is updated to the activated state, and the weight of the garbage collection task is increased.
5. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 4, characterized in that: The preset data amount includes at least: a first preset sub-amount and a second preset sub-amount, the first preset sub-amount being smaller than the second preset sub-amount; when the current data write amount of the SSD software system reaches the preset data amount, updating the initial state of the garbage collection task to an activated state and increasing the weight of the garbage collection task, including: When the current data write amount of the SSD software system reaches the first preset sub-amount, updating the initial state of the garbage collection task to an activated state, and increasing the weight of the garbage collection task to a first preset recycling weight; When the current data write amount of the SSD software system reaches the second preset sub-amount, maintaining the state of the garbage collection task in an activated state, and increasing the weight of the garbage collection task to a second preset recycling weight; The first preset recycling weight is smaller than the second preset recycling weight.
6. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The process of determining the next task to be scheduled and scheduling it until the corresponding tasks are traversed, reducing its own scheduling weight, and re-traversing and scheduling the corresponding tasks based on the reduced scheduling weight until the scheduling weight is reduced to a preset value, thereby completing the current global cycle scheduling, including: According to the task ID of the task corresponding to itself, determine the next task to be scheduled from the tasks other than the current task to be scheduled and schedule it; When the scheduling of the next task to be scheduled is completed, the next task to be scheduled is determined from the tasks corresponding to itself according to the task ID of the task corresponding to itself, and the scheduling weight of itself is reduced by the preset weight when the tasks corresponding to itself are traversed. Based on the reduced scheduling weight, the corresponding tasks are re-traversed and re-scheduled until the scheduling weight is reduced to 0, completing the current global cycle scheduling.
7. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The method of continuing to perform the next global cycle scheduling on the tasks corresponding to the task itself based on the updated weight and state of the at least one task, the initial weight and initial state of the tasks corresponding to the task itself that have not been updated, and the scheduling weight of the task itself includes: When performing the next global cycle scheduling, the current task to be scheduled is determined according to the task and task ID corresponding to the task itself; When the current task to be scheduled has an updated weight and state, determining whether to execute the current task to be scheduled according to the updated state of the current task to be scheduled and the relationship between the current task to be scheduled's own scheduling weight and the updated weight of the current task to be scheduled; if not executed, updating the state of the current task to be scheduled based on the execution result of the last task to be scheduled executed before the current task to be scheduled, and completing the scheduling of the current task to be scheduled; When the current task to be scheduled has an initial weight and an initial state, determining whether to execute the current task to be scheduled according to the initial state of the current task to be scheduled, the relationship between the current task to be scheduled and its own scheduling weight and the initial weight of the current task to be scheduled, and if not executed, updating the initial state of the current task to be scheduled based on the execution result of the last task to be scheduled executed before the current task to be scheduled, and completing the scheduling of the current task to be scheduled; When the scheduling of the current task to be scheduled is completed, the next task to be scheduled is determined for scheduling, until the tasks corresponding to itself are traversed, the scheduling weight of itself is reduced, and based on the reduced scheduling weight, the tasks corresponding to itself are re-traversed and scheduled, until the scheduling weight of itself is reduced to the preset value, the next global cycle scheduling is completed.
8. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The method of treating each functional module corresponding to the first processor and the second processor in the SSD software system as a task, assigning a task ID, an initial weight, and an initial state, and respectively determining the scheduling weights of the first processor and the second processor includes: Taking each functional module corresponding to the first processor and the second processor in the SSD software system as a task, assigning a task ID to each task, wherein at least one task corresponds to the same task ID; According to the priority of the function module corresponding to each task, set the initial weight and initial state for the task; Setting a scheduling weight for the first processor according to the number of tasks corresponding to the first processor; A scheduling weight is set for the second processor according to the number of tasks corresponding to the second processor.
9. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The command received by the second processor is a preset command sent by the first processor to the second processor through shared memory during global loop scheduling; after completing the preset command, the second processor feeds back the completion result to the first processor through shared memory.
10. The task scheduling mechanism method for weighted round-robin arbitration in dual-core mode according to claim 1, characterized in that: The tasks corresponding to the first processor include functional modules in the front end and flash conversion layer of the SSD software system; the tasks corresponding to the second processor include functional modules in the back end of the SSD software system.
Citation Information
Patent Citations
Static task scheduling method for multi-core system based on task movement
CN109117258A
Arbitration management method of task queue, storage medium and solid state disk
CN114265798A