Task scheduling method and device, terminal and storage medium

By considering the priority of fair tasks and undesirable interruption in the Linux system, the problem of the inability to provide special priority processing for fair tasks in the customized system in the prior art is solved, and a better real-time task selection effect is achieved.

CN119938240APending Publication Date: 2025-05-06BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311460991.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-06
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

The existing Linux system does not consider the differences in normal priority tasks on the CPU when selecting real-time tasks, which makes it impossible to provide special priority processing for fair tasks in customized systems.

Method used

By determining the first priority of the real-time task, selecting a central processor combination with a priority lower than that priority, further excluding the central processors with undesirable interruption from the combination, obtaining the final central processor combination, and selecting the central processor running the real-time task in the combination.

Benefits of technology

It is realized that when selecting real-time tasks, the differences between fair tasks are taken into account, and the differences between fair tasks are avoided and unimportant fair tasks are obtained, thereby obtaining better selection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938240A_ABST
    Figure CN119938240A_ABST
Patent Text Reader

Abstract

The invention provides a task scheduling method and device, a terminal and a storage medium. The task scheduling method comprises the following steps: receiving a real-time task; a central processing unit for operation is selected for the real-time task, and the central processing unit for operation is selected for the real-time task and comprises the steps that a first priority corresponding to the real-time task is determined; determining a first combination of the central processing units of which the priorities of the running tasks are lower than the first priority; determining a second combination of the central processing units with tasks which are not expected to be interrupted on the task queue from the first combination, and when the first combination is different from the second combination, removing the central processing units in the second combination from the first combination to obtain a third combination of the central processing units, selecting a central processing unit for running a real-time task from the third combination; and running the real-time task on the selected central processing unit. According to the method disclosed by the invention, the difference between the tasks is considered during real-time task kernel selection, and important tasks can be prevented from being preempted in an inclined manner, but unimportant tasks can be preempted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of information technology, and in particular to a task scheduling method and device, a terminal and a storage medium. Background Art

[0002] Linux tasks are divided into stop tasks, rt tasks, deadline tasks, fair tasks, and idle tasks. Each type of task corresponds to a separate task scheduler. When the central processing unit (CPU) initiates task scheduling when idle, it checks the task status of the CPU waiting queue in the order of stop, rt, deadline, fair, and idle to execute the task. Most tasks are fair tasks, which follow the fairness principle of the completely fair scheduler (CFS) and divide the CPU time in proportion according to priority. The priority of fair tasks is 100 to 139, including 40 different priorities. A small number of tasks are rt (real-time) tasks. The rt task scheduler selects the CPU with the lowest priority of the currently running task to preempt. The current task priority classification includes idle, fair, and rt (0 to 99). For fair tasks, the priority of fair is not distinguished.

[0003] In some cases, special tags are set for tasks according to their importance and business stages. Tasks with special tags enjoy customized task priorities in specific running stages. Such customized priorities are not considered when selecting cores in RT. For example, when selecting cores in RT, a fair task is run on CPU4 and CPU5 respectively. The importance of these two fair tasks is the same for native Linux RT core selection, and one fair task will not be preempted just because it is more important to the business. Summary of the invention

[0004] To solve the existing problems, the present disclosure provides a task scheduling method and device, a terminal and a storage medium.

[0005] The present disclosure adopts the following technical solutions.

[0006] An embodiment of the present disclosure provides a task scheduling method, which includes: receiving a real-time task; selecting a central processing unit to run the real-time task, wherein selecting a central processing unit to run the real-time task includes: determining a first priority corresponding to the real-time task; determining a first combination of central processing units whose priorities of the running tasks are lower than the first priority; determining from the first combination a second combination of central processing units on a task queue where there are tasks that are not expected to be interrupted, and when the first combination is the same as the second combination, selecting a central processing unit to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processing units in the second combination from the first combination to obtain a third combination of central processing units, and selecting a central processing unit to run the real-time task from the third combination; and running the real-time task on the selected central processing unit.

[0007] Another embodiment of the present disclosure provides a task scheduling device, the control device comprising: a task receiving module, configured to receive a real-time task; a processor selection module, configured to select a central processor to run for the real-time task, wherein selecting a central processor to run for the real-time task comprises: determining a first priority corresponding to the real-time task; determining a first combination of central processors whose priorities of the running tasks are lower than the first priority; determining from the first combination a second combination of central processors on a task queue where there are tasks that are not expected to be interrupted, and when the first combination is the same as the second combination, selecting a central processor to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processors in the second combination from the first combination to obtain a third combination of central processors, and selecting a central processor to run the real-time task from the third combination; a task running module, configured to run the real-time task on the selected central processor.

[0008] In some embodiments, the present disclosure provides a terminal, comprising: at least one memory and at least one processor; wherein the memory is used to store program codes, and the processor is used to call the program codes stored in the memory to execute the above-mentioned task scheduling method.

[0009] In some embodiments, the present disclosure provides a storage medium, wherein the storage medium is used to store program code, and the program code is used to execute the above-mentioned task scheduling method.

[0010] The present invention determines from a first combination a second combination of central processors having tasks on a task queue that are not expected to be interrupted, and when the first combination is the same as the second combination, selects a central processor for running real-time tasks from the first combination; when the first combination is different from the second combination, removes the central processors in the second combination from the first combination to obtain a third combination of central processors, and selects a central processor for running real-time tasks from the third combination. In this way, the differences between tasks are taken into account when performing real-time task core selection, and it is possible to tend not to preempt important tasks but to preempt unimportant tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.

[0012] Figure 1 It is a flowchart of a task scheduling method according to an embodiment of the present disclosure.

[0013] Figure 2 A schematic flowchart of task scheduling for queueing tasks according to some embodiments of the present disclosure is shown.

[0014] Figure 3 A schematic flowchart of task dequeue scheduling of some embodiments of the present disclosure is shown.

[0015] Figure 4 A schematic flowchart of load-balanced task scheduling according to some embodiments of the present disclosure is shown.

[0016] Figure 5 A schematic flowchart of core selection for real-time tasks according to some embodiments of the present disclosure is shown.

[0017] Figure 6 It is a partial module of a task scheduling device according to another embodiment of the present disclosure.

[0018] Figure 7 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0020] It should be understood that the various steps described in the method embodiments of the present disclosure can be performed in sequence and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0021] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0022] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0023] It should be noted that the modification of “one” mentioned in the present disclosure is illustrative rather than restrictive, and those skilled in the art should understand that it should be understood as “one or more” unless otherwise clearly indicated in the context.

[0024] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0025] The current Linux real-time task (rt task) does not consider the differences of normal priority tasks on the CPU when selecting cores. For example, all normal priority tasks have an index of CPUPRI_NORMAL=1 in cpupri pri_to_cpu, ignoring the differences between different normal priority tasks, and not considering special priority settings for customized system fair tasks. The purpose of the present disclosure is to consider the differences between fair tasks when selecting rt cores, so that when selecting cores for rt tasks, when selecting CPUs that are also running fair tasks, they tend not to preempt important fair tasks, but to preempt unimportant fair tasks.

[0026] Figure 1 A flowchart of a task scheduling method of an embodiment of the present disclosure is provided. The task scheduling method of the present disclosure may include step S101, receiving a real-time task. In some embodiments, the real-time task is an rt task in a linux task, and the real-time task requests scheduling.

[0027] In some embodiments, the method disclosed herein may further include step S102, selecting a CPU to run for the real-time task. In some embodiments, the received real-time task is a task that requests scheduling, and a core selection is required for the real-time task, that is, a CPU core to run is selected for the real-time task.

[0028] In some embodiments, selecting a central processor to run for a real-time task includes: determining a first priority corresponding to the real-time task; determining a first combination of central processors whose priority of the running task is lower than the first priority; determining from the first combination a second combination of central processors whose tasks are not expected to be interrupted on the task queue, when the first combination is the same as the second combination, selecting a central processor to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processors in the second combination from the first combination to obtain a third combination of central processors, and selecting a central processor to run the real-time task from the third combination. In some embodiments, the priority of the rt task is 0-99, and the priority of the fair task is 100-139. First, determine the first priority corresponding to the real-time task, for example, assuming that the first priority corresponding to the real-time task is 50. Then, determine the first combination of central processors whose priority of the running task is lower than the first priority, for example, assuming that the system has a total of 8 central processors, that is, eight cores, and tasks numbered 0-7 and with priorities of 51-139 run on central processors numbered 0, 2, 3, and 6, then the first combination of central processors includes CPU0, CPU2, CPU3, and CPU6.

[0029] Afterwards, a second combination of central processors having tasks that are not expected to be interrupted on the task queue is determined from the first combination. For example, assuming that there are tasks with special priority settings or special marks on the task queue of CPU0, that is, tasks that are not expected to be interrupted, the second combination includes CPU0. At this time, the first combination and the second combination are not the same. Therefore, the central processors in the second combination are removed from the first combination to obtain a third combination of central processors (for example, including CPU2, CPU3 and CPU6), and the central processor for running real-time tasks is selected from the third combination. In some embodiments, the central processor for running real-time tasks can be selected from the third combination in order or according to existing core selection rules, for example, CPU2 is selected. In some embodiments, for example, when there are tasks that are not expected to be interrupted on the task queues of CPU0, CPU2, CPU3 and CPU6, the first combination and the second combination are the same, and the central processor for running real-time tasks is selected from the first combination. It should be understood that the specific mark or special setting for the task that is not expected to be interrupted can be determined in a customized manner, and the present disclosure is not limited thereto.

[0030] In some embodiments, the method of the present disclosure may further include step S103, running the real-time task on the selected central processing unit.

[0031] The present disclosure considers the differences between tasks when performing real-time task core selection, and can tend not to preempt important tasks but preempt unimportant tasks, thereby obtaining a better core selection result.

[0032] In some embodiments, the tasks that are not expected to be interrupted include fair tasks. Generally, when the rt task is selected, fair tasks of different priorities are ignored because the fair tasks do not distinguish priorities, and thus special priority settings for the fair tasks of the customized system cannot be considered. The present disclosure can avoid the CPU with tasks (with specific tags or customized tags) that are not expected to be interrupted on the task queue by distinguishing the priorities or customized tags of fair tasks when selecting rt tasks.

[0033] In some embodiments, an array is used to indicate whether there are tasks on the task queue that are not expected to be interrupted. In some embodiments, each bit in the array corresponds to a central processing unit. When there are tasks on the corresponding central processing unit that are not expected to be interrupted, the bit in the array corresponding to the central processing unit is 1; when there are no tasks on the corresponding central processing unit that are not expected to be interrupted, the bit in the array corresponding to the central processing unit is 0. Specifically, for example, a cpupri_fair_to_cpu[N] array is maintained, each item of the array corresponds to a CPU, and N is the total number of CPUs in the system. cpupri_fair_to_cpu is used to save the number of tasks on each CPU queue that are not expected to be interrupted by rt ​​tasks. fair_to_cpu_bitmask is a bitmask, where each bit corresponds to a CPU. When cpupri_fair_to_cpu[i] corresponding to CPU i is greater than 0, the i-th bit of fair_to_cpu_bitmask is set to 1; when cpupri_fair_to_cpu[i] corresponding to CPU i becomes 0, the i-th bit of fair_to_cpu_bitmask is set to 0. By setting the cpupri_fair_to_cpu variable, the correct fair_to_cpu_bitmask value is obtained, which can be used to indicate whether there are tasks that are not expected to be interrupted on the task queue of CPU i (i is the CPU number, for example, for eight cores, i can be 0-7) (where 1 indicates existence and 0 indicates non-existence).

[0034] Figure 2 A schematic flowchart of task scheduling for queueing tasks according to some embodiments of the present disclosure is shown. Figure 3A schematic flowchart of task dequeue scheduling of some embodiments of the present disclosure is shown. Figure 4 A schematic flow chart of load-balanced task scheduling of some embodiments of the present disclosure is shown. When a task enters a queue, exits a queue, and is load-balanced, cpupri_fair_to_cpu and fair_to_cpu_bitmask are maintained according to the task settings. The settings of which tasks do not want to be interrupted by rt ​​tasks are related to specific businesses and can be implemented according to business customization, and the present disclosure does not limit them.

[0035] In some embodiments, the task scheduling method of the present disclosure further includes: when the real-time task is set to be allowed to run only on the central processing unit in the fourth combination, obtaining the intersection of the first combination and the fourth combination to obtain a fifth combination. For example, assuming that the first combination includes CPU0, CPU2, CPU3 and CPU6, and the real-time task requested for scheduling is set to run only on CPU0-3, the fifth combination obtained by taking the intersection includes CPU0, CPU2, and CPU3. At this time, determining from the first combination the second combination of central processing units on which there are tasks that are not expected to be interrupted on the task queue includes: determining from the fifth combination the second combination of central processing units on which there are tasks that are not expected to be interrupted on the task queue.

[0036] In some embodiments, when the first combination is the same as the second combination, a central processor for running real-time tasks is selected from the first combination; when the first combination is different from the second combination, the central processor in the second combination is removed from the first combination to obtain a third combination of central processors, and selecting a central processor for running real-time tasks from the third combination includes: when the fifth combination is the same as the second combination, selecting a central processor for running real-time tasks from the fifth combination; when the fifth combination is different from the second combination, the central processor in the second combination is removed from the fifth combination to obtain a third combination of central processors, and selecting a central processor for running real-time tasks from the third combination.

[0037] Figure 5A schematic flow chart of core selection for real-time tasks of some embodiments of the present disclosure is shown. The flow chart describes how to use fair_to_cpu_bitmask to avoid interrupting tasks that are not expected to be interrupted by rt ​​tasks as much as possible when selecting rt tasks. Specifically, when selecting rt cores, native Linux will get the lowest_mask, which is the cpu mask of the CPU with the highest priority for the current priority task on each CPU, and the fair priority is CPUPRI_NORMAL. The lowest_mask obtained at this time is the bit mask of the CPU on each CPU where the fair task is the highest priority task, and the core selection logic is to select a CPU from this lowest_mask as the CPU on which the rt task runs. For example, for an rt task with a priority of 50, the lowest_mask may include CPUs that run tasks with priorities of 51-139.

[0038] In some embodiments, Figure 5 As shown, in lowest_mask, if there are still remaining CPUs after clearing or eliminating the CPUs in fair_to_cpu_bitmask (i.e., the first combination is different from the second combination), then the CPUs in fair_to_cpu_bitmask are eliminated (i.e., the central processing units in the second combination are removed from the first combination to obtain the third combination of central processing units), otherwise they are not eliminated. In this way, if eliminated, the core selection process avoids fair tasks that are not expected to be interrupted by rt ​​tasks; if there are no remaining CPUs in lowest_mask after eliminating the CPUs in fair_to_cpu_bitmask (i.e., the first combination is the same as the second combination), it may affect other rt tasks, so this case is not eliminated.

[0039] By adopting the method disclosed in the present invention, RT can distinguish the priorities or customized labels of fair tasks when selecting cores, and can distinguish the interruptibility of different fair tasks, so as to obtain a better core selection effect. That is, when selecting cores for RT tasks, try not to affect fair tasks with high business importance.

[0040] The embodiment of the present disclosure further provides a task scheduling device 400 . Figure 6The task scheduling device 400 according to some embodiments is shown. The task scheduling device 400 includes a task receiving module 401, a processor selection module 402 and a task running module 403. In some embodiments, the task receiving module 401 is configured to receive a real-time task. In some embodiments, the processor selection module 402 is configured to select a central processor to run for the real-time task, wherein selecting a central processor to run for the real-time task includes: determining a first priority corresponding to the real-time task; determining a first combination of central processors whose priority of the running task is lower than the first priority; determining from the first combination a second combination of central processors in which there are tasks on the task queue that are not expected to be interrupted, when the first combination is the same as the second combination, selecting a central processor to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processors in the second combination from the first combination to obtain a third combination of central processors, and selecting a central processor to run the real-time task from the third combination. In some embodiments, the task running module 403 is configured to run the real-time task on the selected central processor.

[0041] It should be understood that the contents described about the task scheduling method are also applicable to the task scheduling device 400 herein, and for the purpose of simplicity, a detailed description is not given here.

[0042] In some embodiments, the real-time task is an RT task in a Linux task. In some embodiments, the task that is not expected to be interrupted includes a fair task. In some embodiments, an array is used to indicate whether there is a task that is not expected to be interrupted on the task queue. In some embodiments, each bit in the array corresponds to a central processor, and when there is a task that is not expected to be interrupted on a corresponding central processor, the bit in the array corresponding to a central processor is 1; when there is no task that is not expected to be interrupted on a corresponding central processor, the bit in the array corresponding to a central processor is 0. In some embodiments, the processor selection module is also configured to: when the real-time task is set to be allowed to run only on the central processor in the fourth combination, obtain the intersection of the first combination and the fourth combination to obtain the fifth combination; wherein, determining from the first combination a second combination of central processors on which there are tasks that are not expected to be interrupted on the task queue includes: determining from the fifth combination a second combination of central processors on which there are tasks that are not expected to be interrupted on the task queue. In some embodiments, when the first combination is the same as the second combination, a central processor for running real-time tasks is selected from the first combination; when the first combination is different from the second combination, the central processor in the second combination is removed from the first combination to obtain a third combination of central processors, and selecting a central processor for running real-time tasks from the third combination includes: when the fifth combination is the same as the second combination, selecting a central processor for running real-time tasks from the fifth combination; when the fifth combination is different from the second combination, the central processor in the second combination is removed from the fifth combination to obtain a third combination of central processors, and selecting a central processor for running real-time tasks from the third combination.

[0043] In addition, the present disclosure also provides a terminal, including: at least one memory and at least one processor; wherein the memory is used to store program codes, and the processor is used to call the program codes stored in the memory to execute the above-mentioned task scheduling method.

[0044] In addition, the present disclosure also provides a computer storage medium, which stores program code, and the program code is used to execute the above-mentioned task scheduling method.

[0045] The above describes the task scheduling method and device of the present disclosure based on the embodiments and application examples. In addition, the present disclosure also provides a terminal and a storage medium, which are described below.

[0046] Reference below Figure 7, which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 500 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0047] like Figure 7 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0048] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0049] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0050] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0051] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0052] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0053] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method of the present disclosure.

[0054] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0055] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0056] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0057] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0058] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0059] According to one or more embodiments of the present disclosure, a task scheduling method is provided, the task scheduling method comprising: receiving a real-time task; selecting a central processing unit to run the real-time task, wherein selecting a central processing unit to run the real-time task comprises: determining a first priority corresponding to the real-time task; determining a first combination of central processing units whose priorities of the running tasks are lower than the first priority; determining from the first combination a second combination of central processing units on a task queue where there are tasks that are not expected to be interrupted, and when the first combination is the same as the second combination, selecting a central processing unit to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processing units in the second combination from the first combination to obtain a third combination of central processing units, and selecting a central processing unit to run the real-time task from the third combination; and running the real-time task on the selected central processing unit.

[0060] According to one or more embodiments of the present disclosure, the real-time task is an rt task in a linux task.

[0061] According to one or more embodiments of the present disclosure, the task expected to be interrupted includes a fair task.

[0062] According to one or more embodiments of the present disclosure, an array is used to indicate whether there are tasks in the task queue that are not expected to be interrupted.

[0063] According to one or more embodiments of the present disclosure, each bit in the array corresponds to a central processing unit, and when there is a task that is not expected to be interrupted on the corresponding central processing unit, the bit in the array corresponding to the central processing unit is 1; when there is no task that is not expected to be interrupted on the corresponding central processing unit, the bit in the array corresponding to the central processing unit is 0.

[0064] According to one or more embodiments of the present disclosure, the task scheduling method also includes: when the real-time task is set to be allowed to run only on the central processing unit in the fourth combination, obtaining the intersection of the first combination and the fourth combination to obtain a fifth combination; wherein, determining from the first combination a second combination of central processing units on which there are tasks in the task queue that are not expected to be interrupted includes: determining from the fifth combination a second combination of central processing units on which there are tasks in the task queue that are not expected to be interrupted.

[0065] According to one or more embodiments of the present disclosure, when the first combination is the same as the second combination, a central processor that runs the real-time task is selected from the first combination; when the first combination is different from the second combination, the central processor in the second combination is removed from the first combination to obtain a third combination of central processors, and the central processor that runs the real-time task is selected from the third combination, including: when the fifth combination is the same as the second combination, the central processor that runs the real-time task is selected from the fifth combination; when the fifth combination is different from the second combination, the central processor in the second combination is removed from the fifth combination to obtain the third combination of central processors, and the central processor that runs the real-time task is selected from the third combination.

[0066] According to one or more embodiments of the present disclosure, a task scheduling device is provided, the task scheduling device comprising: a task receiving module, configured to receive a real-time task; a processor selection module, configured to select a central processor to run for the real-time task, wherein selecting a central processor to run for the real-time task comprises: determining a first priority corresponding to the real-time task; determining a first combination of central processors whose priorities of the running tasks are lower than the first priority; determining from the first combination a second combination of central processors on a task queue where there are tasks that are not expected to be interrupted, and when the first combination is the same as the second combination, selecting a central processor to run the real-time task from the first combination; when the first combination is different from the second combination, removing the central processors in the second combination from the first combination to obtain a third combination of central processors, and selecting a central processor to run the real-time task from the third combination; a task running module, configured to run the real-time task on the selected central processor.

[0067] According to one or more embodiments of the present disclosure, a terminal is provided, comprising: at least one memory and at least one processor; wherein the at least one memory is used to store program code, and the at least one processor is used to call the program code stored in the at least one memory to execute any one of the methods described above.

[0068] According to one or more embodiments of the present disclosure, a storage medium is provided, wherein the storage medium is used to store program code, and the program code is used to execute the above method.

[0069] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0070] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0071] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A task scheduling method, characterized in that: The task scheduling method comprises: Receive real-time tasks; Selecting a central processing unit to run for the real-time task, wherein selecting a central processing unit to run for the real-time task includes: Determine a first priority corresponding to the real-time task; determining a first combination of CPUs running tasks with a priority lower than the first priority; A second combination of central processors having tasks on the task queue that are not expected to be interrupted is determined from the first combination; when the first combination is the same as the second combination, a central processor for running the real-time task is selected from the first combination; when the first combination is different from the second combination, the central processors in the second combination are removed from the first combination to obtain a third combination of central processors, and a central processor for running the real-time task is selected from the third combination; and the real-time task is run on the selected central processor.

2. The task scheduling method according to claim 1, characterized in that: The real-time task is an rt task in the linux task.

3. The task scheduling method according to claim 1, characterized in that: Tasks that are not expected to be interrupted include fair tasks.

4. The task scheduling method according to claim 1, characterized in that: Use an array to indicate whether there are tasks on the task queue that are not expected to be interrupted.

5. The task scheduling method according to claim 4, characterized in that: Each bit in the array corresponds to a central processing unit. When there is a task that is not expected to be interrupted on the corresponding central processing unit, the bit in the array corresponding to the central processing unit is 1; when there is no task that is not expected to be interrupted on the corresponding central processing unit, the bit in the array corresponding to the central processing unit is 0.

6. The task scheduling method according to claim 1, characterized in that: Also includes: When the real-time task is set to be allowed to run only on the CPU in the fourth combination, obtaining the intersection of the first combination and the fourth combination to obtain a fifth combination; The step of determining from the first combination a second combination of CPUs having tasks in the task queue that are not expected to be interrupted includes: determining from the fifth combination a second combination of CPUs having tasks in the task queue that are not expected to be interrupted.

7. The task scheduling method according to claim 6, characterized in that: When the first combination is the same as the second combination, a central processor that runs the real-time task is selected from the first combination; when the first combination is different from the second combination, the central processor in the second combination is removed from the first combination to obtain a third combination of central processors, and the central processor that runs the real-time task is selected from the third combination includes: When the fifth combination is the same as the second combination, a central processing unit that runs the real-time task is selected from the fifth combination; when the fifth combination is different from the second combination, the central processing unit in the second combination is removed from the fifth combination to obtain the third combination of central processing units, and a central processing unit that runs the real-time task is selected from the third combination.

8. A task scheduling device, characterized in that: The task scheduling device comprises: A task receiving module, configured to receive real-time tasks; A processor selection module is configured to select a central processing unit to run for the real-time task, wherein the central processing unit selected to run for the real-time task includes: Determine a first priority corresponding to the real-time task; determining a first combination of CPUs running tasks with a priority lower than the first priority; A second combination of central processors having tasks that are not expected to be interrupted on the task queue is determined from the first combination; when the first combination is the same as the second combination, a central processor for running the real-time task is selected from the first combination; when the first combination is different from the second combination, the central processors in the second combination are removed from the first combination to obtain a third combination of central processors, and a central processor for running the real-time task is selected from the third combination; a task running module is configured to run the real-time task on the selected central processor.

9. A terminal, comprising: at least one memory and at least one processor; The at least one memory is used to store program code, and the at least one processor is used to call the program code stored in the at least one memory to execute the task scheduling method according to any one of claims 1 to 7.

10. A storage medium, the storage medium being used to store program code, the program code being used to execute the task scheduling method according to any one of claims 1 to 7.