A task scheduling method, system, and computer-readable storage medium
By scheduling target tasks to run on the first core based on priority and time threshold conditions in a multi-core task processing system, the performance waste caused by data invalidation in the cache is solved, and the task scheduling efficiency and data acquisition convenience are improved.
Patent Information
- Application Number
- CN202210775071.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-01
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-07-01
AI Technical Summary
In existing multi-core task processing systems, when a target task is running on the first core, it may be scheduled to the second core due to resource relinquishment or preemption by a higher-priority task. This causes the running data in the cache to become invalid, reducing task scheduling efficiency and wasting performance.
If the target task's task status meets the scheduling conditions, it is added to the task ready queue. When the kernel release time and queue addition time meet the time threshold conditions, the priorities are compared. If the first priority is higher than the second priority, the target task is scheduled to run on the first kernel to ensure that there is still valid data in the cache for easy retrieval.
By prioritizing the execution of target tasks on the first kernel, data acquisition is made more convenient, the execution efficiency of system task scheduling is improved, and the time spent repeatedly retrieving data from main memory is avoided.
Smart Images

Figure CN115168000B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of multi-core processor scheduling technology, and in particular to a task scheduling method, system and computer-readable storage medium. Background Technology
[0002] Task scheduling refers to assigning tasks to resources for execution. Typically, there are many tasks to be executed, but limited resources for execution. Therefore, it is necessary to rationally allocate multiple tasks to limited resources to optimize task execution efficiency.
[0003] Currently, multi-core task processing systems typically schedule tasks using priority and time-slice round-robin. When a target task is running, its code and data are read from main memory and stored in the cache (cache). The cache is located between the CPU and main memory. Existing technology loads a portion of the instruction code or data near the instruction code unit executing the target task from main memory into the cache for the CPU to use for a period of time. Due to the locality of memory access, with a given cache capacity, we can ensure that most of the CPU's instruction fetching and data read / write operations are performed by accessing the cache, rather than main memory.
[0004] However, when the target task runs on the first kernel, it may be scheduled to the second kernel because it is waiting for resources to be actively given up or is preempted by other high-priority tasks. This will cause the target task's running data in the corresponding cache on the first kernel to become invalid. The target task's running data needs to be retrieved from main memory and stored in the corresponding cache on the second kernel. This reading and storage process will reduce the execution efficiency of task scheduling and cause performance waste.
[0005] Given the shortcomings of existing technologies, there is an urgent need to research a task scheduling method, system, and computer-readable storage medium to solve the above problems. Summary of the Invention
[0006] To address the aforementioned technical problems, this application provides a task scheduling method, system, and computer-readable storage medium. When the target task's valid data is still stored in the cache corresponding to the first kernel, this application prioritizes the execution of the target task on the first kernel, ensuring the ease of obtaining the target task's running data and improving the execution efficiency of the system's task scheduling.
[0007] This application discloses a task scheduling method applied to a task processing system with multiple kernels, wherein the task processing system includes at least multiple kernels, and the method includes:
[0008] If the task status of the target task meets the task scheduling conditions, the target task is added to the task ready queue. The target task is a task that was historically scheduled to run on the first kernel among the multiple kernels and released the first kernel after the running process was terminated.
[0009] Obtain the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue.
[0010] If the kernel release time and the queue addition time meet the time threshold condition, obtain the second priority of the currently executing task on the first kernel;
[0011] If the first priority is higher than the second priority, the target task will be scheduled to run on the first kernel.
[0012] Furthermore, the method also includes:
[0013] If the first priority is lower than the second priority, obtain the priority of the currently executing task on the other kernels besides the first kernel among the plurality of kernels;
[0014] The priority of the currently executing task on the other kernels is compared with the first priority to obtain the priority comparison result;
[0015] A second kernel is selected from the other kernels based on the priority comparison result, and the priority of the task currently being executed on the second kernel is lower than that of the first kernel;
[0016] The target task is scheduled to run on the second kernel.
[0017] Furthermore, the method also includes:
[0018] If the priority comparison result is that the first priority is lower than the priority of the currently executing task on the other kernels, the target task is added to the task waiting queue.
[0019] Furthermore, before obtaining the second priority of the currently executing task on the first kernel if the kernel release time and the queue addition time meet a time threshold condition, the method further includes:
[0020] Determine the first time difference between the kernel release time and the queue addition time;
[0021] If the first time difference is within a preset threshold range, it is determined that the kernel release time and the queue addition time meet the time threshold condition.
[0022] Furthermore, the method also includes:
[0023] If the kernel release time and the queue addition time do not meet the time threshold condition, the target task is added to the task waiting queue.
[0024] Furthermore, the process of scheduling the target task to run on the first kernel includes:
[0025] In the case of multiple target tasks competing for the first kernel, obtain the kernel release time of each of the multiple target tasks for the first kernel;
[0026] The execution order of the multiple target tasks is determined based on the kernel release time.
[0027] Based on the task execution order, the multiple target tasks are sequentially scheduled to run on the first kernel.
[0028] Furthermore, prior to the step of ensuring the task status of the target task meets the task scheduling conditions, the method further includes:
[0029] Obtain the current running resource information and target running resource information of the target task; wherein, the target running resource information represents the resources required to execute the target task;
[0030] If the current resource information matches the target running resource information, it is determined that the task status of the target task meets the task scheduling conditions.
[0031] Furthermore, before the step of obtaining the second priority of the currently executing task on the first kernel if the kernel release time and the queue addition time meet a time threshold condition, the method further includes:
[0032] If there is no currently executing task on the first kernel, the target task is scheduled to run on the first kernel.
[0033] This application also protects a task scheduling system for implementing the task scheduling method described above, the system comprising:
[0034] The first execution module is used to add the target task to the task ready queue when the task status of the target task meets the task scheduling conditions. The target task is a task that was historically scheduled to run on the first kernel among the multiple kernels and then released from the first kernel.
[0035] The acquisition module is used to acquire the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue.
[0036] The second execution module is used to obtain the second priority of the currently executing task on the first kernel if the kernel release time and the queue addition time meet a time threshold condition.
[0037] The third execution module is used to schedule the target task to run on the first kernel if the first priority is higher than the second priority.
[0038] This application also protects a computer-readable storage medium storing at least one instruction or at least one program, which is loaded and executed by a processor to implement the task scheduling method described above.
[0039] Implementing the embodiments of this application has the following beneficial effects:
[0040] This application adds the target task to the task ready queue when the task status of the target task meets the task scheduling conditions. When the kernel release time and the queue addition time meet the time threshold conditions, it compares the first priority and the second priority. If the first priority is higher than the second priority, the target task is scheduled to run on the first kernel. This takes into account both priority and timeliness on the first kernel, and makes the target task execute on the first kernel first. This ensures the convenience of obtaining the target task's running data and improves the execution efficiency of the system task scheduling. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of this application. Those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0042] Figure 1 This is a flowchart of the task scheduling method described in this embodiment;
[0043] Figure 2 This is a structural diagram of the task scheduling system described in this embodiment.
[0044] The corresponding reference numerals in the figure are as follows:
[0045] 1-First execution module; 2-Acquisition module; 3-Second execution module; 4-Third execution module. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0048] The existing technology has the following drawbacks: In the existing technology, when the target task runs on the first core, the target task's running data is read from the main memory and stored in the cache corresponding to the first core. When the target task actively yields the current first core due to waiting for resources or is preempted by other high-priority tasks, and the resources are available or it has the highest priority among the runnable tasks, the target task may be scheduled to the second core. This will cause the target task's running data in the cache corresponding to the first core to become invalid. The target task's running data needs to be repeatedly retrieved from the main memory and stored in the cache corresponding to the second core, which will reduce the execution efficiency of task scheduling and cause performance waste.
[0049] To address the shortcomings of existing technologies, this application adds the target task to the task ready queue when the target task's task status meets the task scheduling conditions. Furthermore, when the kernel release time of the target task on the first kernel meets a time threshold condition, the cache corresponding to that first kernel is highly likely to still contain valid information about the target task. In this case, the target task is scheduled to run on the first kernel. This approach considers both the target task's priority and the timeliness of the target task data in the cache on the first kernel, ensuring that the target task is executed preferentially on the first kernel. This guarantees the ease of obtaining the target task's execution data and improves the system's task scheduling efficiency.
[0050] Example 1
[0051] See appendix Figures 1-2 This embodiment provides a task scheduling method applied to a task processing system with multiple kernels. The task processing system includes at least multiple kernels. The method includes:
[0052] S101: If the task status of the target task meets the task scheduling conditions, add the target task to the task ready queue. The target task is the task that was historically scheduled to run on the first kernel among multiple kernels and released the first kernel after the running process was terminated.
[0053] In an optional example, the target task can be any task to be executed in the task processing system. This target task can be scheduled to be executed in any one of the multiple kernels in the task processing system. The task processing system schedules tasks based on task priority and time slice round-robin. During the task scheduling process, the task processing system maintains a task ready queue and a task waiting queue. A task entering the task waiting queue indicates that the task in the execution state is blocked for some reason, such as lack of resources, and thus enters the corresponding task waiting queue. There are two situations in which a task enters the task ready queue: one is that the blocked task is awakened, thus leaving the corresponding task waiting queue and being inserted into the task ready queue; the other is that the execution state task is interrupted or the time slice expires, and it enters the ready state and is inserted into the task ready queue.
[0054] In an optional example, when a target task (such as task A) is scheduled to run on the first kernel among multiple kernels, the kernel identifier of the target task's last run is recorded in the Task Control Block (TCB). When the first kernel executes the target task, the required execution data for the target task is retrieved from main memory and stored in the cache cache corresponding to the first kernel. Each of the multiple kernels has its own corresponding cache cache.
[0055] When task A needs to wait for certain resources, it actively releases the first kernel to other tasks to run, or a higher-priority task B needs to run, and task B preempts task A. The kernel release time of the last release is recorded in the Task Control Block (TCB), and task A moves to the corresponding waiting queue. The target task's running data is still retained in the cache corresponding to the first kernel for a certain preset time. That is, the target task data in the cache corresponding to the first kernel has a time limit. Within the time limit, the cache corresponding to the first kernel will continue to retain the target task's running data. Beyond this time limit, the cache corresponding to the first kernel will clear the target task's running data to make room for other tasks waiting to be executed.
[0056] When the resources required by task A are met, the task is moved from the corresponding task waiting queue to the ready queue. That is, when the task status of the target task meets the task scheduling conditions, the target task is added to the task ready queue, and the queue addition time of the target task to the task ready queue is recorded in the task control block (TCB).
[0057] S102: Obtain the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue.
[0058] In an optional example, the Task Control Block (TCB) records the kernel identifier of the target task's last execution, the kernel release time of the last kernel release, and the queue addition time of the target task to the task ready queue. Based on the kernel release time of the last kernel release and the queue addition time of the target task to the task ready queue, the time difference between the target task being scheduled for execution again and the release of the last running first kernel can be calculated. If this time difference is within the effective range, the target task's execution data may continue to be stored in the cache corresponding to the first kernel. That is, the cache corresponding to the first kernel is very likely to contain valid information about task A, such as code and data.
[0059] In an optional example, the task processing system schedules task execution based on task priority, with higher-priority tasks being scheduled first compared to lower-priority tasks. The first priority refers to the priority defined for the target task when it is scheduled. Obtaining the first priority of the target task allows for subsequent judgment of its priority ranking among all tasks in the ready queue. When the target task's first priority is the highest, it will be scheduled.
[0060] S103: If the kernel release time and queue addition time meet the time threshold condition, obtain the second priority of the currently executing task on the first kernel;
[0061] In an optional example, based on the kernel release time of the last kernel release and the queue addition time of the target task to the task ready queue, the time between the release of the last running first kernel and the rescheduling of the target task can be calculated. In one embodiment, the time difference obtained by subtracting the kernel release time from the queue addition time is taken as the time difference since the release of the first kernel. If this time difference meets a time threshold condition (e.g., less than a certain threshold indicates that the target task data is within the validity period of the cache), the running data of the target task may continue to be stored in the cache corresponding to the first kernel. That is, the cache corresponding to the first kernel is very likely to contain valid information of task A, such as code and data. This time threshold can be set according to the actual cache memory size corresponding to the first kernel and the time for retaining data that is not executing tasks.
[0062] S104: If the first priority is higher than the second priority, the target task will be scheduled to run on the first kernel.
[0063] In an optional example, compare whether the second priority of the task running on the first core is lower than the first priority of task A. If it is lower, task A preempts the first core, saves the task context, switches tasks, and lets task A run.
[0064] It should be noted that in this embodiment, when the task status of the target task meets the task scheduling conditions, the target task is added to the task ready queue. When the kernel release time and queue addition time meet the time threshold conditions, it indicates that the cache corresponding to the first kernel still contains the running data of the target task and has not been cleared. The first priority of the target task is compared with the second priority of the currently executing task on the first kernel. If the first priority is higher than the second priority, the target task is scheduled to run on the first kernel. This takes into account both the priority and the timeliness of the target task data in the cache on the first kernel, and prioritizes the execution of the target task on the first kernel. This ensures the convenience of obtaining the target task running data and improves the execution efficiency of the system task scheduling.
[0065] Specifically, step S101 includes: determining that the target task can be scheduled if the task status of the target task meets the task scheduling conditions; adding the target task to the task ready queue, wherein the target task is the task that was historically scheduled to run on the first kernel among multiple kernels and released the first kernel after the running process was terminated; the task ready queue is the queue in the task processing system where the running resources are ready and about to be run; by determining whether the task status of the target task meets the task scheduling conditions, the target task is scheduled only when the task status meets the task scheduling conditions, which can avoid scheduling the target task when the task status does not meet the task scheduling conditions, which would increase the waiting time of other tasks, prolong the task scheduling time, and reduce the execution efficiency of task scheduling.
[0066] It should be noted that in the prior art, during the execution of the target task, the code and data of the target task are read from main memory and stored in the cache (high-speed buffer memory). Furthermore, in the prior art, a portion of the instruction code or data near the instruction code unit executing the target task is loaded from main memory into the cache. However, the cache will clear the cached data after a certain period. This embodiment avoids retrieving data from main memory and retrieves data as much as possible by accessing the cache of the first kernel. This avoids repeated retrieval from main memory, which prolongs the retrieval time and thus improves the execution efficiency of task scheduling to a certain extent.
[0067] Specifically, in step S103, if the kernel release time and queue addition time meet the time threshold condition, it is determined that the target task data exists in the cache corresponding to the first kernel; the second priority of the currently executing task on the first kernel is obtained; in order to determine whether the target task can run on the first kernel, if it can run on the first kernel, the target task data can be directly obtained from the cache, shortening the data acquisition time and improving the execution efficiency of task scheduling.
[0068] In some possible embodiments, the method further includes:
[0069] S105: If the first priority is lower than the second priority, obtain the priority of the currently executing task on the other kernels besides the first kernel among multiple kernels;
[0070] In an optional example, if the first priority of task A is lower than the second priority of the task running on the first core, it means that task A cannot preempt the first core, and it is necessary to search for other cores to preempt it.
[0071] S106: Compare the priority of the currently executing task on other kernels with the first priority to obtain the priority comparison result;
[0072] S107: Select a second kernel from other kernels based on the priority comparison results. The priority of the task currently executing on the second kernel is lower than the first priority.
[0073] S108: Schedule the target task to run on the second kernel.
[0074] Specifically, step S108 includes:
[0075] The system retrieves the currently executing task on the second kernel; stores the running data of the currently executing task on the second kernel and the kernel release time of the second kernel; and schedules the target task to run on the second kernel. This enables the currently executing task on the second kernel to retrieve running data from the cache (high-speed buffer memory) corresponding to the second kernel when the kernel release time and queue addition time meet the time threshold conditions, thus improving the convenience of retrieving running data.
[0076] Specifically, the priority comparison results include: the first priority being lower than the priority of the currently executing task on all other kernels except the first kernel; the first priority being higher than the priority of the currently executing task on one of the other kernels except the first kernel; and the first priority being equal to the priority of the currently executing task on one of the other kernels except the first kernel.
[0077] Furthermore, in step S107, the priority comparison result is that the first priority is higher than the priority of the currently executing task on one of the other kernels besides the first kernel. Step S107 includes: selecting a kernel with a priority lower than the first priority from the multiple kernels besides the first kernel based on the priority comparison result; if there is only one kernel with a priority lower than the first priority, the kernel with a priority lower than the first priority is determined as the second kernel; if there are multiple kernels with a priority lower than the first priority, the priorities of the currently executing tasks on the multiple kernels with a priority lower than the first priority are compared; the kernel with the lowest priority is selected as the second kernel. This allows for the rapid selection of the second kernel when there are multiple kernels with a priority lower than the first priority, based on the priority of the currently executing tasks on the multiple kernels with a priority lower than the first priority. The selection speed is fast, and the target task only preempts the currently executing task on the second kernel, thus avoiding affecting the currently executing tasks on other kernels, which improves the stability of the task processing system to a certain extent.
[0078] In some possible embodiments, the method further includes:
[0079] S109: If the priority comparison result is that the first priority is lower than the priority of the currently executing task on other kernels, add the target task to the task waiting queue.
[0080] Specifically, step S109 includes: if the priority comparison result is that the first priority is lower than the priority of the currently executing task on other kernels, the target task cannot preempt the currently executing task on other kernels; the target task is sorted in the task processing system based on the first priority, and the target task is added to the task waiting queue based on the priority sort; although the kernel release time and queue addition time meet the time threshold condition at this time, since the priority of the currently executing task on other kernels other than the first kernel is greater than the first priority, the target task cannot preempt the kernel, and the target task can only execute the task according to its priority.
[0081] It should be noted that: In order to avoid retrieving data from main memory again, this application retrieves data by accessing the cache as much as possible. Therefore, steps S1021-S1022 are performed to determine whether the target task data still exists in the cache. If the target task data exists, the data is retrieved from the cache, which avoids retrieving from main memory and prolonging the retrieval time, thereby improving the execution efficiency of task scheduling to a certain extent.
[0082] In some possible embodiments, if the kernel release time and queue addition time meet a time threshold condition, before obtaining the second priority of the currently executing task on the first kernel, the method further includes:
[0083] S1021: Determine the first time difference between the kernel release time and the queue addition time;
[0084] S1022: If the first time difference is within the preset threshold range, it is determined that the kernel release time and the queue addition time meet the time threshold condition; by comparing the first time difference between the two with the preset threshold range, it can be determined whether there is data corresponding to the target task in the Cache. If the first time difference is not within the preset threshold range, it is determined that there is no data corresponding to the target task in the Cache; if the first time difference is within the preset threshold range, it is determined that there is data corresponding to the target task in the Cache. At this time, the Cache can be accessed to obtain the target task, which can reduce the time to obtain the target task data and improve the execution efficiency of task scheduling.
[0085] In some possible embodiments, the method further includes:
[0086] S1010: If the kernel release time and queue addition time do not meet the time threshold conditions, add the target task to the task waiting queue.
[0087] It should be noted that in existing technologies, a portion of the instruction code or data near the instruction code unit executing the target task is loaded from main memory into the cache. However, the cache will clear the cached data after a certain period of time. This application, in order to avoid retrieving data from main memory again, tries to retrieve data through the cache as much as possible. However, when the kernel release time and queue addition time do not meet the time threshold conditions, the target task data no longer exists in the cache. In this case, the target task data cannot be retrieved from the cache, and the target task's execution data can only be retrieved from main memory. The target task is then executed according to the existing priority order. This approach fails to improve the execution efficiency of task scheduling and cannot guarantee the ease of retrieving the target task's execution data.
[0088] In some possible embodiments, scheduling the target task to run on the first kernel includes:
[0089] S1041: In the case of multiple target tasks competing for the first kernel, obtain the kernel release time of each target task for the first kernel;
[0090] S1042: Determine the task execution order of multiple target tasks based on the kernel release time;
[0091] S1043: Based on the task execution order, multiple target tasks are scheduled to run on the first kernel in sequence; by determining the execution order among multiple target tasks through the above steps, the preemption of multiple target tasks is avoided, which would prevent the normal task scheduling from being carried out, thereby ensuring the stability of system operation.
[0092] In some other possible embodiments, scheduling the target task to run on the first kernel includes:
[0093] When multiple target tasks compete for the first kernel, the kernel release time of each target task relative to the first kernel is obtained; based on the kernel release time, the execution order of the multiple target tasks is determined in descending order of time; based on the task execution order, the multiple target tasks are scheduled to run on the first kernel in sequence; this ensures that the target task with the longest kernel release time among the multiple target tasks is executed first, avoiding the clearing of data stored in the cache when other target tasks are executed first. This setting of the execution order of multiple target tasks improves the execution efficiency of system scheduling.
[0094] In other possible embodiments, scheduling the target task to run on the first kernel includes:
[0095] When multiple target tasks compete for the first kernel, obtain the kernel release time of each target task for the first kernel; determine the execution order of the multiple target tasks in ascending order of kernel release time; and schedule the multiple target tasks to run on the first kernel in sequence based on the execution order.
[0096] In some possible embodiments, prior to the step of determining if the task state of the target task satisfies the task scheduling conditions, the method further includes:
[0097] S1001: Obtain the current running resource information and target running resource information of the target task; wherein, the target running resource information represents the resources required to execute the target task;
[0098] S1002: If the current resource information matches the target running resource information, determine that the target task's task status meets the task scheduling conditions.
[0099] If the resource information of the target task does not match the target running resource information, execute other tasks in the first kernel;
[0100] Step S1002 is followed by:
[0101] If the resource information of the target task does not match the target running resource information, execute other tasks in the first kernel; reacquire the current resource information of the target task, and compare the reacquired current resource information with the target running resource information until the current resource information matches the target running resource information, and determine that the task status of the target task meets the task scheduling conditions.
[0102] Specifically, the task status of a target task is determined to meet the task scheduling conditions only when the current running resource information of the target task matches the target running resource information. If the current running resource information and the target running resource information do not match, the subsequent operation of the target task preempting other tasks cannot be performed. If the operation of the target task preempting other tasks is controlled when the two do not match, other tasks will have to wait for the target task's running resource information to match the target running resource information and for the target task to be completed before they can be executed. This obviously increases unnecessary waiting time and reduces the execution efficiency of the system task scheduling.
[0103] In some possible embodiments, before the step of obtaining the second priority of the currently executing task on the first kernel, if the kernel release time and queue addition time meet a time threshold condition, the method further includes:
[0104] S1030: If there is no currently executing task on the first kernel, schedule the target task to run on the first kernel.
[0105] Specifically, when there is no currently executing task on the first kernel, the target task can be directly scheduled to run on the first kernel. This eliminates unnecessary execution operations, allowing the target task to run quickly on the first kernel, saving time and improving the execution efficiency of system task scheduling.
[0106] In some possible embodiments, step S1030 is followed by:
[0107] If a task is currently running on the first kernel, determine whether the current running resources of the task match the running resource information of the second target. If the current running resources of the task do not match the running resource information of the target, determine that the task currently running on the first kernel needs to wait for resources. Prioritize scheduling the target task to run on the first kernel.
[0108] The task scheduling method includes:
[0109] S1001: Obtain the current running resource information and target running resource information of the target task; wherein, the target running resource information represents the resources required to execute the target task;
[0110] S1002: If the current resource information matches the target running resource information, determine that the task status of the target task meets the task scheduling conditions.
[0111] S101: If the task status of the target task meets the task scheduling conditions, add the target task to the task ready queue. The target task is the task that was historically scheduled to run on the first kernel among multiple kernels and released the first kernel after the running process was terminated.
[0112] S102: Obtain the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue.
[0113] S1030: If there is no currently executing task on the first kernel, schedule the target task to run on the first kernel;
[0114] S103: If the kernel release time and queue addition time meet the time threshold condition, obtain the second priority of the currently executing task on the first kernel;
[0115] S104: If the first priority is higher than the second priority, schedule the target task to run on the first kernel;
[0116] S105: If the first priority is lower than the second priority, obtain the priority of the currently executing task on the other kernels besides the first kernel among multiple kernels;
[0117] S106: Compare the priority of the currently executing task on other kernels with the first priority to obtain the priority comparison result;
[0118] S107: Select a second kernel from other kernels based on the priority comparison results. The priority of the task currently executing on the second kernel is lower than the first priority.
[0119] S108: Schedule the target task to run on the second kernel;
[0120] S109: If the priority comparison result is that the first priority is lower than the priority of the currently executing task on other kernels, add the target task to the task waiting queue;
[0121] S1010: If the kernel release time and queue addition time do not meet the time threshold conditions, add the target task to the task waiting queue.
[0122] Please see Figure 2 , Figure 2 This invention provides a task scheduling system for implementing the above-described task scheduling method. The system includes:
[0123] The first execution module 1 is used to add the target task to the task ready queue when the task status of the target task meets the task scheduling conditions. The target task is the task that was historically scheduled to run on the first kernel among multiple kernels and then released from the first kernel.
[0124] Module 2 is used to obtain the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue.
[0125] The second execution module 3 is used to obtain the second priority of the currently executing task on the first kernel if the kernel release time and queue addition time meet the time threshold condition.
[0126] The third execution module 4 is used to schedule the target task to run on the first kernel if the first priority is higher than the second priority.
[0127] It should be noted that: In a task scheduling system with the above task scheduling method, when the task status of the target task meets the task scheduling conditions, the target task is added to the task ready queue. When the kernel release time and the queue addition time meet the time threshold conditions, the first priority and the second priority are compared. If the first priority is higher than the second priority, the target task is scheduled to run on the first kernel. This takes into account both priority and timeliness on the first kernel, and prioritizes the execution of the target task on the first kernel. This ensures the convenience of obtaining the target task's running data and improves the execution efficiency of the system's task scheduling.
[0128] In some possible embodiments, the task scheduling system further includes: a confirmation module, a first comparison module, a fourth execution module, a second comparison module, a fifth execution module, a sixth execution module, and a seventh execution module;
[0129] The confirmation module is used to determine the first time difference between the kernel release time and the queue addition time;
[0130] The first comparison module is used to determine whether the kernel release time and the queue addition time meet the time threshold condition if the first time difference is within the preset threshold range.
[0131] The fourth execution module is used to obtain the priority of the currently executing task on the other kernels (excluding the first kernel) among multiple kernels if the first priority is lower than the second priority;
[0132] The second comparison module is used to compare the priority of the currently executing task on other kernels with the first priority to obtain the priority comparison result;
[0133] The fifth execution module is used to select a second kernel from other kernels based on the priority comparison results. The priority of the currently executing task on the second kernel is lower than the first priority.
[0134] The sixth execution module is used to schedule the target task to run on the second kernel;
[0135] The seventh execution module is used to add the target task to the task waiting queue if the kernel release time and queue addition time do not meet the time threshold conditions.
[0136] This application also protects a computer-readable storage medium storing at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded and executed by a processor to implement the task scheduling method described above.
[0137] Computer program products may include storage media on which computer-readable program instructions are loaded to enable a processor to implement various aspects of the present invention.
[0138] Optionally, in this embodiment, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0139] According to one aspect of the present invention, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations described above.
[0140] Although this application has been described through preferred embodiments, it is not limited to the embodiments described herein, and various changes and modifications are included without departing from the scope of this application.
[0141] In this document, the directional terms such as front, back, top, and bottom are defined based on the location of the components in the accompanying drawings and their relative positions to each other, solely for the purpose of clarity and convenience in expressing the technical solution. It should be understood that the use of these directional terms should not limit the scope of protection claimed in this application.
[0142] Where there is no conflict, the above embodiments and features described herein can be combined with each other.
[0143] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A task scheduling method, applied to a task processing system with multiple kernels, characterized in that, The methods include: If the task status of the target task meets the task scheduling conditions, the target task is added to the task ready queue. The target task is a task that was historically scheduled to run on the first kernel among the multiple kernels and released the first kernel after the running process was terminated. Obtain the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue. The time difference obtained by subtracting the kernel release time from the queue addition time is taken as the time difference since the first kernel was released. If the time difference is less than the time threshold, the second priority of the currently executing task on the first kernel is obtained. If the first priority is higher than the second priority, the target task will be scheduled to run on the first kernel.
2. The task scheduling method according to claim 1, characterized in that, The method further includes: If the first priority is lower than the second priority, obtain the priority of the currently executing task on the other kernels besides the first kernel among the plurality of kernels; The priority of the currently executing task on the other kernels is compared with the first priority to obtain the priority comparison result; A second kernel is selected from the other kernels based on the priority comparison result, and the priority of the task currently being executed on the second kernel is lower than that of the first kernel; The target task is scheduled to run on the second kernel.
3. The task scheduling method according to claim 2, characterized in that, The method further includes: If the priority comparison result is that the first priority is lower than the priority of the currently executing task on the other kernels, the target task is added to the task waiting queue.
4. The task scheduling method according to claim 1, characterized in that, The method further includes: If the kernel release time and the queue addition time do not meet the time threshold condition, the target task is added to the task waiting queue.
5. The task scheduling method according to claim 1, characterized in that, Before scheduling the target task to run on the first kernel, the following steps are included: In the case of multiple target tasks competing for the first kernel, obtain the kernel release time of each of the multiple target tasks for the first kernel; The execution order of the multiple target tasks is determined based on the kernel release time. Based on the task execution order, the multiple target tasks are sequentially scheduled to run on the first kernel.
6. The task scheduling method according to claim 1, characterized in that, Prior to the step where the task status of the target task meets the task scheduling conditions, the method further includes: Obtain the current running resource information and target running resource information of the target task; wherein, the target running resource information represents the resources required to execute the target task; If the current running resource information matches the target running resource information, it is determined that the task status of the target task meets the task scheduling conditions.
7. The task scheduling method according to claim 1, characterized in that, Before the step of subtracting the kernel release time from the queue addition time to obtain the time difference as the time difference since the release of the first kernel, and if the time difference is less than a time threshold, the method further includes: If there is no currently executing task on the first kernel, the target task is scheduled to run on the first kernel.
8. A task scheduling system, characterized in that, The system for implementing the task scheduling method as described in any one of claims 1-7 includes: The first execution module is used to add the target task to the task ready queue when the task status of the target task meets the task scheduling conditions. The target task is a task that was historically scheduled to run on the first kernel among the multiple kernels and then released from the first kernel. The acquisition module is used to acquire the scheduling record information and first priority of the target task. The scheduling record information includes the kernel release time of the target task for the first kernel and the queue addition time of the target task to the task ready queue. The second execution module is used to take the time difference obtained by subtracting the kernel release time from the queue addition time as the time difference since the release of the first kernel. If the time difference is less than the time threshold, the second priority of the currently executing task on the first kernel is obtained. The third execution module is used to schedule the target task to run on the first kernel if the first priority is higher than the second priority.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the task scheduling method as described in any one of claims 1-7.
Citation Information
Patent Citations
Interprocess Resource-Based Dynamic Scheduling System and Method
US20080288949A1
Task scheduling processing system and method for embedded real-time operating system
WO2021139560A1