A process scheduling method and a computing device

By adding a scheduler and constructing a scheduling policy data structure using packet filters in computing devices, the problem of suboptimal scheduling by the CFS scheduler in specific scenarios is solved, user-space custom scheduling policy optimization is realized, and the flexibility and efficiency of process scheduling are improved.

CN114691339BActive Publication Date: 2026-03-27UNIONTECH SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

The existing CFS scheduler does not produce optimal scheduling results under specific scenarios and loads, and cannot customize scheduling strategies in user space according to actual scenarios and loads.

Method used

In the computing device, additional schedulers are added to the kernel through packet filters, the latest scheduling policy data structure is built and written to the shared data storage area, and the execution process is scheduled according to the latest policy data structure.

Benefits of technology

It enables users to customize scheduling strategies based on actual scenarios and loads, optimizes the passive preemption scheduling strategy, and improves the flexibility and efficiency of process scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691339B_ABST
    Figure CN114691339B_ABST
Patent Text Reader

Abstract

The application discloses a process scheduling method and a computing device, and relates to the technical field of process scheduling. The method is executed in the computing device, the operating system is run in the computing device, the kernel of the operating system comprises a packet filter and a shared data storage area, and the user space above the operating system runs an application program. The method comprises the following steps: the application program adds an additional scheduling program to the kernel by using the packet filter; the latest scheduling strategy data structure is constructed according to the current load of the computing device, the additional scheduling program is called to write the latest scheduling strategy data structure into the shared data storage area; and the additional scheduling program is called to circularly traverse the shared data storage area to obtain the latest scheduling strategy data structure, and the execution process is scheduled according to the latest scheduling strategy data structure. According to the technical scheme of the application, the execution process can be scheduled according to the scheduling strategy most suitable for the current load.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of process scheduling, and in particular to a process scheduling method and a computing device. BACKGROUND

[0002] CFS is the default scheduler for normal processes. The CFS scheduler maintains a virtual run time (vruntime) for each scheduling entity based on a red-black tree data structure, and schedules the scheduling entity with the smallest vruntime, which balances efficiency and fairness and can be applied to general-purpose scenarios. However, in some specific scenarios or specific loads, the scheduling result of CFS is not always optimal.

[0003] The existing scheduler has two main scheduling opportunities: active scheduling and passive preemption. The function of active scheduling is schedule, and the main process is to first close preemption, call the schedule function, and then open preemption. The passive preemption opportunity includes four types: returning from a system call to user mode, returning from an interrupt to user mode, kernel starting preemption, and returning from an interrupt to kernel mode.

[0004] Among them, passive preemption first judges whether the scheduling flag TIF_NEED_RESCHED exists, and if the scheduling flag exists, the schedule function may be executed to perform scheduling. The scenarios for setting the scheduling flag mainly include two types: process wake-up try_to_wake_up and periodic scheduling scheduler_tick.

[0005] The function for checking whether to preempt is check_preempt_curr, which checks whether to preempt by selecting the corresponding method in the corresponding scheduling class. For example, in the CFS scheduler, the method for checking whether to preempt in the process wake-up scenario is check_preempt_wakeup, and the method for checking whether to preempt in the periodic scheduling scenario is check_preempt_tick.

[0006] According to the existing scheduling scheme, the scheduling strategy can only be determined by the kernel, and the scheduling strategy cannot be customized in the user mode according to the current specific scenario and specific load. The scheduling opportunity of active scheduling generally does not need to be changed. For passive preemption, how to customize the scheduling strategy in the user mode according to the actual scenario and load so as to flexibly select the most suitable scheduling strategy for the current load needs to be solved.

[0007] Therefore, a process scheduling method is needed to solve the problems in the above scheme. SUMMARY

[0008] To this end, the application provides a process scheduling method to solve or at least alleviate the above problems.

[0009] According to an aspect of the application, there is provided a process scheduling method, which is executed in a computing device, wherein an operating system is running in the computing device, a kernel of the operating system comprises a packet filter and a shared data storage area, and an application program is running in a user space above the operating system, the method comprising the steps of: the application program adding an additional scheduling program to the kernel by means of the packet filter; custom-built constructing a latest scheduling policy data structure according to a current load of the computing device, calling the additional scheduling program to write the latest scheduling policy data structure into the shared data storage area; and calling the additional scheduling program to loop through the shared data storage area to obtain the latest scheduling policy data structure and schedule an execution process according to the latest scheduling policy data structure.

[0010] Optionally, in the process scheduling method according to the application, the step of obtaining the latest scheduling policy data structure and scheduling the execution process according to the latest scheduling policy data structure comprises: finding a corresponding latest scheduling policy data structure from the shared data storage area based on process identifiers of a current process and a wake-up process, determining whether there is a custom scheduling policy according to the latest scheduling policy data structure; if there is a custom scheduling policy, determining whether the wake-up process can preempt the current process according to the latest scheduling policy data structure; and if the wake-up process can preempt the current process, setting a scheduling flag for the wake-up process so as to schedule the execution of the wake-up process.

[0011] Optionally, in the process scheduling method according to the application, the step of determining whether there is a custom scheduling policy according to the latest scheduling policy data structure further comprises: if there is no custom scheduling policy, determining a new minimum wake-up scheduling time interval according to the latest scheduling policy data structure; judging whether a difference between virtual running times of the current process and the wake-up process is greater than the new minimum wake-up scheduling time interval; and if the difference is greater than the new minimum wake-up scheduling time interval, setting a scheduling flag for the wake-up process so as to schedule the execution of the wake-up process.

[0012] Optionally, in the process scheduling method according to the application, the shared data storage area adopts a Map data structure to establish and store a mapping relationship between a process data structure and a scheduling policy data structure; wherein the process data structure comprises process identifiers of the current process and the wake-up process; and the scheduling policy data structure comprises a custom scheduling policy writing state, a state of whether preemption is allowed, and a new minimum wake-up scheduling time interval.

[0013] Optionally, in the process scheduling method according to the present application, the step of obtaining the latest scheduling policy data structure and scheduling the execution of a process according to the latest scheduling policy data structure comprises: searching for a corresponding latest scheduling policy data structure from a shared data storage area based on the process identification of a current process, determining whether there is a self-defined scheduling policy according to the latest scheduling policy data structure, determining whether the current process can be preempted according to the latest scheduling policy data structure if there is a self-defined scheduling policy, and setting a scheduling flag so as to schedule the execution of a next process if the current process can be preempted.

[0014] Optionally, in the process scheduling method according to the present application, the step of determining whether there is a self-defined scheduling policy according to the latest scheduling policy data structure further comprises: determining a new minimum scheduling time interval according to the latest scheduling policy data structure if there is no self-defined scheduling policy, determining whether the actual running time of the current process is greater than the theoretical running time of the current process, and setting a scheduling flag so as to schedule the execution of a next process if the actual running time of the current process is greater than the theoretical running time.

[0015] Optionally, in the process scheduling method according to the present application, the step of determining whether the actual running time of the current process is greater than the theoretical running time of the current process further comprises: determining whether the actual running time of the current process is greater than the new minimum scheduling time interval if the actual running time of the current process is less than or equal to the theoretical running time of the current process, determining whether the difference between the virtual running time of the current process and the virtual running time of the next process is greater than the theoretical running time of the current process if the actual running time of the current process is greater than the new minimum scheduling time interval, and setting a scheduling flag so as to schedule the execution of a next process if the difference is greater than the theoretical running time of the current process.

[0016] Optionally, in the process scheduling method according to the present application, the shared data storage area adopts a Map data structure to establish and store the mapping relationship between a process data structure and a scheduling policy data structure; wherein, the process data structure comprises the process identification of a current process; and the scheduling policy data structure comprises a self-defined scheduling policy writing state, a state of whether preemption is allowed, and a new minimum scheduling time interval.

[0017] According to an aspect of the present application, there is provided a computing device comprising: at least one processor; a memory storing program instructions configured to be executed by the at least one processor, the program instructions comprising instructions for performing the process scheduling method as described above.

[0018] According to an aspect of the present application, there is provided a readable storage medium storing program instructions, which, when read and executed by a computing device, cause the computing device to perform the process scheduling method as described above.

[0019] According to the technical solution of the present application, a process scheduling method is provided, in which an application program running in a user space can set a personalized scheduling strategy according to a current load. The application program running in the user space adds an additional scheduling program to a kernel by using a packet filter, and then can customize and construct a latest scheduling strategy data structure according to a current load of the computing device and write the latest scheduling strategy data structure into a shared data storage area of the kernel. In this way, the additional scheduling program can schedule an execution process according to the latest scheduling strategy data structure that is most suitable for the current load, so as to optimize the method of checking whether to preempt according to an existing scheduling strategy based on passive preemption. Moreover, the process scheduling method according to the present application does not need to restart an operating system or close an application program.

[0020] The above description is only a summary of the technical solution of the present application. In order to enable one skilled in the art to better understand the technical means of the present application and to implement the same according to the contents of the description, and in order to enable the above and other purposes, features and advantages of the present application to be more apparent and understandable, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS

[0021] To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings. These aspects are indicative of various ways in which the principles disclosed herein can be practiced and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The foregoing and other objects, features, and advantages of the disclosure will be apparent from the following description of certain aspects as taken in connection with the accompanying drawings in which like reference characters refer to the same elements throughout. The following detailed description is set forth by way of example with reference to the figures.

[0022] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present application is shown;

[0023] Figure 2 A flowchart of a process scheduling method 200 according to an embodiment of the present application is shown;

[0024] Figure 3 A flowchart of scheduling an execution process in a process wake-up scenario according to an embodiment of the present application is shown;

[0025] Figure 4 A flowchart of scheduling an execution process in a periodic scheduling scenario according to an embodiment of the present application is shown;

[0026] Figure 5 A hardware structure schematic diagram of a computing device 100 according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0027] Exemplary embodiments of the present disclosure will be described in greater detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure can be more thoroughly understood, and so that the scope of the present disclosure can be completely conveyed to those skilled in the art.

[0028] According to the process scheduling scheme of the present disclosure, for passive preemption, a scheduling policy can be self-defined according to actual scenarios and loads in user mode, so as to schedule execution processes using the scheduling policy most suitable for the current load.

[0029] In specific embodiments of the present disclosure, only the CFS scheduler is taken as an example to specifically describe how to self-define a scheduling policy according to the current load to affect the original passive preemption-based scheduling policy (including the check_preempt_wakeup method for checking whether to preempt in the process wake-up scenario, and the check_preempt_tick method for checking whether to preempt in the periodic scheduling scenario). However, it should be pointed out that the process scheduling scheme of the present disclosure is not limited to the specific scheduling policy based on passive preemption provided in the embodiments.

[0030] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present disclosure is shown.

[0031] As shown in Figure 1 The computing device 100 runs an operating system, and the operating system of the computing device 100 includes a kernel 120. A user space 110 is arranged above the operating system, and the user space 110 can run one or more application programs 111. The application programs 111 of the user space 110 can communicate with the kernel 120 through system calls.

[0032] The kernel 120 includes a packet filter 123, and the packet filter can be instrumented in the kernel. In this way, the application programs 111 running in the user space can use the packet filter 123 to add an additional scheduling program 124 for the present disclosure to the kernel 120 of the operating system. Moreover, the additional scheduling program can be run in the kernel 120 based on the packet filter 123.

[0033] In an implementation, the packet filter 123 can be implemented as an eBPF (Extended Berkeley Packet Filter) for example.

[0034] According to an embodiment of the present application, the kernel 120 further comprises a shared data storage area 125 for data sharing with the user space 110, which can adopt a Map data structure to establish a mapping relationship between processes and scheduling policies based on Key and Value.

[0035] According to an embodiment of the present application, the application 111 can customize the latest scheduling policy data structure according to the current load of the computing device 100, and invoke the additional scheduling program 124 to write the customized latest scheduling policy data structure into the shared data storage area 125 in the kernel 120.

[0036] The application 111 iterates through the shared data storage area 125 by invoking the additional scheduling program 125 in the kernel, so as to check whether the shared data storage area has added the latest scheduling policy data structure, and the additional scheduling program 125 schedules the execution process according to the latest scheduling policy data structure when it is found that the shared data storage area has added the latest scheduling policy data structure. It can be understood that scheduling the execution process means allocating the time of occupying the CPU to the process, so as to execute the process through the CPU.

[0037] In an embodiment according to the present application, the computing device 100 is configured to execute the process scheduling method 200 according to the present application. The computing device can realize self-customization of the scheduling policy according to the actual scene and load in the user space by executing the process scheduling method 200 according to the present application.

[0038] Figure 2 A flowchart of the process scheduling method 200 according to an embodiment of the present application is shown. The method 200 is suitable for execution in a computing device (for example, the aforementioned computing device 100).

[0039] The computing device 100 according to the present application runs an operating system, and the user space 110 is arranged above the operating system, which can run one or more application programs 111. The kernel 120 of the operating system comprises a packet filter 123, and a shared data storage area 125 for data sharing with the user space.

[0040] It should be noted that in the specific embodiments of the present application, only the CFS scheduler is taken as an example to specifically describe how to customize the scheduling policy according to the current load to affect the original scheduling policy based on passive preemption (including the method check_preempt_wakeup for checking whether to pre-empt in the process wake-up scenario, and the method check_preempt_tick for checking whether to pre-empt in the periodic scheduling scenario). However, it should be pointed out that the process scheduling method 200 of the present application is not limited to the specific scheduling policy based on passive preemption provided in the embodiments.

[0041] As Figure 2 shown, the method 200 starts from step S210.

[0042] In step S210, the application program 111 running in the user space adds the additional scheduling program 124 to the kernel 120 of the operating system by using the packet filter 123. After that, the application program 111 can call the additional scheduling program 124 in the kernel to update or access the data stored in the shared data storage area in the kernel.

[0043] In step S220, the application program 111 can customize the latest scheduling policy data structure according to the current load of the computing device 100, and call the additional scheduling program 124 to write the built latest scheduling policy data structure into the shared data storage area 125 in the kernel.

[0044] It should be noted that the shared data storage area 125 established in the kernel can realize the data sharing between the kernel and the user space. In an embodiment, the shared data storage area adopts a Map data structure, and a mapping relationship between the process and the scheduling policy is established based on Key and Value.

[0045] In an implementation, the Key can be implemented as a process data structure. The Value can be implemented as a scheduling policy data structure (struct preempt) associated with the process data structure. That is, the shared data storage area can adopt a Map data structure to establish and store the mapping relationship between the process data structure and the scheduling policy data structure (struct preempt). The scheduling policy data structure (struct preempt) can include a customized scheduling policy writing state (state), a state whether to be preempted (decide), and a new minimum wake-up scheduling time interval (granularity).

[0046] In step S230, the application program 111 calls the additional scheduling program 125 to loop through the shared data storage area in the kernel, so as to check whether the shared data storage area is newly added with the latest scheduling policy data structure. When it is determined that the shared data storage area is newly added with the latest scheduling policy data structure, the additional scheduling program 125 acquires the latest scheduling policy data structure, and schedules the execution process according to the latest scheduling policy data structure. It can be understood that scheduling the execution process is to allocate the time of occupying the CPU to the process, so as to execute the process by the CPU.

[0047] In an implementation, for the process wake-up scenario, the shared data storage area adopts a Map data structure to establish and store the mapping relationship between the process data structure (struct wakeup) and the scheduling policy data structure (struct preempt). The process data structure struct wakeup includes the process identifiers of the current process and the wake-up process. The scheduling policy data structure (struct preempt) can include a custom scheduling policy writing state (state), a state of whether preemption is allowed (decide), and a new minimum wake-up scheduling time interval (granularity).

[0048] Figure 3 A flowchart of scheduling an execution process in a process wake-up scenario according to an embodiment of the present application is shown.

[0049] In the process wake-up scenario, after the process that needs to be woken up is added to the running queue of the CPU and the process is woken up, when it is checked whether preemption is performed, the following can be performed. Figure 3 Step S230 is performed in the flow shown. Specifically, as shown in Figure 3 The corresponding latest scheduling policy data structure can be found from the shared data storage area based on the process identifiers of the current process (i.e., the process being run) and the wake-up process, and it is determined whether there is a custom scheduling policy according to the latest scheduling policy data structure corresponding to the current process and the wake-up process that is found. Here, it can be specifically determined whether there is a custom scheduling policy according to the custom scheduling policy writing state state in the latest scheduling policy data structure, that is, it is determined whether the original scheduling policy needs to be changed.

[0050] If there is a custom scheduling policy (the original scheduling policy needs to be changed), it is further determined whether the wake-up process can preempt the current process according to the latest scheduling policy data structure. Here, it can be specifically determined whether the wake-up process can preempt the current process according to the state of whether preemption is allowed decide in the latest scheduling policy data structure.

[0051] If it is determined that the current process can be preempted, a scheduling flag is set for the wake-up process so as to schedule the execution of the wake-up process. Here, by setting the scheduling flag for the wake-up process, the wake-up process can preempt the current process so as to execute the wake-up process preferentially. In an implementation, the wake-up process preempts the current process can be implemented by resched_curr.

[0052] If there is no self-defined scheduling policy, the original scheduling policy is not changed, and a new minimum wakeup scheduling time interval needs to be determined according to the granularity in the latest scheduling policy data structure. Then it is judged whether the new minimum scheduling time interval is greater than 0. If the minimum scheduling time interval is less than or equal to 0, the process is scheduled based on the original minimum scheduling time interval. In the case where the new minimum wakeup scheduling time interval is greater than 0, the new minimum wakeup scheduling time interval is updated and set (replaces the original minimum wakeup scheduling time interval) so as to schedule the process according to the new minimum wakeup scheduling time interval. Here, before the new minimum wakeup scheduling time interval is updated and set, the original minimum wakeup scheduling time interval needs to be saved.

[0053] Then, it is judged whether the virtual running time (vruntime) of the current process is greater than the virtual running time of the wakeup process. If yes, the difference between the virtual running time of the current process and the virtual running time of the wakeup process is further calculated, and it is judged whether the difference between the virtual running time of the current process and the virtual running time of the wakeup process is greater than the new minimum wakeup scheduling time interval.

[0054] If the difference between the virtual running time of the current process and the virtual running time of the wakeup process is greater than the new minimum wakeup scheduling time interval, a scheduling flag (TIF_NEED_RESCHED) is set for the wakeup process so as to schedule and execute the wakeup process.

[0055] On the contrary, if the difference between the virtual running time of the current process and the virtual running time of the wakeup process is less than or equal to 0, or if the difference between the virtual running time of the current process and the virtual running time of the wakeup process is less than or equal to the new minimum wakeup scheduling time interval, the scheduling flag is not set to execute scheduling.

[0056] Finally, the original minimum wakeup scheduling time interval is restored.

[0057] It can be understood that the scheduling flag is set to indicate that there is currently a process that needs to be run preferentially, so that when the next scheduling opportunity occurs, the corresponding process is scheduled by checking the scheduling flag.

[0058] It should be noted that the new minimum wakeup scheduling time interval set in the latest scheduling policy data structure can affect the process scheduling frequency, i.e. the process preemption frequency. Only when the difference between the virtual running time of the current process and the virtual running time of the wakeup process is greater than the new minimum wakeup scheduling time interval, the scheduling flag is set. In this way, the system overhead caused by the frequency switching process is avoided as much as possible.

[0059] Thus, according to the method 200 of the present application, after the application program adds the additional scheduler to the kernel by using the packet filter, the latest scheduling policy data structure can be built and written into the shared data storage area of the kernel according to the current load of the computing device, so that the additional scheduler can schedule the execution process according to the latest scheduling policy data structure suitable for the current load, and the method check_preempt_wakeup of checking whether to preempt in the original scheduling policy based on passive preemption in the process wake-up scenario is optimized.

[0060] In an implementation, for the periodic scheduling scenario, the shared data storage area adopts a Map data structure to establish and store the mapping relationship between the process data structure (struct tick) and the scheduling policy data structure (struct preempt). The process data structure struct tick includes the process identifier (pid) of the current process. The scheduling policy data structure (struct preempt) can include the custom scheduling policy writing state (state), the state of whether to preempt (decide), and the new minimum wake-up scheduling time interval (granularity).

[0061] Figure 4 A flowchart of scheduling an execution process in a periodic scheduling scenario according to an embodiment of the present application is shown.

[0062] In the periodic scheduling scenario, when checking whether to preempt, the following can be performed: Figure 4 The step S230 is performed in the flow shown. Specifically, as shown in Figure 4 the corresponding latest scheduling policy data structure of the current process (i.e., the running process) can be found from the shared data storage area, and whether to have a custom scheduling policy is determined according to the latest scheduling policy data structure corresponding to the current process. Here, whether to have a custom scheduling policy can be specifically determined according to the custom scheduling policy writing state state in the latest scheduling policy data structure, that is, whether to change the original scheduling policy.

[0063] If there is a custom scheduling policy (the original scheduling policy needs to be changed), whether to preempt the current process is further determined according to the latest scheduling policy data structure. Here, whether to preempt the current process can be specifically determined according to the state of whether to preempt decide in the latest scheduling policy data structure.

[0064] If it is determined that the current process can be preempted, a scheduling flag is set so as to schedule the execution of the next process. Here, by setting the scheduling flag for the next process, the current process can be preempted by the next process so as to give priority to the execution of the next process. In one implementation, the preemption of the current process by the next process can be implemented by resched_curr.

[0065] If there is no self-defined scheduling policy, the original scheduling policy is not changed, and a new minimum scheduling time interval needs to be determined according to the granularity in the latest scheduling policy data structure. Then, it is determined whether the new minimum scheduling time interval is greater than 0. If the minimum scheduling time interval is less than or equal to 0, the process is scheduled based on the original minimum scheduling time interval. In the case where the new minimum scheduling time interval is greater than 0, the new minimum scheduling time interval is updated and set (replaces the original minimum scheduling time interval) so as to schedule the process according to the new minimum scheduling time interval. Here, before the new minimum scheduling time interval is updated and set, the original minimum scheduling time interval needs to be saved.

[0066] Then, the theoretical running time of the current process is calculated, and the actual running time of the current process is calculated. It is determined whether the actual running time of the current process is greater than the theoretical running time of the current process. Here, the theoretical running time of the process is the time that the process should run.

[0067] If it is greater than the theoretical running time (the current process runs overtime), a scheduling flag is set so as to schedule the execution of the next process.

[0068] It should be noted that the next process scheduled for execution refers to the highest priority process in the run queue, i.e., the process with the smallest virtual running time (vruntime) in the run queue of the periodic scheduling, i.e., the leftmost node process in the run queue. It can be understood that the smaller the vruntime of the process, the more left the position of the process in the red-black tree data structure of the scheduler; on the contrary, the larger the vruntime of the process, the more right the position of the process in the red-black tree data structure. The smaller the vruntime of the process, the less time the process occupies the CPU before, and the higher the priority of the process.

[0069] In addition, if the actual running time of the current process is less than or equal to the theoretical running time of the current process, it is determined whether the actual running time of the current process is greater than the new minimum scheduling time interval. If not (the actual running time of the current process is less than or equal to the new minimum scheduling time interval), the scheduling flag is no longer set to perform scheduling.

[0070] If the actual running time of the current process is greater than the new minimum scheduling interval, the difference between the virtual running time of the current process and the next process is calculated, and it is determined whether the difference between the virtual running time of the current process and the next process is greater than or equal to 0. If the difference is greater than or equal to 0, it is further determined whether the difference between the virtual running time of the current process and the next process is greater than the theoretical running time of the current process.

[0071] If the difference between the virtual runtime of the current process and the next process is greater than the theoretical runtime of the current process, a scheduling flag is set to schedule the next process for execution. Here, by setting the scheduling flag for the next process, the current process can be preempted by the next process, allowing the next process to execute first. In one implementation, `resched_curr` can be used to achieve this preemption of the current process by the next process.

[0072] Additionally, if the difference between the virtual runtime of the current process and the next process is less than 0, or if the difference between the virtual runtime of the current process and the next process is less than or equal to the theoretical runtime of the current process, then the scheduling flag will not be set to perform scheduling.

[0073] Finally, restore the original minimum scheduling interval.

[0074] Thus, according to the method 200 of the present invention, after the application adds the additional scheduler to the kernel using the packet filter, it can customize and construct the latest scheduling policy data structure according to the current load of the computing device and write it to the kernel's shared data storage area. In this way, the additional scheduler can schedule the execution process according to the latest scheduling policy data structure suitable for the current load. The method check_preempt_tick for checking whether preemption should be performed in the original passive preemption-based scheduling policy in the periodic scheduling scenario has been optimized.

[0075] Figure 5 A schematic diagram of the hardware structure of a computing device 100 according to an embodiment of the present invention is shown. Figure 5 As shown, the computing device 100 may include an input device 90, a processor 91, an output device 92, a memory 93, and at least one communication bus 94. The communication bus 94 is used to realize communication connections between components. The memory 93 may include high-speed RAM memory, and may also include non-volatile memory (NVM), such as at least one disk storage device. The memory 93 may store various program instructions for performing various processing functions and implementing the process scheduling method in the embodiments of the present invention.

[0076] Optionally, the processor 91 can be implemented as a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a controller, a microcontroller, a microprocessor or other electronic devices, which can be coupled to the input device 90 and the output device 92 through a wired or wireless connection.

[0077] Optionally, the input device 90 can include various input devices, such as at least one of a user interface facing a user, a device interface facing a device, a programmable interface of software, a camera, and a sensor. Optionally, the device interface facing a device can be a wired interface for data transmission between devices, and can also be a hardware insertion interface (such as a USB interface, a serial port, etc.) for data transmission between devices. Optionally, the user interface facing a user can be, for example, a user interface facing a user, a voice input device for receiving voice input, and a touch sensing device (such as a touch screen with touch sensing function, a touchpad, etc.) for receiving user touch input. Optionally, the programmable interface of software can be, for example, an entry for user to edit or modify a program, such as an input pin interface or an input interface of a chip, etc. Optionally, the transceiver can be a radio frequency transceiver chip, a baseband processing chip, and a transceiving antenna with communication function, etc. The audio input device such as a microphone can receive voice data. The output device 92 can include a display, a sound device, etc.

[0078] In an embodiment of the present application, the computing device 100 includes one or more processors, and one or more readable storage media storing program instructions. When the program instructions are configured to be executed by the one or more processors, the computing device performs the process scheduling method in the embodiment of the present application.

[0079] According to the process scheduling method 200 of the present application, the application program in the user space can set a personalized scheduling strategy for the current load. Wherein, the application program running in the user space adds an additional scheduling program to the kernel by using a packet filter, and then can customize and build a latest scheduling policy data structure according to the current load of the computing device and write it into the shared data storage area of the kernel. In this way, the additional scheduling program can schedule the execution process according to the latest scheduling policy data structure most suitable for the current load, so as to optimize the existing method of checking whether to preempt based on passive preemption of the scheduling strategy. Moreover, the process scheduling method of the present application does not need to restart the operating system or close the application program.

[0080] The various techniques described herein can be implemented in connection with hardware or software or, where appropriate, with a combination of both. Thus, the methods and apparatus of the present application, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard disks, USB flash drives, optical tapes, CD-ROMs, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the subject application.

[0081] Where a program code is executed on a programmable computer, the mobile terminal generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute instructions in the program code stored in the memory to perform the process scheduling method of the present application.

[0082] In the context of this document, a "storage medium" can be any physical medium that stores data and / or instructions for use by an instruction execution system. The storage medium can have stored therein computer software or a computer program that can be implemented on the instruction execution system. In the context of this document, a "computer-readable medium" can be any physical medium that stores instructions that can be executed by a computer or that causes a computer to perform any one or more of the operations described herein. The computer-readable medium can be, but is not limited to, ROM, RAM, flash memory, CD-ROMs, optical hard drives, or other storage devices.

[0083] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to avoid obscuring the understanding of this description.

[0084] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to avoid obscuring the understanding of this description.

[0085] Similarly, it is to be understood that the embodiments of the present application can be alternately grouped together in a single embodiment, figure, or description of embodiments, for the purpose of brevity and clarity. However, none of the disclosure should be construed as reflecting an intention that the application of the claimed application is limited to less than all embodiments set forth in each and every claim.

[0086] Those skilled in the art understand that the modules or units or components of the devices in the examples disclosed herein can be arranged in the devices as described in the examples, or alternatively can be located in one or more devices different from the devices in the examples. The modules in the foregoing examples can be combined into one module or further divided into multiple sub-modules.

[0087] Those skilled in the art understand that the modules in the devices in the examples can be adaptively changed and arranged in one or more devices different from the examples. The modules or units or components in the examples can be combined into one module or unit or component, and further divided into multiple sub-modules or sub-units or sub-components. All features disclosed in this specification (including the claims, abstract, and drawings) and all methods disclosed in this specification can be combined in any combination, except where such features and / or processes are mutually exclusive. Each feature disclosed in this specification (including the claims, abstract, and drawings) can be replaced by alternative features providing the same, equivalent, or similar functionality unless otherwise stated.

[0088] Further, those skilled in the art understand that although some of the examples described herein include certain features of other examples but not others, combinations of features of the different examples are contemplated within the scope of the application and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.

[0089] Further, some of the examples described herein are described as a combination of methods or method elements implemented by a processor of a computer system or by other means for performing the functions described by the elements of the methods. Accordingly, the processor with the necessary instructions for performing such methods or method elements forms the means for performing the method or method elements. Further, the elements of the means for performing the functions described herein are examples of means for performing the functions described by the elements of the methods.

[0090] As used herein, unless otherwise indicated, the use of the ordinal adjectives "first", "second", "third", etc., are to add specificity and difference to a term, and are not intended to indicate a temporal or chronological order or sequence. A term that is used in more than one place in this specification should be interpreted not to pick up unique meanings because of its use in various places, unless it is otherwise indicated.

[0091] While the present application has been described in connection with limited number of embodiments, those skilled in the art will appreciate that numerous modifications and variations therefrom can be made without departing from the scope of the present application as set forth in the limitations to follow. Moreover, the language used in this specification has been principally selected for readability and instructional purposes and can not have been selected to delineate or circumscribe the subject application. Accordingly, the disclosure of the present application is intended to be illustrative, but not limiting, of the scope of the application, which is set forth in the following limitations.

Claims

1. A process scheduling method, executed in a computing device, wherein an operating system is running in the computing device, a kernel of the operating system comprising a packet filter, a shared data storage area, the shared data storage area adopting a Map data structure to establish and store a mapping relationship between a process data structure and a scheduling policy data structure, wherein, The process data structure includes process identifiers of a current process and a wake-up process, and the scheduling policy data structure includes a custom scheduling policy writing state, a state of whether preemption is allowed, and a new minimum wake-up scheduling time interval (granularity). An application program runs in a user space above the operating system. The method includes the steps of: The application program adds an additional scheduling program to the kernel using a packet filter; A latest scheduling policy data structure is custom-built according to a current load of the computing device, and the additional scheduling program is called to write the latest scheduling policy data structure to the shared data storage area; and The additional scheduling program is called to loop through the shared data storage area to obtain a latest scheduling policy data structure, and a scheduling execution process is scheduled according to the latest scheduling policy data structure, which is used to allocate time for a process to occupy a CPU so as to execute the process by the CPU. In a process wake-up scenario, the step of obtaining the latest scheduling policy data structure and scheduling the execution process according to the latest scheduling policy data structure includes: searching for a corresponding latest scheduling policy data structure from the shared data storage area based on process identifiers of a current process and a wake-up process, determining whether there is a custom scheduling policy according to the latest scheduling policy data structure, determining whether the wake-up process can preempt the current process according to the latest scheduling policy data structure if there is a custom scheduling policy, setting a scheduling flag for the wake-up process to schedule the execution of the wake-up process if the wake-up process can preempt the current process, determining a new minimum wake-up scheduling time interval according to the latest scheduling policy data structure if there is no custom scheduling policy, judging whether a difference between a virtual running time of the current process and a virtual running time of the wake-up process is greater than the new minimum wake-up scheduling time interval, and setting the scheduling flag for the wake-up process to schedule the execution of the wake-up process if the difference is greater than the new minimum wake-up scheduling time interval. In a periodic scheduling scenario, the step of obtaining the latest scheduling policy data structure and scheduling the execution process according to the latest scheduling policy data structure includes: searching for a corresponding latest scheduling policy data structure from the shared data storage area based on a process identifier of a current process, determining whether there is a custom scheduling policy according to the latest scheduling policy data structure, determining whether preemption of the current process is allowed according to the latest scheduling policy data structure if there is a custom scheduling policy, setting a scheduling flag to schedule the execution of a next process if preemption of the current process is allowed, determining a new minimum scheduling time interval according to the latest scheduling policy data structure if there is no custom scheduling policy, judging whether an actual running time of the current process is greater than a theoretical running time of the current process, and setting the scheduling flag to schedule the execution of the next process if the actual running time of the current process is greater than the theoretical running time of the current process.

2. The method of claim 1, wherein, The step of judging whether the actual running time of the current process is greater than the theoretical running time of the current process further includes: if the actual running time of the current process is less than or equal to the theoretical running time of the current process, determining whether the actual running time of the current process is greater than the new minimum scheduling time interval; if greater than the new minimum scheduling time interval, determining whether a difference between the virtual running time of the current process and the next process is greater than the theoretical running time of the current process; if the difference is greater than the theoretical running time of the current process, setting a scheduling flag to schedule execution of the next process.

3. A computing device comprising: at least one processor; and a memory storing program instructions configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-2.

4. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-2. ​