Task processing method and device

By adjusting the task priority of not responding to low task priority in the Linux kernel system, the system instability caused by long-term CPU occupation by physical layer tasks is solved, and timely task scheduling and system stability are improved.

CN119473546APending Publication Date: 2025-02-18LENOVO (BEIJING) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411547220.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In Linux kernel systems, physical layer tasks occupy CPU for a long time, resulting in lagging or inability to schedule kernel tasks, which leads to system instability, such as system lag or downtime.

Method used

By traversing the task running state in the system, the priority of the second task with the low priority of the unresponsive first task is adjusted to be equal to or higher than the priority of the first task, thereby prioritizing the scheduling of the second task.

Benefits of technology

The problem of blocking the second task affected by the first task is solved, ensuring that the blocking task is scheduled in time and improving system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473546A_ABST
    Figure CN119473546A_ABST
Patent Text Reader

Abstract

The invention discloses a task processing method and device. The task processing method comprises the steps that the running state of a task in a system is traversed; when it is determined that the system does not respond within a first duration based on a first task based on a traversal result of the running state and a second task needing to be scheduled preferentially exists in the system, the priority of a second class of tasks to which the second task belongs is adjusted, the first task belongs to the first class of tasks, and the second class of tasks need to be scheduled preferentially. The adjusted priority of the second class of tasks is equal to or higher than the priority of the first class of tasks; and scheduling the second task based on the adjusted priority of the second type of task. According to the scheme, the system stability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and is related to but not limited to task processing methods and devices. Background Art

[0002] In the Linux kernel system, process management includes five scheduling classes, with priorities arranged from high to low: stop, deadline, real-time (rt), completely fair scheduling (cfs), and idle. Physical layer tasks usually use the rt scheduling class and select the first-in-first-out (sched_fifo) scheduling strategy with priorities of 98 and 99. The characteristics of the sched_fifo scheduling strategy are that it adopts a first-in-first-out scheduling method, and tasks will only be switched before they are finished or blocked. They will only be blocked when the current task priority is lower than other tasks. In order to ensure real-time requirements, physical layer tasks choose non-blocking task design. Therefore, after the physical layer tasks start, they often occupy the CPU for a long time and will not be switched at will, resulting in processing lags or inability to schedule kernel tasks in the system, which in turn leads to system instability, such as system freezes and system crashes. Summary of the invention

[0003] The present application provides a task processing method and device, which improve the system stability for the solution of the present application.

[0004] The technical solution of this application is implemented as follows:

[0005] The present application provides a task processing method, the method comprising:

[0006] Traverse the running status of tasks in the system;

[0007] Determining based on the traversal result of the running status that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled with priority, adjusting the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, the priority of the second category of tasks before adjustment is lower than the priority of the first category of tasks, and the priority of the second category of tasks after adjustment is equal to or higher than the priority of the first category of tasks;

[0008] The second tasks are scheduled based on the adjusted priorities of the second-category tasks.

[0009] The present application provides a task processing device, which is deployed in an electronic device and includes:

[0010] The monitoring module is used to traverse the running status of tasks in the system;

[0011] an adjustment module, configured to determine, based on the traversal result of the running status, that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled with priority, adjust the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks;

[0012] A scheduling module is used to schedule the second task based on the adjusted priority of the second type of task.

[0013] The present application also provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the above-mentioned task processing method when executing the program.

[0014] The present application also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned task processing method is implemented.

[0015] The task processing method, apparatus, device and storage medium provided in this application include:

[0016] Traverse the running status of tasks in the system;

[0017] Determining, based on the traversal result of the running status, that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled with priority, adjusting the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks;

[0018] The second tasks are scheduled based on the adjusted priorities of the second-category tasks.

[0019] It can be seen that for the solution of the present application, when the system is hung based on the first task and there is a second task that needs to be scheduled with priority, the priority of the second task is adjusted by adjusting the priority of the second type of task, so that the priority of the second task is equal to or higher than the priority of the first task. Relative to the second task before the priority adjustment, there is no need to wait for the first task to release resources, and the second task can be prioritized or scheduled in advance, thereby solving the problem of blocking the second task affected by the first task, ensuring that the affected blocked tasks are scheduled in time, and improving system stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0021] Figure 2An optional flowchart of a task processing method provided in an embodiment of the present application;

[0022] Figure 3 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0023] Figure 4 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0024] Figure 5 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0025] Figure 6 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0026] Figure 7 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0027] Figure 8 An optional flowchart of a task processing method provided in an embodiment of the present application;

[0028] Fig. 9 An optional structural diagram of a task processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.

[0030] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0031] In the following description, the terms "first\second\third" are used only as examples to distinguish different objects, and do not represent a specific order for the objects, nor do they have a limitation on the order of precedence. It is understandable that "first\second\third" can be interchanged with a specific order or order of precedence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0033] The embodiments of the present application can provide a task processing method, device, equipment and storage medium. In practical applications, the task processing method can be implemented by a task processing device, and each functional entity in the task processing device can be collaboratively implemented by hardware resources of the electronic device, such as computing resources such as a processor, and communication resources (such as for supporting various communication methods such as optical cables and cellular).

[0034] In a first aspect, an embodiment of the present application provides a task processing method, which is applied to a task processing device; wherein the task processing device can be deployed in an electronic device. Below, the task processing method provided by the embodiment of the present application is described with the electronic device as the execution subject.

[0035] Figure 1 A flowchart showing an alternative task processing method is shown. Figure 1 The process may include but is not limited to the following: Figure 1 S101 to S103 shown.

[0036] S101, traverse the running status of tasks in the system.

[0037] The system may include multiple types of tasks, and the priorities of different types of tasks may be different. In the embodiment of the present application, for one type of task, a scheduling parameter for determining the priority is configured.

[0038] In one example, the scheduling parameters include: scheduling class, scheduling policy and scheduling priority. Among them, the scheduling class is a large classification of process scheduling, and different scheduling classes have different goals and mechanisms; the scheduling policy is the implementation details within a specific scheduling class, which determines how to select the next running process in the class. Each scheduling class can have one or more scheduling policies; the scheduling priority is a numerical value that indicates the scheduling priority of a process relative to other processes.

[0039] The terminal device traverses the tasks in the system to determine the running status of the tasks in the system.

[0040] In a possible implementation, the terminal device traverses the tasks in a kernel in units of kernels to determine the running status of each task.

[0041] In the embodiment of the present application, the running state of a task may include: running, sleeping, stopping, zombie, D-uninterruptible sleep (D state), dead, etc. In the embodiment of the present application, there is no limitation on the classification of the running state of a task.

[0042] S102. Based on the traversal results of the running status, it is determined that the system adjusts the priority of the second category of tasks to which the first task belongs when the second task does not respond within a first time period and there is a second task in the system that needs to be scheduled with priority, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks.

[0043] After determining the running status of the tasks in the system, it is detected whether the system does not respond within a first time period based on the first task based on the determined running status.

[0044] In the embodiment of the present application, the first task can be understood as a task that causes the system to fail to respond within the first time period. The first task can be a pre-set task or a task in which an exception occurs. The first task can be different based on different situations in which the system fails to respond within the first time period.

[0045] In the embodiment of the present application, the failure of the system to respond within the first time period can be understood as the system being hung or deadlocked. The situations where the system fails to respond within the first time period include:

[0046] Case 1: The first task preempts the second task;

[0047] Case 2: There is a kernel thread that enters the first task of an infinite loop;

[0048] Case 3: The first task that takes too long to process is interrupted.

[0049] For case 1, the first task may be a designated task to be tracked, the system may include one or more first tasks, and the second task may be understood as a task preempted by the first task. In the case where the first task preempts the second task, it can be considered that the system does not respond within the first time period because the system occupies more resources based on the scheduling of the first task.

[0050] In the embodiment of the present application, the first task belongs to the first category of tasks, and the first category of tasks may be tasks with a priority higher than the specified priority and consuming more resources than the specified resources, such as base station tasks. Then situation 1 can be understood as the system not responding within the first time period due to the priority of processing the first category of tasks.

[0051] For situation 2, the first task is a task whose kernel thread enters an infinite loop. At this time, since the kernel thread of the first task enters an infinite loop, the system cannot respond.

[0052] For situation 3, the first task is a task whose interrupt processing time is too long. At this time, the system cannot respond because the interrupt processing time is too long.

[0053] In the embodiment of the present application, situation 1 may be understood as a soft deadlock, and situation 2 and situation 3 may be hard deadlocks.

[0054] The task processing method provided in the embodiment of the present application can be applied to a variety of different deadlock scenarios, so that a variety of deadlock problems can be processed in a combined manner.

[0055] In the case that the system does not respond within the first time period based on the first task, and there is a second task that needs to be scheduled with priority, the second task cannot be scheduled due to the influence of the first task, that is, the second task is a blocked task affected by the first task. In the case that there is a second task that needs to be scheduled with priority, the priority of the second-class task to which the second task belongs is increased, so that the priority of the second-class task is equal to or higher than the priority of the first-class task to which the first task belongs.

[0056] In the embodiment of the present application, the scheduling parameters of the second type of tasks can be adjusted to adjust the priority of the second type of tasks. The scheduling parameters are used to determine the priority of the tasks. The priority is used to determine the scheduling order of the tasks, wherein a task with a high priority is scheduled before a task with a low priority.

[0057] In the embodiment of the present application, when the priority of the second-category task is adjusted, the modification flag of the second task may be set to indicate that the priority of the second-category task is modified.

[0058] The modification flag of the second task is used to indicate whether the priority of the second type of task is modified. The modification flag of the second task indicates whether the priority of the second type of task is modified based on different values. In one example, the value of the modification flag of the second task is 1, indicating that the priority of the second type of task is modified; the value of the modification flag of the second task is 0, indicating that the priority of the second type of task is not modified.

[0059] If the adjusted priority of the second-category task is equal to or higher than the priority of the first-category task, the priority of the second task is adjusted, and the adjusted priority of the second task is equal to or higher than the priority of the first task.

[0060] S103: Scheduling the second task based on the adjusted priority of the second-type task.

[0061] If the adjusted priority of the second task is higher than the priority of the first task, the system interrupts the scheduling of the first task, the first task releases resources, and the second task is scheduled, and resources are allocated to the second task, thereby achieving priority processing of the second task.

[0062] If the adjusted priority of the second task is equal to the priority of the first task, the system maintains the scheduling of the first task and schedules the second task, and resources are allocated to the first task and the second task respectively, thereby realizing early processing of the second task.

[0063] If the priority of the second type of task is not adjusted, the second task may be allocated resources only after the first task is executed and the resources are released, and then it is processed based on the allocated resources. In the embodiment of the present application, the priority of the second type of task is adjusted, and the adjusted priority of the second type of task is equal to or higher than the priority of the first type of task, so that the priority of the second task is equal to or higher than the priority of the first task, so that the second task is scheduled in advance or with priority.

[0064] It should be noted that, in an embodiment of the present application, a kernel module may be embedded in the system, and the name of the task in the system may be used as an internal parameter of the kernel module, so that the tasks in the system may be traversed through the kernel module.

[0065] In the embodiments of the present application, the kernel module can be flexibly configured and can be loaded and used online, unloaded and disabled, etc.

[0066] In an embodiment of the present application, when the system is hung based on the first task and there is a second task that needs to be scheduled with priority, the priority of the second task is adjusted by adjusting the priority of the second type of task, so that the priority of the second task is equal to or higher than the priority of the first task. Relative to the second task before the priority adjustment, there is no need to wait for the first task to release resources, and the second task can be prioritized or scheduled in advance, thereby solving the problem of blocking the second task affected by the first task, ensuring that the affected blocked tasks are scheduled in time, and improving system stability.

[0067] The following describes a method for determining that the first task has not responded within the first time period based on the system. In a possible implementation, the task processing method provided in the embodiment of the present application further includes:

[0068] When the running state of the first task is running and the first task preempts the second task, it is determined that the system does not respond within a first time period based on the first task.

[0069] The running state of the first task may be one of the following states: running, sleeping, stopping, zombie, D-uninterruptible sleep (D state), and dead.

[0070] In the case where a first task is running and the first task preempts a second task, it can be considered that the system is hung based on the first task.

[0071] If the running state of the first task is not D state, it is determined that the first task is running. In the embodiment of the present application, if the running state of the task is D state, it means that the thread of the task is waiting for certain conditions (such as hardware I / O), and this process cannot be interrupted.

[0072] In the embodiment of the present application, the first task can be a user state task or a kernel state task, and the second task is a kernel task. At this time, if the task in the user state causes the kernel task to deadlock, and the kernel task needs to be processed first, the priority of the kernel task is adjusted and the kernel task is scheduled first.

[0073] In a possible implementation, if the first task is in an uninterruptible sleep state, it indicates that an exception occurs in the processing of the first task, and the first task may be killed and the task scheduling or other exception protection mechanisms, such as timeout design, may be restarted.

[0074] In a possible implementation, the step of determining that the first task preempts the second task includes:

[0075] When the running state of the second task is an uninterruptible sleep state, the second task is not scheduled, and the scheduling start time of the second task is earlier than the scheduling start time of the first task, it is determined that the first task preempts the second task.

[0076] In an embodiment of the present application, tasks in the system except the first task can be traversed. If a task meets the following conditions: the running state of the task is a terminal state, no scheduling occurs, and the scheduling start time is earlier than the scheduling start time of the first task, then it is considered that the first task preempts the task and the task can be considered as the second task.

[0077] In the embodiment of the present application, a thread descriptor is recorded for each task, and the thread descriptor includes the scheduling start time of the task. The scheduling start time is the time point when the task starts to be scheduled.

[0078] If the task is in D state, no scheduling occurs, and the scheduling start time is earlier than the scheduling start time of the first task, it indicates that the task line is scheduled, and after being scheduled, based on the arrival of the first task, the first task is scheduled, and the first task occupies more resources, and there are no available resources allocated to the second task, so that the second task is not scheduled, and the second task is always in a state of waiting for resources.

[0079] In an example, task A starts running at 0 o'clock, runs for 1 second (s) and is in D state, and task B starts running at 1 o'clock, runs for 10 seconds and is in running state. From the timeline, task A runs first and task B runs later. Task B, which runs later, continues to occupy CPU resources, indicating that task B preempted task A and has not released the resources after occupying them, causing task A to be in a state of waiting for resources.

[0080] In an embodiment of the present application, the priority of the first category of tasks is higher than the priority of the second category of tasks before adjustment, that is, the priority of the first task is higher than the priority of the second task. Therefore, when the first task arrives, the first task is scheduled relative to the second task being scheduled, and the scheduling of the second task is interrupted.

[0081] The terminal device can traverse the tasks in the system, determine all the first tasks included in the system and record the first tasks in a tracking list, and at the same time clarify the kernel where each first task is located.

[0082] The tracking list also includes the descriptor information of the first task or a pointer address for obtaining the descriptor information. In one possible implementation, the pointer address of the thread descriptor of each first task in at least one first task is recorded in the tracking list, and the pointer address of the first descriptor can be used to obtain the thread descriptor of the first task.

[0083] The thread descriptor of the first task may include at least the following information of the first task: a scheduling start time.

[0084] In the case where the second task is rescheduled based on the priority of the second type of task,

[0085] The scheduling start time of the second task is updated to the rescheduled time.

[0086] In an embodiment of the present application, when a first task with a higher priority and more resource consumption is scheduled for a long time and preempts a second task, the second task affected by the first task is blocked. When the second task needs to be scheduled first, the priority of the second task is adjusted to ensure timely processing of the blocked second task and improve system stability.

[0087] In some embodiments, the case where the system does not respond within the first time period includes the case 1, S101 traverses the running status of the tasks in the system, including Figure 2 Steps shown:

[0088] S1011, determining a first kernel where the first task is located;

[0089] S1012. Traverse the running status of the tasks on the first core based on a specified period; wherein the second task is the task on the first core.

[0090] For the first task, determine the core where the first task is located, and determine the running status of all tasks on the core based on a specified period, so as to judge whether there is a second task preempted by the first task among the tasks on the core where the first task is located. At this time, the first task and the second task are tasks on the same core.

[0091] In the embodiment of the present application, the task preemption determination is performed on a core basis, so that the second task preempted by the first task can be effectively and quickly determined, that is, when the first task preempts the second task, the system processing efficiency can be improved.

[0092] The following describes a method for determining the priority scheduling of the second task.

[0093] In some embodiments, the task processing method provided by the embodiment of the present application also includes: Figure 3 Steps shown:

[0094] S301, determining, in the system, whether the second task holds a lock when the first task does not respond within a first time period;

[0095] S302: When the second task holds the lock, determine that the second task needs to be scheduled first.

[0096] In the case where the second task holds the lock, the second task can be understood as a lock-holding task, and the lock-holding task can be understood as a task that needs to be scheduled first. The lock held by the second task is a lock provided by the kernel, which may include: a conventional lock including a read-write lock, and a read-copy-update lock.

[0097] In one example, when task A preempts task B, it is determined whether task B holds a lock. If task B holds a lock, it is determined that task B needs to be scheduled first, and the priority of the task class described in task B is adjusted.

[0098] In the embodiment of the present application, whether the second task needs to be scheduled first is determined based on whether the second task holds a lock, so that the priority scheduling requirement of a second task can be determined effectively and quickly.

[0099] In some embodiments, adjusting the priority of the second category of tasks further includes:

[0100] In the case where the third task is waiting for the lock held by the second task, the priority of the second type of tasks is adjusted.

[0101] Here, the system adjusts the priority of the second type of task based on the fact that the first task is hung, the second task is a lock holding task, and there is a lock waiting task waiting for the lock held by the second task.

[0102] For a task, if the waiting lock parameter of the task indicates that the task is waiting for a lock and the owner of the waiting lock is the second task, the task is the third task. The third task and the second task can be tasks on the same core or on different cores.

[0103] In the embodiment of the present application, the third task may be a user mode task or a kernel task.

[0104] In the embodiment of the present application, the first task is a high-priority task that continuously occupies resources, the second task is a task that is blocked and locked due to the influence of the first task, and the third task is a lock-waiting task that is waiting for the lock held by the second task, that is, the third task is a task affected by the second task, that is, the second task waits for the first task, and the third task waits for the second task, that is, multiple tasks influence each other, forming a restraint between the multiple tasks.

[0105] In one example, task A is the task to be tracked, task A preempts task B, task B holds a lock and task C waits for the lock of task B, then the priority of task B is adjusted.

[0106] In actual applications, there may also be a fourth task affected by the third task, for example, the fourth task waits for the lock of the third task.

[0107] In an embodiment of the present application, when there is a second task that is blocked by the first task and affects other tasks, namely the third task, the priority of the second task class of the second task is increased, thereby increasing the priority of the second task, scheduling the second task as soon as possible, resolving task blocking, and improving system stability.

[0108] In a possible implementation, when the system is based on the fact that the first task is hung and the second task needs to be scheduled with priority, the priority of the second type of task is directly adjusted.

[0109] The following describes a method for adjusting the priority of the second category of tasks.

[0110] In some embodiments, adjusting the priority of the second category of tasks in S102 includes:

[0111] One or more of the scheduling class, scheduling strategy and scheduling priority of the second-category tasks are adjusted so that the priority of the second-category tasks is improved.

[0112] The scheduling parameters of the second task are adjusted to adjust the priority of the second task, wherein the scheduling parameters of the second task are the same as the scheduling parameters of the second task class to which the second task belongs. It is understandable that tasks of the same class use unified scheduling parameters.

[0113] The scheduling parameters may include a scheduling class, a scheduling policy, and a scheduling priority. The scheduling class, scheduling policy, and scheduling priority of the second category of tasks are checked in turn, so as to adjust one or more of the scheduling class, scheduling policy, and scheduling priority of the second category of tasks to adjust the priority of the second category of tasks.

[0114] In one example, the scheduling class of the second type of tasks is adjusted.

[0115] In one example, the scheduling policy of the second type of tasks is adjusted.

[0116] In one example, the scheduling class and scheduling policy of the second type of tasks are adjusted.

[0117] In one example, the scheduling priority of the second type of tasks is adjusted.

[0118] In one example, the scheduling class and scheduling priority of the second category of tasks are adjusted.

[0119] In one example, the scheduling class, scheduling policy, and scheduling priority of the second type of tasks are adjusted.

[0120] In the embodiment of the present application, the scheduling parameters of the second type of tasks may be adjusted based on a comparison between the scheduling parameters of the first type of tasks and the scheduling parameters of the second type of tasks.

[0121] In some embodiments, adjusting one or more of the scheduling class, scheduling policy, and scheduling priority of the second type of tasks includes at least one of the following:

[0122] When the priority of the scheduling class of the first type of tasks is higher than the priority of the scheduling class of the second type of tasks, adjusting the scheduling class of the second type of tasks to the scheduling class of the first type of tasks;

[0123] When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the priority of the scheduling policy of the first category of tasks is higher than the priority of the scheduling policy of the second category of tasks, adjusting the scheduling policy of the second category of tasks to the scheduling policy of the first category of tasks;

[0124] When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the scheduling strategy of the first category of tasks is the same as the scheduling strategy of the second category of tasks, adjust the scheduling priority of the second category of tasks so that the scheduling priority of the second category of tasks is equal to or higher than the scheduling priority of the first category of tasks.

[0125] In the embodiment of the present application, the priority of the first type of tasks is higher than the priority of the second type of tasks, wherein:

[0126] The priority of the first type of tasks is higher than that of the second type of tasks, including the following situations:

[0127] The priority of the scheduling class of the first type of task is higher than the priority of the scheduling class of the second task, the priority of the scheduling policy of the first type of task is higher than, equal to, or lower than the priority of the scheduling policy of the second task, and the scheduling priority of the first type of task is higher than, equal to, or lower than the priority of the second task;

[0128] The priority of the scheduling class of the first type of task is equal to the priority of the scheduling class of the second task, the priority of the scheduling policy of the first type of task is higher than the priority of the scheduling policy of the second task, and the scheduling priority of the first type of task is higher than, equal to, or lower than the priority of the second task;

[0129] The priority of the scheduling class of the first type of task is equal to the priority of the scheduling class of the second task, the priority of the scheduling policy of the first type of task is equal to the priority of the scheduling policy of the second task, and the scheduling priority of the first type of task is higher than the priority of the second task.

[0130] In the embodiment of the present application, the scheduling class, scheduling strategy and scheduling priority of the first task and the second task may be compared in sequence.

[0131] Compare the scheduling class of the first category of tasks with the scheduling class of the second category of tasks: when the priority of the scheduling class of the first category of tasks is higher than the priority of the scheduling class of the second category of tasks, adjust the scheduling class of the second category of tasks to the scheduling class of the first category of tasks, so that the adjustment class of the first category of tasks is the same as the adjustment class of the second category of tasks, and after the adjustment class of the first category of tasks is the same as the adjustment class of the second category of tasks, compare the scheduling policy of the first category of tasks with the scheduling policy of the second category of tasks. When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, compare the scheduling policy of the first category of tasks with the scheduling policy of the second category of tasks.

[0132] Compare the scheduling policies of the first category of tasks and the scheduling policies of the second category of tasks: when the priority of the scheduling policy of the first category of tasks is lower than the priority of the scheduling policy of the second category of tasks, there is no need to adjust the scheduling policy of the second category of tasks. When the priority of the scheduling policy of the first category of tasks is higher than the priority of the scheduling policy of the second category of tasks, adjust the scheduling policy of the second category of tasks to the scheduling policy of the first category of tasks, so that the adjustment policy of the first category of tasks is the same as the adjustment policy of the second category of tasks, and after the adjustment policy of the first category of tasks is the same as the adjustment policy of the second category of tasks, compare the scheduling priority of the first category of tasks with the scheduling priority of the second category of tasks. When the scheduling policy of the first category of tasks is the same as the scheduling policy of the second category of tasks, compare the scheduling priority of the first category of tasks with the scheduling priority of the second category of tasks.

[0133] Compare the scheduling priority of the first category of tasks with the scheduling priority of the second category of tasks: if the scheduling priority of the first category of tasks is equal to or lower than the priority of the scheduling policy of the second category of tasks, there is no need to adjust the scheduling priority of the second category of tasks. If the scheduling priority of the first category of tasks is higher than the scheduling priority of the second category of tasks, adjust the scheduling priority of the second category of tasks to be equal to or higher than the scheduling priority of the first category of tasks.

[0134] In one example, the scheduling parameters of the first type of tasks include: scheduling class A, scheduling policy A and scheduling priority A, and the scheduling parameters of the second type of tasks include: scheduling class B, scheduling policy B and scheduling priority B. The priority of the second type of tasks can be adjusted as follows: Figure 4 As shown, including:

[0135] S401: Determine whether the priority of scheduling class A is higher than the priority of scheduling class B.

[0136] If the priority of scheduling class A is higher than the priority of scheduling class B, execute S402; otherwise, execute S403.

[0137] S402: Adjust the scheduling class of the second type of tasks to scheduling class A.

[0138] S403: Determine whether the priority of scheduling strategy A is higher than the priority of scheduling strategy B.

[0139] If the priority of scheduling policy A is higher than the priority of scheduling policy B, execute S404; otherwise, execute S405.

[0140] S404: Adjust the scheduling strategy of the second type of tasks to scheduling strategy A.

[0141] S405: Determine whether scheduling priority A is higher than scheduling priority B.

[0142] If the scheduling priority A is slightly higher than the scheduling priority B, execute S406.

[0143] S406: Adjust the scheduling priority of the second type of tasks to scheduling priority A.

[0144] In S406 , the scheduling priority of the second type of tasks may also be adjusted to scheduling priority C, and scheduling priority C is higher than scheduling priority A.

[0145] In the embodiment of the present application, the priority of the second type of task is adjusted based on the scheduling class, scheduling policy and scheduling priority included in the scheduling parameters, following the kernel's settings on the scheduling class, scheduling policy and scheduling priority, and there is no need to adjust the kernel's scheduling mechanism, thereby reducing the complexity of priority adjustment. In addition, in the embodiment of the present application, the scheduling parameters of the task class are adjusted in the kernel, thereby reducing the scheduling delay of the second task on the first task.

[0146] In some embodiments, the task processing method provided by the embodiment of the present application also includes Figure 5 Steps shown:

[0147] S501. When detecting the second-category task whose priority has been adjusted, restore the priority of the second-category task to the priority before adjustment; wherein the priority of the second-category task before adjustment is lower than the priority of the first-category task.

[0148] After the scheduling of the second task is completed, if it is detected that the system includes a second-category task whose priority has been adjusted, the priority of the second-category task is restored to the priority before the adjustment.

[0149] In the embodiment of the present application, the priority of the second type of task can be restored based on the completion of the scheduling of the second task. The priority of the second type of task can also be restored in the next scheduling cycle. Restoring the priority of the second type of task may include: restoring the scheduling parameters of the second type of task.

[0150] In the embodiment of the present application, whether the priority of the second task class is modified may be identified based on the modification flag of the second task.

[0151] Taking the restoration of the priority of the second type of task based on the completion of the scheduling of the second task as an example, when there is a modification flag for the task that has completed the scheduling, and the modification flag indicates that the priority of the task class corresponding to the task has been modified, the task can be considered as the second task, and the modification flag indicates that the priority of the second type of task has been modified, the scheduling parameters of the second type of task before being modified are obtained, and the scheduling parameters of the second type of task are restored to the scheduling parameters of the second type of task before being modified.

[0152] In order to restore the priority of the second type of task in the next scheduling cycle, the electronic device traverses the tasks in the first kernel based on the specified cycle. When a task is not preempted by the first task and there is a modification flag, and the modification flag indicates that the priority of the task class corresponding to the task is modified, the task can be considered to be the second task that has completed the scheduling, and the modification flag indicates that the priority of the second type of task is modified. At this time, the scheduling parameters of the second type of task before being modified are obtained, and the scheduling parameters of the second type of task are restored to the scheduling parameters of the second type of task before being modified.

[0153] In the embodiment of the present application, if the state of a task is not D state, no scheduling occurs, and the scheduling start time is later than the scheduling start time of the first task, it can be considered that the task is not preempted by the first task. Here, if the task is the second task, the scheduling start time of the task is the time when the task is scheduled again based on the adjustment of the priority.

[0154] After the priority of the second-category task is restored, when a task belonging to the second-category task is included in the system again, the task is scheduled according to the restored priority.

[0155] In an embodiment of the present application, when the second task is blocked due to the influence of the first task, the priority of the second type of task is adjusted to give priority to the processing of the second task, and after the processing of the second task is completed, the priority of the second type of task is automatically restored or recovered without affecting the operation of the first type of task.

[0156] Below, taking the first task as a base station task as an example, the task processing method provided in an embodiment of the present application is described.

[0157] In the related technology, the fifth generation (5G) digital indoor base station of the open Radio Access Network (O-RAN) is composed of three parts: a host unit (including a distributed unit (DU) + a central unit (CU)), an extension unit (such as a hub), and a remote radio unit (RRU).

[0158] The host unit adopts a general-purpose server processing platform. The physical layer involves high-speed data exchange and a large number of parallel intensive complex operations. In order to meet high real-time requirements, the CPU side physical layer tasks select high-priority scheduling strategies and high-priority configurations when running.

[0159] In the Linux kernel system, process management includes five scheduling classes, and the priorities of these five scheduling classes are arranged from high to low: stop, deadline, real-time (rt), completely fair scheduling (cfs), and idle. Physical layer tasks usually use the rt scheduling class and select the first-in-first-out (sched_fifo) scheduling strategy with priorities of 98 and 99. The characteristics of the sched_fifo scheduling strategy are that it adopts a first-in-first-out scheduling method, and tasks will only be switched before they are finished or blocked, and will only be blocked when the current task priority is lower than other tasks. In order to ensure the real-time requirements of physical layer tasks, non-blocking task design is selected in the logic design. Therefore, after the physical layer tasks start, they often occupy the CPU for a long time and will not be switched at will, resulting in processing lags or inability to schedule kernel-related tasks in the system, which in turn leads to system instability, such as system freezes and system crashes.

[0160] The above five scheduling classes are described below.

[0161] Stop: No CPU allocation is performed for stopped tasks; Deadline: Complete tasks before the deadline; Rt: Real-time task processing; Cfs: Completely fair scheduling, evenly allocating CPU to each task; Idle: Process this type of task when there are no other tasks.

[0162] In the embodiments of the present application, a scheduling class is a large classification of process scheduling, and different scheduling classes have different goals and mechanisms. A scheduling policy is an implementation detail within a specific scheduling class that determines how to select the next running process in the class. Each scheduling class can have one or more scheduling policies. A scheduling priority is a numerical value that indicates the scheduling priority of a process relative to other processes. A scheduling class defines the type and structure of scheduling, a scheduling policy implements a specific scheduling algorithm, and a scheduling priority plays a role in actual decision-making in the scheduling policy.

[0163] In view of the existing problems, the analysis and confirmation method uses the system's stuck task hungtask mechanism combined with the kdump tool to mirror the system data after the system is hung for 600 seconds to the disk, recover through the crash tool, and analyze and interpret the point where the system is hung. In addition, by adjusting the system kernel parameters and reducing the physical layer scheduling priority, the probability of system instability can be reduced.

[0164] The above methods can greatly reduce the problem of system instability, but it has many negative effects on the stability of the physical layer software and the entire 5G system. For example, due to the adjustment of scheduling strategies and scheduling priorities, the physical layer transmission time interval (TTI) delay is large, the delay of interaction with hardware increases, and then the internal logic of the physical layer has different degrees of delay, uplink and downlink communication brings more lags, resulting in 5G system instability. Another example: Problem analysis requires stopping the current kernel, saving the image, and restarting the server, resulting in business suspension.

[0165] The task processing method provided in the embodiment of the present application includes the following contents: 1. Monitoring the operation status of base station tasks in the Linux kernel; 2. Flexible adjustment of scheduling strategies, which can be automatically restored after adjustment without affecting the operation of base station software; 3. The framework design can combine multiple problem optimizations; 4. The kernel module is flexibly configured and can be loaded and used online, uninstalled and disabled, etc.; 5. The module interface is compatible with multiple kernel versions and users are not aware of it.

[0166] The task processing method provided in the embodiment of the present application has the following technical advantages: automatically analyzing the base station operating status in the kernel according to the set logic, adjusting the task scheduling strategy and priority, and solving the blocking problem of the affected tasks; not involving the upper-level software architecture and the underlying hardware manufacturers; and being able to merge the stability issues of multiple base station systems.

[0167] The task processing method provided in the embodiment of the present application can be as follows: Figure 6 As shown, including:

[0168] S601: Determine the name of each task to be tracked.

[0169] The kernel module input parameter is the name of the task to be tracked tsk_lnx, such as the polling-cpri task of the base station software phy module.

[0170] Among them, tasks with high priority and consuming more resources can be used as tasks to be tracked.

[0171] S602: traverse all tasks in the system and save thread descriptor information of the tasks to be tracked.

[0172] According to the parameter-passing task, record the thread descriptor information of the task to be tracked.

[0173] In actual use, the pointer address of the thread descriptor is recorded, and in subsequent use, the specific information of the recorded thread descriptor is obtained according to the pointer address.

[0174] S603: Create a task list to be tracked based on the tasks to be tracked.

[0175] The descriptor information of the task to be tracked is saved in the task linked list lnx_tsks.

[0176] S604: After waiting for 1 second, traverse the tracking task list to obtain the running information of the task to be tracked.

[0177] Here, 1 can be fixed as the traversal cycle, and the task list is periodically traversed and tracked based on the traversal cycle.

[0178] For each task to be tracked, the running information of the task to be tracked is determined, and the running information may include: kernel information, running status, scheduling start time and scheduling parameters.

[0179] The kernel information may include the kernel ID of the kernel where the task to be tracked is located. For each task to be tracked, the specific kernel ID where each task to be tracked is running is clarified.

[0180] The running state can be one of the following states: running, sleeping, stopping, zombie, D-uninterruptible sleep (D state), and dead.

[0181] The scheduling start time is the starting time point when the corresponding task to be tracked starts to be scheduled, which can represent the time of occupying the CPU.

[0182] The scheduling parameter may represent the priority of the task to be tracked, wherein the scheduling parameter may include the following information: scheduling class sched_class_lnx, scheduling policy sched_policy_lnx, and scheduling priority sched_pri_lnx.

[0183] S605: Determine whether the task to be tracked is in D state.

[0184] If the task to be tracked is not in the D state, S606 is executed.

[0185] The D state is an uninterruptible state, which means that the thread is waiting for certain conditions (such as hardware I / O) and this process cannot be interrupted.

[0186] In the embodiments of the present application, the design of the base station task itself must avoid the D state and needs to be designed to ensure that if the base station is in the D state for a long time, it indicates that there is an abnormality in the base station link. The method of killing the station and restarting it, or other abnormal protection mechanisms, such as timeout design, can be selected.

[0187] S606: Traverse the task status of other tasks on the core where the task to be tracked is located.

[0188] S607: Determine whether there is any preempted task.

[0189] If it exists, execute S608; if it does not exist, execute S611.

[0190] When the core where the task to be tracked is located is in D state, is not scheduled, and the task runs earlier than the task to be tracked, the task is considered to be preempted.

[0191] S608: Determine whether the preempted task needs to be scheduled with priority.

[0192] If yes, then execute S609. If no, then execute S606.

[0193] In the embodiment of the present application, if the preempted task holds a lock, the task needs to be scheduled preferentially, and the lock may include the following locks provided by the kernel: read-write lock, read-copy-update (Read-Copy-Update, RCU) lock, etc.

[0194] In the embodiment of the present application, when the preempted task holds the lock, there may be other tasks waiting for the lock.

[0195] S609: Raise the priority of the preempted task.

[0196] S610: Mark that the priority of the task is modified, record the preempted task, and record native scheduling information.

[0197] The modification flag of the task is set to 1, where 1 indicates that the priority of the task is modified.

[0198] Here, the native scheduling class, scheduling policy, and scheduling priority of the task are recorded in the cache space.

[0199] Continue to execute S606.

[0200] S611: Whether there is a modified task.

[0201] It is determined whether there is a task with a modification mark of 1. If so, the task with the modification mark of 1 is the task whose priority has been modified.

[0202] If it exists, execute S612; if it does not exist, execute S606.

[0203] S612: Restore the scheduling information of the modified task.

[0204] The task configuration is restored based on the recorded scheduling information of the task.

[0205] S613: Whether the task being restored is the last task on the core where the task to be tracked is located;

[0206] If not, continue to execute S606, if yes, execute S604 and continue to traverse other tasks to be tracked.

[0207] The process of S607 can be as follows Figure 7 As shown, the following steps are included:

[0208] S701, determine whether the task is in D state;

[0209] If yes, execute S702.

[0210] S702, determining whether the task is scheduled;

[0211] If not, execute S703.

[0212] S703: Check whether the scheduling start time Tcur of the task is greater than the retrieval start time Tlnx of the task to be tracked.

[0213] If yes, it is confirmed that the task is a preempted task, that is, the task to be tracked preempts the task.

[0214] In the embodiment of the present application, Tcur is the scheduling start time of one of the tasks currently being traversed, and Tlnx is the scheduling start time of the task to be tracked. In one example, task A is the task currently being traversed, and task B is the task to be tracked. Task A starts running at 0 o'clock, runs for 1 second, and is in the D state. Task B starts running at 1 o'clock, runs for 10 seconds, and is in the running state. From the timeline, task A runs first, and task B runs later. The later running task B continues to occupy CPU resources, indicating that task B has seized the resources of task A, and task B has not released the resources after occupying them, causing task A to be in a waiting resource state.

[0215] like Figure 8 As shown, S609 includes the following steps:

[0216] S801. Determine whether the scheduling class sched_class_cur of the preempted task is equal to the scheduling class sched_class_lnx of the task to be tracked.

[0217] If they are not equal, execute S802; if they are equal, execute S803.

[0218] S802: Set the scheduling class of the preempted task as the scheduling class of the task to be tracked.

[0219] Here, the scheduling classes of the two are made the same, and S803 is executed after S802.

[0220] S803: Determine whether the scheduling policy sched_policy_cur of the preempted task is the same as the scheduling policy sched_policy_lnx of the task to be tracked.

[0221] If they are not the same, execute S804; if they are the same, execute S805.

[0222] S804: Set the scheduling policy of the preempted task as the scheduling policy of the task to be tracked.

[0223] S805 . Determine whether the scheduling priority sched_pri_cur of the preempted task is less than the scheduling priority sched_pri_lnx of the task to be tracked.

[0224] If sched_pri_cur is less than sched_pri_lnx, execute S806; if it is greater than or equal to sched_pri_lnx, continue to execute S610.

[0225] S806: The scheduling priority sched_pri_cur of the preempted task is set to the scheduling priority sched_pri_lnx of the task to be tracked.

[0226] After S806 , the process continues to execute S610 .

[0227] In the second aspect, in order to implement the above-mentioned task processing method, a task processing device according to an embodiment of the present application is provided. The structural diagram of the task processing device is described below. Fig. 9 As shown, the task processing device 900 includes:

[0228] Monitoring module 901, used to traverse the running status of tasks in the system;

[0229] An adjustment module 902 is used to determine, based on the traversal result of the running status, that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled first, and adjust the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks;

[0230] The scheduling module 903 is used to schedule the second task based on the adjusted priority of the second type of task.

[0231] In some embodiments, the task processing device 900 further includes:

[0232] The first determining module is configured to determine that the system does not respond within a first time period based on the first task when the running status of the first task is running and the first task preempts the second task.

[0233] In some embodiments, the first determining module is further configured to

[0234] When the running state of the second task is an uninterruptible sleep state, the second task is not scheduled, and the scheduling start time of the second task is earlier than the scheduling start time of the first task, it is determined that the first task preempts the second task.

[0235] In some embodiments, the monitoring module 901 is further configured to:

[0236] determining a first kernel where the first task is located,

[0237] The running status of the tasks on the first core is traversed based on a specified period; wherein the second task is the task on the first core.

[0238] In some embodiments, the task processing device 900 further includes:

[0239] The second determination module is used for:

[0240] The system determines whether the second task holds a lock if the first task fails to respond within a first time period;

[0241] In the case where the second task holds the lock, it is determined that the second task needs to be scheduled preferentially.

[0242] In some embodiments, the adjustment module 902 is further configured to:

[0243] In the case where the third task is waiting for the lock held by the second task, the priority of the second type of tasks is adjusted.

[0244] In some embodiments, the adjustment module 902 is further configured to:

[0245] One or more of the scheduling class, scheduling strategy and scheduling priority of the second-category tasks are adjusted so that the priority of the second-category tasks is improved.

[0246] In some embodiments, the adjustment module 902 is further configured to:

[0247] When the priority of the scheduling class of the first type of tasks is higher than the priority of the scheduling class of the second type of tasks, adjusting the scheduling class of the second type of tasks to the scheduling class of the first type of tasks;

[0248] When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the priority of the scheduling policy of the first category of tasks is higher than the priority of the scheduling policy of the second category of tasks, adjusting the scheduling policy of the second category of tasks to the scheduling policy of the first category of tasks;

[0249] When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the scheduling strategy of the first category of tasks is the same as the scheduling strategy of the second category of tasks, adjust the scheduling priority of the second category of tasks so that the scheduling priority of the second category of tasks is equal to or higher than the scheduling priority of the first category of tasks.

[0250] In some embodiments, the task processing device further includes:

[0251] The restoration module is used to restore the priority of the second-category task to the priority before adjustment when detecting that the priority of the second-category task has been adjusted; wherein the priority of the second-category task before adjustment is lower than the priority of the first-category task.

[0252] It should be noted that the task processing device provided in the embodiment of the present application includes the various units included, which can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a CPU, a microprocessor (MPU, Micro Processor Unit), a digital signal processor (DSP, Digital Signal Processor) or a field programmable gate array (FPGA, Field-Programmable Gate Array), etc.

[0253] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0254] It should be noted that in the embodiment of the present application, if the above-mentioned task processing method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0255] In the third aspect, in order to implement the above-mentioned task processing method, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in the task processing method provided in the above-mentioned embodiment are implemented.

[0256] In a fourth aspect, an embodiment of the present application provides a storage medium, that is, a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the task processing method provided in the above embodiment are implemented.

[0257] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0258] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0259] It should be noted that, in this article, the terms "include", "comprises" or any other variations 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, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0260] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0261] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0262] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0263] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.

[0264] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0265] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A task processing method, the method comprising: Traverse the running status of tasks in the system; Determining, based on the traversal result of the running status, that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled with priority, adjusting the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks; The second tasks are scheduled based on the adjusted priorities of the second-category tasks.

2. The method according to claim 1, further comprising: When the running state of the first task is running and the first task preempts the second task, it is determined that the system does not respond within a first time period based on the first task.

3. The method according to claim 2, further comprising: When the running state of the second task is an uninterruptible sleep state, the second task is not scheduled, and the scheduling start time of the second task is earlier than the scheduling start time of the first task, it is determined that the first task preempts the second task.

4. The method according to claim 2, wherein the step of traversing the running status of tasks in the system comprises: determining a first kernel where the first task is located, The running status of the tasks on the first core is traversed based on a specified period; wherein the second task is the task on the first core.

5. The method according to any one of claims 1 to 4, further comprising: The system determines whether the second task holds a lock if the first task fails to respond within a first time period; In the case where the second task holds the lock, it is determined that the second task needs to be scheduled preferentially.

6. The method according to claim 5, wherein adjusting the priority of the second type of tasks comprises: In the case where the third task is waiting for the lock held by the second task, the priority of the second type of tasks is adjusted.

7. The method according to any one of claims 1 to 4, wherein adjusting the priority of the second type of tasks comprises: One or more of the scheduling class, scheduling strategy and scheduling priority of the second-category tasks are adjusted so that the priority of the second-category tasks is improved.

8. The method according to claim 7, wherein adjusting one or more of the scheduling class, scheduling policy and scheduling priority of the second type of tasks comprises at least one of the following: When the priority of the scheduling class of the first type of tasks is higher than the priority of the scheduling class of the second type of tasks, adjusting the scheduling class of the second type of tasks to the scheduling class of the first type of tasks; When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the priority of the scheduling policy of the first category of tasks is higher than the priority of the scheduling policy of the second category of tasks, adjusting the scheduling policy of the second category of tasks to the scheduling policy of the first category of tasks; When the scheduling class of the first category of tasks is the same as the scheduling class of the second category of tasks, and the scheduling strategy of the first category of tasks is the same as the scheduling strategy of the second category of tasks, adjust the scheduling priority of the second category of tasks so that the scheduling priority of the second category of tasks is equal to or higher than the scheduling priority of the first category of tasks.

9. The method according to any one of claims 1 to 4, further comprising: When the second-category task whose priority has been adjusted is detected, the priority of the second-category task is restored to the priority before adjustment; wherein the priority of the second-category task before adjustment is lower than the priority of the first-category task.

10. A task processing device, comprising: The monitoring module is used to traverse the running status of tasks in the system; an adjustment module, configured to determine, based on the traversal result of the running status, that the system does not respond within a first time period based on the first task, and there is a second task in the system that needs to be scheduled with priority, adjust the priority of the second category of tasks to which the second task belongs, the first task belongs to the first category of tasks, and the adjusted priority of the second category of tasks is equal to or higher than the priority of the first category of tasks; A scheduling module is used to schedule the second task based on the adjusted priority of the second type of task.