A task processing method, processor and storage medium

By setting a task processing unit and monitoring the waiting time in the processor, the problem that tasks in the prior art may be postponed or starved to death for a long time is solved, and fair and efficient execution of tasks and full utilization of system resources are achieved.

CN118963972BActive Publication Date: 2025-02-07SHANGHAI XINLIJI SEMICON CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411441056.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-02-07
Estimated Expiration
2044-10-16

AI Technical Summary

Technical Problem

The existing task scheduling algorithm cannot guarantee that each task will be executed, especially when the system resources are tight, tasks with low-urgency levels may be postponed or starved to death for a long time, and the algorithm cannot flexibly adjust the execution order of tasks, which may lead to failure. Fair task execution.

Method used

Using a task processing method, by setting a task processing unit in the processor, including a first task area and a second task area, monitoring the waiting time of each task, and triggering the task evaluation mechanism when the waiting time exceeds the preset threshold. Adjust task allocation to ensure fair execution of tasks.

Benefits of technology

It realizes the rational and efficient allocation of tasks and the flexibility of execution order, avoids task hunger and unfair execution, and improves the utilization rate of system resources and task processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963972B_ABST
    Figure CN118963972B_ABST
Patent Text Reader

Abstract

The present invention discloses a task processing method, a processor and a storage medium, the method includes setting a task processing unit including a first task area and a second task area in a processor, obtaining the task to be processed and transmitting it to the first task area, recording the waiting time of the task, the timing start time of the waiting time is the time when the task enters the first task area; transmitting the task that meets the preset requirements in the first task area to the second task area; giving priority to executing the tasks in the second task area, and monitoring the waiting time corresponding to each task in the first task area; if there is a task corresponding to a waiting time that is not less than a preset first time threshold, triggering a task evaluation mechanism, including: adjusting the task allocation in the first task area and the second task area according to task information and / or system resource utilization, the task information includes the waiting time and the time required for execution. The present invention can take into account the urgency of the task, the waiting time and the resource utilization, and process the task more efficiently and reasonably.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a task processing method, a processor and a storage medium. Background Art

[0002] In the field of computer science, task scheduling in operating systems is one of the core issues. The main goal of task scheduling is to ensure that the system's resource utilization is maximized while ensuring the response time and execution efficiency of tasks. In a multi-tasking operating system, the urgency level of each task is usually variable, which leads to uncertainty in the execution order of tasks. In addition, task scheduling also involves multiple factors such as task execution time and resource utilization.

[0003] In existing technologies, the task scheduling algorithms based on urgency level are usually adopted, such as Round Robin, First-Come / First-Served (FCFS), Shortest Job First (SJF), etc. These algorithms set urgency levels for tasks and determine the scheduling order of tasks according to the urgency levels.

[0004] Although the existing task scheduling algorithms can meet the needs of task scheduling to a certain extent, there are still some problems. First, the existing algorithms cannot guarantee that each task will be executed. Especially when system resources are tight or there are many tasks with high urgency levels, tasks with low urgency levels may be postponed for a long time or even starved to death. Second, the existing algorithms cannot adjust the urgency level of tasks, which makes the execution order of tasks not flexible enough and unable to adapt to changes in the system. Finally, the existing algorithms may cause unfairness during the execution of tasks. For example, some tasks may have an unfair impact on other tasks due to uneven execution time.

[0005] The disclosure of the above background technology content is only used to assist in understanding the inventive concept and technical solution of the present invention. It does not necessarily belong to the prior art of the present application, nor does it necessarily provide technical guidance. In the absence of clear evidence that the above content has been disclosed before the filing date of the present application, the above background technology should not be used to evaluate the novelty and creativity of the present application. Summary of the invention

[0006] The purpose of the present invention is to provide a task processing method, a processor and a storage medium, which can take into account the urgency, waiting time and resource utilization of the task and process the task more efficiently and reasonably.

[0007] To achieve the above object, the technical solution adopted by the present invention is as follows:

[0008] A task processing method, the task processing method comprising the following steps:

[0009] A task processing unit is provided in the processor, wherein the task processing unit is provided with a first task area and a second task area;

[0010] Acquire the tasks to be processed and transmit them to the first task area, and record the waiting time corresponding to each task, where the starting time of the waiting time is the time when the task enters the first task area;

[0011] Transferring tasks that meet preset requirements in the first task area to the second task area;

[0012] Prioritize executing tasks in the second task area, and monitor the waiting time corresponding to each task in the first task area;

[0013] If the waiting time corresponding to the task is not less than a preset first time threshold, the task evaluation mechanism is triggered, including: obtaining task information and system resource utilization, and adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization, the task information including the waiting time and the execution time corresponding to the task.

[0014] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, triggering a task evaluation mechanism to adjust the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization rate includes:

[0015] If the system resource utilization is not greater than a preset utilization threshold, the task corresponding to the waiting time exceeding the preset first time threshold is stored in the second task area.

[0016] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, triggering a task evaluation mechanism to adjust the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization rate includes:

[0017] If the system resource utilization is greater than the preset utilization threshold, and there is a task in the second task area whose execution time is greater than or equal to the preset second time threshold, then the task corresponding to the task whose execution time is greater than or equal to the preset second time threshold is stored in the first task area.

[0018] Further, any one of the above-mentioned technical solutions or a combination of multiple technical solutions triggers the task evaluation mechanism, further comprising:

[0019] If there is a task in the first task area whose waiting time is not less than the preset third time threshold, immediately execute the task whose waiting time is not less than the preset third time threshold;

[0020] The third time threshold is greater than the first time threshold and is not greater than the starvation time corresponding to the task.

[0021] Further, based on any one of the technical solutions or a combination of multiple technical solutions mentioned above, the third time threshold has a corresponding relationship with the starvation time of the task.

[0022] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, the preset first time threshold is a fixed value; or,

[0023] The preset first time threshold is a preset value corresponding to the task.

[0024] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, if the number of tasks in the first task area exceeds a preset number threshold, the task evaluation mechanism is triggered; and / or,

[0025] If the remaining storage space of the first task area is less than a preset storage space threshold, the task evaluation mechanism is triggered.

[0026] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, the tasks that meet the preset requirements in the first task area are transferred to the second task area, including:

[0027] Obtaining task information corresponding to each task, wherein the task information includes a priority, and the priority includes an urgent priority and a normal priority;

[0028] The urgent task is stored in the second task area, and the priority of the urgent task is urgent.

[0029] Further, based on any one of the above-mentioned technical solutions or a combination of multiple technical solutions, the second mission area includes a first emergency area and a second emergency area;

[0030] The urgency in the priority level also includes the first urgency and the second urgency. The first urgency task is stored in the first urgency area, and the second urgency task is stored in the second urgency area. The priority of the first urgency task is the first urgency, and the priority of the second urgency task is the second urgency.

[0031] The tasks in the first emergency area are executed first. If there are no tasks in the first emergency area, the tasks in the second emergency area are executed first.

[0032] Further, any one of the above-mentioned technical solutions or a combination of multiple technical solutions does not affect the priority execution of tasks in the first emergency area when the task evaluation mechanism is triggered; or,

[0033] The tasks in the first emergency area will not be adjusted to the second emergency area or the first task area due to triggering the task evaluation mechanism.

[0034] Further, according to any one of the technical solutions or a combination of multiple technical solutions described above, the priority level corresponding to the task directly initiated by the user is configured as the first urgency.

[0035] Furthermore, based on any one of the technical solutions or a combination of multiple technical solutions mentioned above, the task information also includes the time required for execution, and the time required for execution is less than a preset fourth time threshold, then the priority of the task is configured as the second most urgent, and the fourth time threshold is less than the first time threshold.

[0036] According to another aspect of the present invention, the present invention provides a processor, comprising a task processing unit, a task scheduler and a task evaluation module, wherein the task processing unit comprises a first task area, a second task area and a timer configured therein;

[0037] The task processing unit acquires the task to be processed and transmits it to the first task area, the timer is configured to record the waiting time corresponding to the task, the timing start time of the waiting time is the time when the task enters the first task area, and the task processing unit is further configured to transmit the task in the first task area that meets the preset requirements to the second task area;

[0038] The task scheduler is electrically connected to the task processing unit, and the task scheduler is configured to schedule a task from the task processing unit to the execution end, and the task scheduler schedules tasks according to the rule including: preferentially scheduling tasks in the second task area;

[0039] The task evaluation module is electrically connected to the task processing unit. The task evaluation module is triggered to work when the waiting time corresponding to the task exceeds a preset first time threshold, including: obtaining task information and system resource utilization, and adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization, the task information including the waiting time and the execution time corresponding to the task.

[0040] According to another aspect of the present invention, the present invention provides a computer-readable storage medium for storing program instructions, wherein the program instructions are configured to call and execute the steps of the method described in any one of the above technical solutions or a combination of multiple technical solutions.

[0041] The beneficial effects brought by the technical solution provided by the present invention are as follows:

[0042] a. The system task processing method proposed in the present invention monitors the waiting time of tasks in the first task area with a lower priority. When the waiting time corresponding to the task is not less than the preset first time threshold, the task evaluation mechanism is triggered to avoid a task not being executed for a long time or even being starved to death, so as to more reasonably and efficiently allocate and plan the execution order of tasks;

[0043] b. After the task evaluation mechanism is triggered, the present invention compares the system resource utilization with a preset utilization threshold. If the system resource utilization is not greater than the preset utilization threshold, the task corresponding to the waiting time exceeding the preset first time threshold is stored in the second task area. By upgrading the tasks in the first task area, the system resources can be more fully utilized and the task processing efficiency can be improved.

[0044] c. After the task evaluation mechanism of the present invention is triggered, if the system resource utilization is greater than a preset utilization threshold, and there is a task in the second task area whose execution time is greater than or equal to a preset second time threshold, then the task is stored in the first task area. By downgrading the tasks in the second emergency area, the fairness of task scheduling can be maintained: ensuring that all tasks have a chance to be executed, rather than allowing some tasks to occupy resources for a long time due to their high priority; and preventing resource abuse: by monitoring the actual execution time and the estimated execution time of the task, it can prevent some tasks from occupying too many resources due to excessive execution time, thereby affecting the execution of other tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0046] Figure 1 A module schematic diagram of a task processing module provided for an exemplary embodiment of the present invention;

[0047] Figure 2 A schematic diagram of a module of a first task area provided for an exemplary embodiment of the present invention;

[0048] Figure 3 A schematic diagram of a task scheduling mechanism provided for an exemplary embodiment of the present invention;

[0049] Figure 4 A flowchart of a task scheduling method provided for an exemplary embodiment of the present invention;

[0050] Figure 5 A flowchart of a task evaluation mechanism provided for an exemplary embodiment of the present invention;

[0051] Figure 6 A block diagram of a processor is provided for an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0053] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0054] In one embodiment of the present invention, a task processing method is provided. Figures 1 to 5 , the method comprises the following steps:

[0055] A task processing unit is provided in the processor, wherein the task processing unit is provided with a first task area and a second task area;

[0056] Acquire the tasks to be processed and transmit them to the first task area, and record the waiting time corresponding to each task, where the starting time of the waiting time is the time when the task enters the first task area;

[0057] Transferring tasks that meet preset requirements in the first task area to the second task area;

[0058] Prioritize executing tasks in the second task area, and monitor the waiting time corresponding to each task in the first task area;

[0059] If the waiting time corresponding to the task is not less than the preset first time threshold, the task evaluation mechanism is triggered and the following steps are performed: task information and system resource utilization are obtained, and the task allocation in the first task area and the second task area is adjusted according to the task information and / or the system resource utilization, wherein the task information includes the waiting time and the execution time corresponding to the task.

[0060] The system task processing method proposed in the present invention detects the waiting time of tasks in the first task area with lower priority. When the waiting time corresponding to the task is not less than the preset first time threshold, the task evaluation mechanism is triggered to avoid a task not being executed for a long time or even being starved to death, so as to more reasonably allocate and plan the execution order of tasks.

[0061] There are multiple ways to transfer the tasks that meet the preset requirements in the first task area to the second task area, for example: obtaining the task information corresponding to each task, the task information includes a priority, and the priority includes urgent and ordinary; storing the urgent task in the second task area, and the priority of the urgent task is urgent. Alternatively, each task is pre-configured with a label, and the label has a corresponding relationship with the first task area and the second task area, and the task corresponding to the label in the second task area is transferred to the second task area.

[0062] In one embodiment of the present invention, Figure 1 As shown, the second task area further includes a first emergency area and a second emergency area. The first emergency area is configured to store the highest priority tasks (tasks in this area are strictly executed and will not be interrupted by other tasks), and the second emergency area is configured to store tasks that are not the highest priority and are higher than the normal level.

[0063] Correspondingly, the urgency in the priority also includes the first emergency and the second emergency. The first emergency task is stored in the first emergency area, and the second emergency task is stored in the second emergency area. The priority of the first emergency task is the first emergency, and the priority of the second emergency task is the second emergency.

[0064] In practical applications, preferably, the priority corresponding to the task directly initiated by the user is configured as the first urgent one, so as to respond to the user's operation in a timely manner. The task information also includes the time required for execution, and the time required for execution is less than a preset fourth time threshold, then the priority of the task is configured as the second urgent one, and the fourth time threshold is less than the first time threshold. The time required for execution has a corresponding relationship with the task, and is determined according to the previous time required for execution of the task.

[0065] In this embodiment, when the task evaluation mechanism is triggered, it does not affect the priority execution of tasks in the first emergency area. The tasks in the first emergency area will not be adjusted to the second emergency area or the first task area due to the triggering of the task evaluation mechanism.

[0066] The following is a specific application example to illustrate the process of allocating a task:

[0067] For example, there are three tasks X, Y, and Z in the system that arrive at the first task area.

[0068] Task X: is a data copy task initiated by a user, and its estimated execution time is 12 milliseconds. Although 12 milliseconds is greater than the preset fourth time threshold (assuming it is 10 milliseconds), Task X is directly initiated by the user, so it will be considered an urgent task and needs to be processed immediately. According to the preset requirements, Task X will enter the first emergency area from the first task area.

[0069] Task Y: This is a data backup task with an estimated execution time of 30 milliseconds. Although this task is also important, its execution time exceeds the preset fourth time threshold (assuming it is 10 milliseconds), so it will not be classified as a task in the emergency area, and Task Y remains in the first task area.

[0070] Task Z: This is a system monitoring task with an estimated execution time of 8 milliseconds. The execution time of this task is lower than the preset fourth time threshold (assuming it is 10 milliseconds), so according to the preset requirements, this Z task will enter the second emergency area from the first task area.

[0071] In this embodiment, see Figure 3 The task monitor monitors the tasks and task information in the first task area, the first emergency area and the second emergency area in real time or regularly. The scheduling method and execution order of the tasks in the task processing unit are as follows: Figure 4The process shown is carried out. During normal task execution, for example, when the task evaluation mechanism is not triggered, as shown in the figure, check whether there are tasks in the first emergency area. If there are tasks in the second emergency area, execute the tasks in the second emergency area. If not, execute the tasks in the first task area. The execution order of the tasks placed in the first emergency area / the second emergency area / the first task area is not the key point of the present invention. One or more combinations of Round Robin, First-Come / First-Served (FCFS) and Shortest Job First (SJF) can be adopted.

[0072] In one embodiment of the present invention, Figure 2 The first task area includes a storage space / storage device, a timer and a counter for storing tasks. Tasks newly arriving at the task processing unit enter the first task area by default and are arranged in order. And each task is assigned an initial waiting time counter when entering the first task area, and the initial value is zero. The system regularly checks the waiting time corresponding to each task in the first task area. If the counter value corresponding to a task exceeds the preset first time threshold, the task evaluation mechanism is triggered.

[0073] The counter is configured to count the number of tasks currently in the first task area. Specifically, when a new task is added to the first task area, the value of the counter is increased by one, and when a new task is removed from the first task area, the value of the counter is decreased by one. If the number of tasks in the first task area exceeds a preset number threshold, the task evaluation mechanism is triggered. In addition, if the remaining storage space in the first task area is less than a preset storage space threshold, the task evaluation mechanism is triggered.

[0074] For the first task area, the waiting time, the number of tasks and the remaining storage space corresponding to each task therein are checked in real time or regularly to determine whether the task evaluation mechanism needs to be triggered.

[0075] The following uses a specific application example to illustrate the situation where the task evaluation mechanism is triggered.

[0076] For example, the first task area includes three common tasks A, B and C, the first time threshold W1 preset in the system is 100 milliseconds, and the values ​​of the timer and counter in the first task area are set to be checked every 10 milliseconds.

[0077] Task Execution:

[0078] For Task A: (1) Enter the normal area and start timing; (2) At the 50th millisecond (the 5th round of inspection), the waiting time counter of Task A is 50 milliseconds, which does not exceed W1, i.e., 100 milliseconds; (3) The system decides to execute Task A at this time; (4) The timing of the waiting time of Task A ends, and the timing of the execution time of Task A begins.

[0079] For Task B: (1) Enter the normal zone and start timing; (2) At the 80th millisecond (the 8th round of inspection), the waiting time counter of Task B is 80 milliseconds, which does not exceed W1, i.e., 100 milliseconds; (3) The system decides to execute Task B at this time; (4) The timing of the waiting time of Task B ends, and the timing of the execution time of Task B begins.

[0080] For Task C: (1) Enter the normal zone and start timing; (2) At the 100th millisecond (the 10th round of inspection), the waiting time counter of Task C is 100 milliseconds, which is exactly equal to 100 milliseconds of W1; (3) Since Task C has not been executed when the first time threshold corresponding to W1 is reached, the system will trigger the task evaluation mechanism to avoid a task not being executed for a long time or even being starved to death, and to more reasonably allocate and plan the execution order of tasks.

[0081] In one embodiment of the present invention, the conditions under which the task evaluation mechanism is triggered and the steps performed after being triggered are as follows: Figure 5 shown.

[0082] Firstly, it is determined whether the task evaluation mechanism will be triggered according to a preset rule, that is, if the waiting time corresponding to the task is not less than a preset first time threshold, the task evaluation mechanism is triggered.

[0083] It should be noted that, in the present invention, the preset first time threshold may be a preset fixed value, for example, 80 milliseconds, 100 milliseconds, 110 milliseconds, 120 milliseconds, and the like.

[0084] More preferably, the preset first time threshold is not a preset fixed value, but a preset set value having a corresponding relationship with the task. That is, each task corresponds to a first time threshold, and the first time thresholds corresponding to different tasks may be the same or different. Specifically, the first time threshold can be determined according to the starvation time corresponding to each task. For example, the first time threshold is determined to be the difference between the starvation time corresponding to each task and a certain value. Of course, the fixed value is less than the corresponding starvation time. For example, if the starvation time of a task is 600 milliseconds, then the corresponding first time threshold is determined to be 600 milliseconds-200 milliseconds=400 milliseconds.

[0085] like Figure 5As shown, after the task evaluation mechanism is triggered, it is first determined whether there is a task in the first task area whose waiting time is not less than the preset third time threshold. If so, the task whose waiting time is not less than the preset third time threshold is immediately executed to prevent the task from being starved to death; the third time threshold is greater than the first time threshold and is not greater than the starvation time corresponding to the task. Preferably, the third time threshold also has a corresponding relationship with the starvation time of the task.

[0086] When the processor selects a task to execute from the general area, the system records the execution start time of the task and pauses updating the waiting time counters of other tasks to ensure fairness during the execution process and prevent unfair impact on other tasks due to uneven task execution time.

[0087] Ordinary area (first mission area) mission upgrade:

[0088] If there is no task in the first task area whose waiting time is not less than the preset third time threshold, the system resource utilization rate is compared with the preset utilization threshold. If the system resource utilization rate is not greater than the preset utilization threshold, the task corresponding to the waiting time exceeding the preset first time threshold is stored in the second task area. As the task is executed, the system continuously monitors the waiting time of the task in the first task area. When the waiting time of the task in the first task area is too long, the specific judgment standard is that the waiting time counter value of the task exceeds the preset first time threshold W1, and the current system resource utilization rate is lower than the preset resource utilization threshold R1 (for example, 80%). This means that the current task allocation is unreasonable and the system resources cannot be used more efficiently. At this time, the task in the first task area whose waiting time exceeds the first time threshold is promoted to the second emergency area with a higher priority and a lower urgency level area, which can make more full use of system resources and improve the processing efficiency of tasks.

[0089] Priority zone (second emergency zone) mission downgrade:

[0090] If the system resource utilization is greater than the preset utilization threshold R1 (for example, 80%), and the execution time required for the task in the second task area is greater than or equal to the preset second time threshold W2, the task will be stored in the first task area. At this time, it means that the system resources are fully utilized, but some tasks occupy too many resources due to long execution time, thus affecting the execution of other tasks. Therefore, through the task downgrading operation in the priority area, the fairness of task scheduling can be maintained: ensuring that all tasks have the opportunity to be executed, rather than letting some tasks occupy resources for a long time due to high priority; and preventing resource abuse: by monitoring the actual execution time and estimated execution time of the task, it can prevent some tasks from occupying too many resources due to long execution time, thereby affecting the execution of other tasks.

[0091] The above dynamically adjusts the allocation of tasks according to the waiting time of tasks and the resource utilization of the system, including upgrading tasks in the common area (first task area) and downgrading tasks in the priority area (second emergency area), thereby achieving a more reasonable reallocation of the areas where each task is located. After the tasks are reallocated, the scheduling and execution of tasks continue in the above priority order: the first emergency area is higher than the second emergency area, and the second emergency area is higher than the first task area.

[0092] The following is a specific application example to illustrate the task reallocation process after the task evaluation mechanism is triggered:

[0093] Suppose there is a multitasking operating system that needs to schedule the following four tasks:

[0094] Task A: high priority (corresponding to the tasks in the first emergency zone), with high resource requirements;

[0095] Task B: low priority (corresponding to the tasks in the first task area), with small resource requirements;

[0096] Task C: low priority (corresponding to the tasks in the first task area), with high resource requirements;

[0097] Task D: Medium priority (corresponding to tasks in the second emergency zone), with medium resource requirements;

[0098] The preset system resource utilization threshold is 80%.

[0099] Based on the task processing method proposed in the present invention: tasks A, B, C, and D enter the first task area and are arranged in sequence, and the system resource utilization rate is 70%; task A enters the first emergency area and is executed immediately; after a period of time, the waiting time of task B exceeds the first time threshold W1, and the system resource utilization rate is still 70%, which is lower than the resource utilization threshold of 80%.

[0100] According to the task processing method provided by the present invention, the task evaluation mechanism will be triggered. At this time, regardless of whether task D is executed or not, the priority of task B will be increased and transmitted to the second emergency area because its waiting time is too long and system resources are not fully utilized. Compared with the task processing process in the prior art, which cannot take into account the processing efficiency, priority, resource utilization and avoidance of long task waiting time, the task processing solution proposed in this application has a very good balance of multiple factors such as task priority, resource utilization, task waiting time, etc.

[0101] The task processing method proposed in the present invention has at least the following advantages compared with the existing task processing methods:

[0102] (1) The urgency level of tasks can be adjusted in real time. By setting different urgency levels for tasks and adjusting the urgency level of tasks in real time according to the real-time situation of the tasks, the flexibility of task scheduling is improved. For example, when the waiting time of a task in the first task area is too long, the task is promoted to the second emergency area of ​​the emergency area, thereby speeding up the execution of the task;

[0103] (2) Avoiding task starvation: In the task scheduling strategy of the present invention, even if there are many tasks with high urgency, tasks with low urgency will not be postponed for a long time, thus avoiding the problem of task starvation. At the same time, by setting different urgency levels for tasks, it can also ensure that urgent tasks can be responded to quickly, thereby improving the response speed of the system.

[0104] (3) Fairness guarantee: In the task scheduling strategy of the present invention, when the processor selects a task to execute from the first task area, the system will record the execution start time of the task and suspend the update of the waiting time counters of other tasks to ensure fairness in the execution process and prevent unfair impact on other tasks due to uneven task execution time;

[0105] (4) Enhanced adaptability: In the task scheduling strategy of the present invention, the urgency of the task is adjusted by monitoring and judging the task execution time, so that the execution order of the task is more adaptable to the changes of the system, thereby improving the adaptability and flexibility of the system. The task scheduling strategy of the present invention has made significant improvements over the existing technology in terms of improving the flexibility and fairness of task scheduling, and has high practical value.

[0106] In another embodiment of the present invention, a processor is provided, such as Figure 6 As shown, it includes a task processing unit, a task scheduler and a task evaluation module, wherein the task processing unit includes a first task area, a second task area and a timer configured therein;

[0107] The task processing unit acquires the task to be processed and transmits it to the first task area, the timer is configured to record the waiting time corresponding to the task, the timing start time of the waiting time is the time when the task enters the first task area, and the task processing unit is further configured to transmit the task in the first task area that meets the preset requirements to the second task area;

[0108] The task scheduler is electrically connected to the task processing unit, and the task scheduler is configured to schedule a task from the task processing unit to the execution end, and the task scheduler schedules tasks according to the rule including: preferentially scheduling tasks in the second task area;

[0109] The task evaluation module is electrically connected to the task processing unit, and the task evaluation module is triggered to work when the waiting time corresponding to the task exceeds a preset first time threshold, including: obtaining task information and system resource utilization, and adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization, wherein the task information includes the waiting time and the execution time corresponding to the task;

[0110] During the task scheduling and processing, the tasks and task information in the first task area, the first emergency area and the second emergency area are monitored in real time or periodically by the task monitor, and the task information is transmitted to the task scheduler and the task evaluation module.

[0111] In one embodiment of the present invention, a computer-readable storage medium is provided for storing program instructions, wherein the program instructions are configured to be called to execute the steps of the method described in any one of the above embodiments.

[0112] It should be noted that the processor and computer-readable storage medium embodiments provided by the present invention have the same inventive concept as the above-mentioned task processing method embodiment, and all the contents of the task processing method embodiment are incorporated into the processor and computer-readable storage medium embodiments by introduction.

[0113] Due to the advanced nature of this technical solution, it can be widely used in application fields such as operating systems, cloud computing, and embedded systems. First, in the field of operating systems, the task processing method proposed in this technical solution can effectively solve the shortcomings of the existing scheduling algorithm, ensure that each task can get a fair processing opportunity, and improve the resource utilization of the system. Secondly, in the field of cloud computing, this technical solution can be applied to virtual machine management, container scheduling, etc. In a cloud computing environment, the efficiency and fairness of task scheduling are crucial. The task processing method proposed in this technical solution can effectively solve these problems, thereby improving the performance and user experience of the cloud computing environment. Finally, in the field of embedded systems, this technical solution can be applied to various real-time systems, control systems, etc. In embedded systems, the real-time and reliability of tasks are crucial. The task processing method proposed in this technical solution can adjust the scheduling order of tasks according to factors such as the urgency level of the task and the resource utilization rate, thereby ensuring the real-time and reliability of the task. In general, the task processing method proposed in this technical solution has a broad application prospect, can meet the market demand for efficient, fair, and flexible task scheduling, and has great market potential.

[0114] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0115] The above is only a specific implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A task processing method, characterized in that: Applicable to a single processor, the method comprises the following steps: A task processing unit is provided in the processor, wherein the task processing unit is provided with a first task area and a second task area; Obtaining tasks to be processed and transmitting them to the first task area, and recording the waiting time corresponding to each task, wherein the starting time of the waiting time is the time when the task enters the first task area; Transferring tasks that meet preset requirements in the first task area to the second task area; Prioritize executing tasks in the second task area, and monitor the waiting time corresponding to each task in the first task area; If there is a waiting time corresponding to the task that is not less than a preset first time threshold, a task evaluation mechanism is triggered, including: obtaining task information and system resource utilization, and adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization, the task information including the waiting time and the execution time corresponding to the task, and the preset first time threshold being a preset value having a corresponding relationship with the task; Wherein, adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization rate includes: If there is a task in the first task area whose waiting time is not less than the preset third time threshold, the task whose waiting time is not less than the preset third time threshold is immediately executed; the third time threshold is greater than the first time threshold and not greater than the starvation time corresponding to the task; If there is no task in the first task area whose waiting time is not less than the preset third time threshold, the system resource utilization is compared with the preset utilization threshold, and if the system resource utilization is not greater than the preset utilization threshold, the task corresponding to the waiting time exceeding the preset first time threshold is stored in the second task area; If the system resource utilization is greater than the preset utilization threshold, and there is a task in the second task area whose execution time is greater than or equal to the preset second time threshold, then the task corresponding to the task whose execution time is greater than or equal to the preset second time threshold is stored in the first task area.

2. The task processing method according to claim 1, characterized in that: The third time threshold has a corresponding relationship with the starvation time of the task.

3. The task processing method according to claim 1, characterized in that: If the number of tasks in the first task area exceeds a preset number threshold, the task evaluation mechanism is triggered; and / or, If the remaining storage space of the first task area is less than a preset storage space threshold, the task evaluation mechanism is triggered.

4. The task processing method according to claim 1, characterized in that: The step of transferring the tasks meeting preset requirements in the first task area to the second task area comprises: Obtaining task information corresponding to each task, wherein the task information includes a priority, and the priority includes an urgent priority and a normal priority; The urgent task is stored in the second task area, and the priority of the urgent task is urgent.

5. The task processing method according to claim 4, characterized in that: The second mission area includes a first emergency area and a second emergency area; The urgency in the priority level also includes the first urgency and the second urgency. The first urgency task is stored in the first urgency area, and the second urgency task is stored in the second urgency area. The priority of the first urgency task is the first urgency, and the priority of the second urgency task is the second urgency. The tasks in the first emergency area are executed first. If there are no tasks in the first emergency area, the tasks in the second emergency area are executed first.

6. The task processing method according to claim 5, characterized in that: When the task evaluation mechanism is triggered, the tasks in the first emergency area are not affected to be executed preferentially; or, The tasks in the first emergency area will not be adjusted to the second emergency area or the first task area due to triggering the task evaluation mechanism.

7. The task processing method according to claim 5, characterized in that: The priority level of a task directly initiated by a user is configured as the first urgency.

8. The task processing method according to claim 4, characterized in that: The task information also includes the time required for execution, and if the time required for execution is less than a preset fourth time threshold, the priority of the task is configured as second urgency, and the fourth time threshold is less than the first time threshold.

9. A processor, characterized in that: It includes a task processing unit, a task scheduler and a task evaluation module, wherein the task processing unit includes a first task area, a second task area and a timer; The task processing unit acquires the task to be processed and transmits it to the first task area, the timer is configured to record the waiting time corresponding to the task, the timing start time of the waiting time is the time when the task enters the first task area, and the task processing unit is further configured to transmit the task in the first task area that meets the preset requirements to the second task area; The task scheduler is electrically connected to the task processing unit, and the task scheduler is configured to schedule a task from the task processing unit to the execution end, and the task scheduler schedules tasks according to the rule including: preferentially scheduling tasks in the second task area; The task evaluation module is electrically connected to the task processing unit, and the task evaluation module is triggered to work when the waiting time corresponding to the task exceeds a preset first time threshold, including: obtaining task information and system resource utilization, and adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization, the task information including the waiting time and the execution time corresponding to the task, and the preset first time threshold is a preset value having a corresponding relationship with the task; Wherein, adjusting the task allocation in the first task area and the second task area according to the task information and / or the system resource utilization rate includes: If there is a task in the first task area whose waiting time is not less than the preset third time threshold, the task whose waiting time is not less than the preset third time threshold is immediately executed; the third time threshold is greater than the first time threshold and not greater than the starvation time corresponding to the task; If there is no task in the first task area whose waiting time is not less than the preset third time threshold, the system resource utilization is compared with the preset utilization threshold, and if the system resource utilization is not greater than the preset utilization threshold, the task corresponding to the waiting time exceeding the preset first time threshold is stored in the second task area; If the system resource utilization is greater than the preset utilization threshold, and there is a task in the second task area whose execution time is greater than or equal to the preset second time threshold, then the task corresponding to the task whose execution time is greater than or equal to the preset second time threshold is stored in the first task area.

10. A computer-readable storage medium for storing program instructions, characterized in that: The program instructions are configured to be called to execute the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Task scheduling method in cloud computing environment

    CN103324525A

  • Heterogeneous sensing GPU (Graphics Processing Unit) resource allocation and scheduling method and system

    CN113535387A

  • Data loss detection method and system for intelligent storage chip

    CN118331504A