Task scheduling method and device, electronic equipment and computer readable storage medium
By managing and scheduling the target tasks according to whether they can be directly dispatched and assigned to the corresponding task queue, the problem of inefficient tasks in the prior art is solved, and efficient task scheduling and execution are achieved.
Patent Information
- Application Number
- CN202411909080.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-15
AI Technical Summary
In the prior art, the task scheduling method is relatively cumbersome, resulting in inefficient task execution.
By managing and scheduling target tasks based on whether they can be directly dispatched and allocated to the corresponding task queue, the efficiency of task scheduling management is improved. The specific steps include obtaining the target task to be executed, adding it to a first queue that can be directly scheduled or a second queue that cannot be directly scheduled, and after the task execution in the first queue is completed, the task is scheduled from the second queue to the first queue.
It improves task scheduling management and execution efficiency, reduces the attention of upper-level applications to thread creation and scheduling, reduces the probability of errors, and optimizes the execution order of tasks.
Smart Images

Figure CN119829289A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task scheduling method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] When an operating system of an electronic device (eg, Android system, etc.) detects a task to be executed, it is usually based on thread scheduling, that is, executing the corresponding task by scheduling threads.
[0003] However, it is found in practice that the current method of scheduling threads to execute tasks is rather cumbersome, thereby reducing the efficiency of task execution. Summary of the invention
[0004] The embodiments of the present application disclose a task scheduling method and device, an electronic device, and a computer-readable storage medium, which can add a target task to a corresponding task queue for management and scheduling based on whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management and thus improving the efficiency of task execution.
[0005] The first aspect of the embodiment of the present application discloses a task scheduling method, including:
[0006] Get multiple target tasks to be executed;
[0007] Adding a first target task among the multiple target tasks to the first queue, and / or adding a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled;
[0008] The first target task in the first queue is scheduled to be executed in the thread, and when any first target task is completed, the second target task is scheduled from the second queue as the first target task to the first queue.
[0009] A second aspect of an embodiment of the present application discloses a task scheduling device, including:
[0010] An acquisition unit, used for acquiring a plurality of target tasks to be executed;
[0011] an adding unit, configured to add a first target task among the plurality of target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled;
[0012] The first scheduling unit is used to schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0013] A third aspect of the present application discloses an electronic device, including:
[0014] A memory storing executable program code;
[0015] a processor coupled to the memory;
[0016] The processor calls the executable program code stored in the memory to execute the method disclosed in the first aspect of the embodiment of the present application.
[0017] A fourth aspect of an embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the method disclosed in the first aspect of the embodiment of the present application.
[0018] The fifth aspect of the embodiments of the present application discloses a computer program product. When the computer program product runs on a computer, the computer executes part or all of the steps of any one of the methods of the first aspect of the embodiments of the present application.
[0019] A sixth aspect of an embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes part or all of the steps of any one of the methods of the first aspect of the embodiment of the present application.
[0020] Compared with the related art, the embodiments of the present application have the following beneficial effects:
[0021] In the embodiment of the present application, multiple target tasks to be executed can be obtained, and the first target task among the multiple target tasks can be added to the first queue, and / or the second target task can be added to the second queue; wherein, the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; it can be seen that in the embodiment of the present application, the target task can be added to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks makes it unnecessary for the upper-level application to pay attention to the problems of thread creation and scheduling at the bottom layer, and the upper-level application only needs to pass the target task, thereby reducing the probability of error. In addition, in the embodiment of the present application, the first target task that can be directly scheduled in the first queue can be scheduled to the thread for execution first, and when any first target task is executed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a structural diagram of a task management system disclosed in an embodiment of the present application;
[0024] Figure 2 It is a flowchart of a task scheduling method disclosed in an embodiment of the present application;
[0025] Figure 3 is a schematic diagram of a target interface disclosed in an embodiment of the present application;
[0026] Figure 4 It is a task scheduling schematic diagram disclosed in an embodiment of the present application;
[0027] Figure 5 It is a flowchart of another task scheduling method disclosed in an embodiment of the present application;
[0028] Figure 6 It is a schematic diagram of parallel task scheduling disclosed in an embodiment of the present application;
[0029] Figure 7 It is a scheduling diagram of a task set disclosed in an embodiment of the present application;
[0030] Figure 8 It is a flowchart of another task scheduling method disclosed in an embodiment of the present application;
[0031] Fig. 9 It is a structural schematic diagram of a task scheduling device disclosed in an embodiment of the present application;
[0032] Fig.10 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] It should be noted that the terms "first", "second", "third" and "fourth" in the specification and claims of the present application are used to distinguish different objects rather than to describe a specific order. The terms "including" and "having" in the embodiments of the present application and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device including a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] The embodiments of the present application disclose a task scheduling method and device, an electronic device, and a computer-readable storage medium, which can add a target task to a corresponding task queue for management and scheduling based on whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management and thus improving the efficiency of task execution.
[0036] The technical solution of the present application will be described in detail below in conjunction with specific embodiments.
[0037] In order to more clearly introduce the task scheduling method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application, the application scenarios applicable to the method are first introduced. Optionally, the method can be applied to the task operation scheduling inside various electronic devices, and the electronic devices may include: portable electronic devices such as mobile phones and tablets, wearable devices such as smart watches and smart bracelets, or desktop devices such as desktop computers and desktop TVs, which are not limited here.
[0038] Optionally, the method may be applied to various operating systems for task execution scheduling, and the operating systems may include: Android operating system, IOS operating system or Windows operating system, etc., which are not limited here.
[0039] In the related art, when electronic devices perform task scheduling, they usually need to create a thread pool, and then schedule threads to execute corresponding tasks based on the threads in the thread pool as the basic scheduling unit. In this process, users (such as upper-level applications) need to pay attention to the management of various life cycle stages such as the creation, scheduling, and closing of each thread. When there are many threads, scheduling is more cumbersome, thereby reducing the efficiency of task scheduling.
[0040] In addition, when there are a large number of threads, the threads may continue to grow due to the user's failure to close the threads that have completed the task in time, which may lead to thread leakage problems and increase the memory space occupied by the electronic device.
[0041] In this regard, the embodiments of the present application provide a task scheduling method and device, an electronic device, and a computer-readable storage medium to solve the technical problems in the related art. Optionally, the method can be applied to various electronic devices introduced above. Optionally, the method can be applied to an application or system service in an electronic device, which is not limited here.
[0042] Optionally, the electronic device can obtain multiple target tasks to be executed, and add the first target task among the multiple target tasks to the first queue, and / or add the second target task to the second queue; wherein the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; it can be seen that in the embodiment of the present application, the electronic device can add the target task to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks makes it unnecessary for the upper-level application to pay attention to the problems of thread creation and scheduling at the bottom layer, and the upper-level application only needs to pass the target task, thereby reducing the probability of error. In addition, in the embodiment of the present application, the first target task that can be directly scheduled in the first queue can be scheduled to the thread for execution first, and when any first target task is executed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution.
[0043] See also Figure 1 , Figure 11 is a schematic diagram of the structure of a task management system disclosed in an embodiment of the present application. Optionally, the task management system can be applied to the above-mentioned electronic device, and the task scheduling method disclosed in an embodiment of the present application can be applied to the task management system.
[0044] Optionally, the task management system may include an application layer 110 and a framework layer 120 ; wherein the framework layer 120 may include: an interface module 130 and a task management module 140 .
[0045] Optionally, the application layer 110 may be used to call the target interface provided by the interface module 130 to send target task information to the task management module 140 , where the target task information includes: a plurality of target tasks to be executed;
[0046] The task management module 140 is used to add a first target task among the multiple target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled;
[0047] The task management module 140 is further configured to schedule the first target task in the first queue to be executed in the thread, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0048] In one embodiment, the task management system may further include a third-party interface, and the third-party interface is used to connect to a third-party application program, so that the third-party application program may also use the method, thereby expanding the use scenarios of the method.
[0049] It should be noted that Figure 1 This is just an optional example for the convenience of explanation. The task management system may also include other modules and / or units, wherein the connection between the modules and / or units may also be the same as Figure 1 Not the same, Figure 1 This should not be construed as limiting the embodiments of the present application.
[0050] It should be further explained that an embodiment of the present application provides a task management system, which is a system based on task scheduling, which can facilitate electronic equipment to be scheduled based on tasks, thereby improving the efficiency of task scheduling and operation.
[0051] Based on this, the task scheduling method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application are introduced below.
[0052] See also Figure 2 , Figure 21 is a flowchart of a task scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various electronic devices introduced above, or other execution entities, which are not limited here. Optionally, the method can include the following steps:
[0053] 202. Obtain multiple target tasks to be executed.
[0054] In the embodiment of the present application, the electronic device may obtain target task information, and the target task information may include: a plurality of target tasks to be executed;
[0055] In the embodiment of the present application, the multiple target tasks to be executed may include: application tasks issued by an upper-layer application program, and / or system tasks issued by an operating system of the electronic device, etc., which are not limited here.
[0056] Optionally, the task lower initiator (eg, an upper layer application, an operating system, etc.) may transmit the target task information by calling a target interface, and then the electronic device may acquire the target task information.
[0057] Optionally, the target interface may include an application programming interface (API), which may provide an interface for the task initiator to transmit target task information to the electronic device, thereby facilitating the electronic device to uniformly receive the target task information and further facilitate the electronic device to manage the target task information.
[0058] In the embodiment of the present application, the target task information may also include: the execution order between multiple target tasks to be executed, the task content of multiple target tasks, etc., which are not limited here.
[0059] The execution order between multiple target tasks can include: serial order or parallel order. Serial order means that multiple target tasks are executed in sequence, and the next target task can be executed only after the previous task is executed. Parallel order means that multiple target tasks have no restrictions on the order of execution, and multiple target tasks can be executed at the same time.
[0060] In an optional embodiment, the target task information may also include name information, attribute information, and priority information of the target task, which are not limited here. The name information is used to distinguish different target tasks; the attribute information is used to indicate the source, business, data volume and format of the target task, which are not limited here; the priority information is used to indicate the resource allocation method of the thread or process corresponding to the target task.
[0061] See also Figure 3 , Figure 33 is a schematic diagram of a target interface disclosed in an embodiment of the present application. Optionally, the target interface may include: a task queue creation unit 310 , a task content unit 320 and a sending unit 330 .
[0062] Wherein, the task queue creation unit 310 is used to create a task queue, and the task queue can include a serial task queue or a parallel task queue. The execution order of the tasks in the serial task queue is a serial order, and the execution order of the tasks in the parallel task queue is a parallel order, which is not limited here. That is, the task queue can store the execution order between multiple target tasks. Optionally, the task queue can also store the name information, attribute information and priority information of the task queue, which is not limited here.
[0063] Optionally, among multiple target tasks to be executed, target tasks in parallel order can be stored in a parallel task queue, and target tasks in serial order can be stored in a serial task queue, which is not limited here, so as to facilitate electronic devices to classify and manage target tasks with different execution orders.
[0064] Optionally, the task content unit 320 may be used to store the task content of the target task, where the task content is used to indicate how to execute the target task.
[0065] Optionally, the sending unit 330 may be configured to send the created task queue and task content to an electronic device.
[0066] It should be noted that Figure 3 It is only an optional implementation manner and should not be construed as limiting the embodiments of the present application.
[0067] By implementing the above method, the target interface can be used to provide the task sender with an interface for transmitting target task information to the electronic device, thereby facilitating the electronic device to uniformly receive and manage the target task information, and facilitating the interaction of information data between the task sender and the electronic device.
[0068] 204. Add a first target task among the multiple target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled.
[0069] In the embodiment of the present application, the electronic device can determine whether each target task can be directly scheduled. Wherein, being directly schedulable may mean that the corresponding target task can be directly scheduled to be executed in a thread; correspondingly, being not directly schedulable may mean that the corresponding target task cannot be directly scheduled to be executed in a thread.
[0070] Optionally, the electronic device may create a first queue and a second queue; wherein the first queue is used to store target tasks that can be directly scheduled, and the second queue is used to store target tasks that cannot be directly scheduled, so as to facilitate separate management of target tasks that can be directly scheduled and those that cannot be directly scheduled.
[0071] It should be noted that each time the electronic device obtains multiple target tasks to be executed, the multiple target tasks may be first target tasks that can all be directly scheduled, or second target tasks that cannot all be directly scheduled; or the multiple target tasks may include some first target tasks that can be directly scheduled, and some second target tasks that cannot be directly scheduled. The electronic device may add the first target tasks that can be directly scheduled among the multiple target tasks to the first queue, and / or add the second target tasks that cannot be directly scheduled to the second queue.
[0072] Optionally, there may be one or more first queues. Optionally, when there is only one first queue, when the electronic device schedules the first target task from the first queue, it only needs to schedule from one first queue, and does not need to schedule from different first queues, thereby improving the scheduling efficiency of the task.
[0073] Optionally, there may be one or more second queues. When there are multiple second queues, one service may correspond to one or more second queues, and the target tasks contained in each second queue belong to the same service. By implementing this method, target tasks that cannot be directly scheduled in different services can be added to the corresponding second queues, thereby facilitating the electronic device to manage and schedule target tasks of different services, thereby improving the scheduling efficiency of target tasks.
[0074] In another optional embodiment, when there is only one second queue, the electronic device can add all target tasks that cannot be directly scheduled to the second queue, and then the subsequent electronic device only needs to schedule from one second queue, without scheduling from different second queues, thereby improving the scheduling efficiency of tasks.
[0075] In an optional embodiment, the electronic device can add the target tasks to the corresponding queue according to the execution order of the multiple target tasks, so that when the subsequent electronic device schedules the target tasks from the queue, it can also be scheduled according to the execution order of the multiple target tasks, thereby ensuring that the subsequent multiple target tasks can be executed in the execution order.
[0076] For example, see Figure 4 , Figure 4This is a task scheduling diagram disclosed in an embodiment of the present application. Assuming that the electronic device can only create two threads at most, the target tasks A1 and A2 in the "parallel task queue 1" can be directly scheduled, so they are added to the first queue. However, since there is not enough third thread to execute the target task A3, the target task A3 cannot be directly scheduled and is added to the corresponding "second queue 1".
[0077] For another example, in the "serial task queue 1", in order to avoid H1 and H2 being scheduled to the thread for execution at the same time after being added to the first queue instead of being executed in a serial order, the electronic device can add the target task H1 and the target task H2 as the second target task that cannot be directly scheduled to the "third queue 3", waiting for subsequent scheduling, which is not limited here.
[0078] It should be noted that Figure 4 This is merely an example for convenience of explanation and should not be construed as limiting the embodiments of the present application.
[0079] 206. Schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0080] In the embodiment of the present application, the electronic device may first schedule the first target task in the first queue to be executed in the thread. Optionally, the electronic device may schedule each first target task to be executed in the thread according to the execution order of the first target task to ensure that the first target task in the first queue is executed in the execution order.
[0081] Alternatively, the electronic device schedules each first target task to be executed in a thread according to the order in which the first target tasks are queued, which is not limited here.
[0082] In another embodiment, the electronic device may schedule a second number of first target tasks from the first queue to be executed in different threads; wherein the second number is less than or equal to a thread number threshold.
[0083] Optionally, the thread number threshold may include: an upper limit on the number of threads that can exist simultaneously in the electronic device, or other values set by the developer or user, which are not limited here. Among them, the upper limit of threads that can currently exist simultaneously may include: the sum of currently idle threads and new threads that can be newly created. It should be noted that, subject to hardware performance limitations, there is an upper limit to the number of threads that can exist simultaneously in an electronic device, and the thread upper limit values of different electronic devices may be different.
[0084] Optionally, typical values of the thread quantity threshold may include 8, 16, or 32, etc., which are not limited here.
[0085] Optionally, the electronic device may schedule a second number of first target tasks from the first queue to different threads for execution according to scheduling requirements, and the second number may be greater than 1 and less than or equal to a thread number threshold.
[0086] By implementing the above method, the electronic device can flexibly schedule the second number of first target tasks from the first queue to different threads for execution, so that the number of second target tasks scheduled simultaneously is controllable, thereby improving the flexibility and controllability of the method.
[0087] In another optional embodiment, the electronic device may schedule a maximum number of first target tasks from the first queue to different threads for execution, so that as many first target tasks as possible can be scheduled to threads for execution, thereby improving the execution efficiency of the first target tasks.
[0088] Optionally, the maximum number may be determined based on the thread number threshold described above. Figure 4 , where: when the thread quantity threshold is 2, the electronic device can schedule at most two target tasks, target task A1 and target task A2, from the first queue to be executed in "thread 1" and "thread 2" respectively.
[0089] Furthermore, when any first target task is executed, it indicates that there is an idle thread currently. The electronic device can schedule the second target task from the second queue as the first target task to the first queue, and then the electronic device can schedule the first target task from the first queue to the idle thread for execution, so that the target task can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution.
[0090] By implementing the methods disclosed in the above embodiments, multiple target tasks to be executed can be obtained, and the first target task among the multiple target tasks can be added to the first queue, and / or the second target task can be added to the second queue; wherein, the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; it can be seen that in the embodiment of the present application, the target task can be added to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks makes it unnecessary for the upper-level application to pay attention to the problems of thread creation and scheduling at the bottom layer, and the upper-level application only needs to pass the target task, thereby reducing the probability of error. In addition, in the embodiment of the present application, the first target task that can be directly scheduled in the first queue can be scheduled to the thread for execution first, and when any first target task is executed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution.
[0091] See also Figure 5 , Figure 5 1 is a flowchart of another task scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various electronic devices introduced above, or other execution entities, which are not limited here. Optionally, the method can include the following steps:
[0092] 502. Obtain multiple target tasks to be executed.
[0093] 504. According to the execution order of the multiple target tasks, add the first target task among the multiple target tasks to the first queue, and / or add the second target task to the second queue.
[0094] In the embodiment of the present application, the execution order between multiple target tasks may include the serial order or the parallel order introduced above.
[0095] It is understandable that serial order means that multiple target tasks are executed in sequence, that is, the next target task can only be executed after the previous target task is completed. In this regard, when the previous target task is added to the queue as the first target task that can be directly scheduled, before the previous target task is completed, the next target task is the second target task that cannot be scheduled and can be added to the second queue.
[0096] Parallel order means that multiple target tasks can be executed simultaneously without any restriction on the order of execution. In this case, if the number of threads is sufficient to execute multiple parallel target tasks at the same time, multiple target tasks can be added to the queue as the first target tasks that can be directly scheduled.
[0097] That is to say, the execution order between multiple target tasks is one of the factors that determine whether the multiple target tasks can be scheduled between each other. For this purpose, the electronic device can determine the first target task that can be directly scheduled among the multiple target tasks based on the execution order between the multiple target tasks, and add it to the first queue; and / or determine the second target task that cannot be directly scheduled, and add it to the second queue.
[0098] By implementing the above method, the electronic device can add multiple target tasks to the corresponding queue according to the execution order between the multiple target tasks, so that when the subsequent electronic device schedules the target task from the queue to the thread for execution, it schedules it according to the execution order between the multiple target tasks, thereby ensuring that the subsequent multiple target tasks are executed in the execution order, thereby improving the intelligence and execution effect of the method.
[0099] In one embodiment, the execution order of the multiple target tasks may include a parallel order. Optionally, when the electronic device determines that the execution order between the multiple target tasks is a parallel order, the multiple target tasks may be added to the first queue as the first target task.
[0100] By implementing the above method, when the number of threads is sufficient to simultaneously execute multiple target tasks in parallel, the electronic device can add multiple target tasks to the queue as first target tasks that can be directly scheduled, so that multiple target tasks can be subsequently scheduled to the thread for execution, thereby improving the execution efficiency of the task.
[0101] In another optional embodiment, the electronic device may add a first target task among the multiple target tasks to the first queue and / or add a second target task to the second queue according to the execution order and the first quantity of the multiple target tasks.
[0102] Optionally, the first number may include the thread number threshold introduced above, and typical values may include 8, 16 or 32, etc., which are not limited here.
[0103] Optionally, when determining that the execution order of the multiple target tasks is a parallel order, the electronic device may determine whether the number of the multiple target tasks is greater than the first number;
[0104] If so, it means that the number of multiple target tasks exceeds the upper limit of the number of threads that can be scheduled currently, and some target tasks cannot be directly scheduled to the thread for execution. Optionally, the electronic device can add the first number of target tasks among the multiple target tasks as the first target tasks to the first queue, and add the other target tasks as the second target tasks to the second queue, wherein the other target tasks are target tasks other than the first number of target tasks among the multiple target tasks.
[0105] Optionally, if the number of multiple target tasks is less than or equal to the first number, it means that the currently schedulable threads are sufficient to execute multiple target tasks in parallel. The electronic device adds the multiple target tasks to the first queue so that the multiple target tasks can be scheduled to the thread for execution as soon as possible, thereby improving the execution efficiency of the thread.
[0106] For example, see Figure 6 , Figure 6 This is a schematic diagram of parallel task scheduling disclosed in an embodiment of the present application. Assuming that the electronic device can only create 2 threads at most (i.e., the first number is 2), the target tasks A1 and A2 in the "parallel task queue 1" can be directly scheduled, so they are added to the first queue, while the target task A3 cannot be directly scheduled because there are not enough threads to execute, so it is added to the corresponding "second queue 1".
[0107] If the target tasks A4 and A5 in the "parallel task queue 1" do not exceed the first quantity 2, the electronic device can add both the target tasks A4 and A5 to the first queue so that the target tasks A4 and A5 can be scheduled to the thread for execution as soon as possible.
[0108] By implementing the above method, when the execution order between multiple target tasks is a parallel order, the electronic device can add as many target tasks as possible to the first queue according to the first number of threads that can be currently scheduled, so that under the premise of ensuring that multiple target tasks are executed in the execution order, as many target tasks as possible can be scheduled to the threads for execution as quickly as possible, thereby improving the execution efficiency of the threads; and other target tasks exceeding the first number can be added to the second queue to wait for execution, thereby facilitating the management and scheduling of the target tasks.
[0109] In an optional embodiment, when the electronic device adds other target tasks as second target tasks to the second queue, it can add dependency information for the other target tasks in the second queue, and the dependency information is used to represent the execution order information between the other target tasks and the first number of target tasks added to the first queue.
[0110] For example, please refer again to Figure 6 , target task A3 cannot be directly scheduled because there are not enough threads to execute it. Therefore, when it is added to the corresponding "second queue 1", the electronic device can add corresponding dependency information for target task A3. The dependency information is used to indicate that the execution order between target task A3 and target tasks A1 and A2 added to the first queue is a parallel order, and target task A3 is executed after target task A1 and A2.
[0111] By implementing the above method, the electronic device can add dependency information for the target tasks waiting to be scheduled in the second queue, thereby facilitating the electronic device to schedule the corresponding target tasks in the second queue according to the dependency information, so that the execution order of the target tasks meets the preset order, thereby improving the intelligence level and execution effect of the method.
[0112] As an optional implementation, the execution order of the multiple target tasks may include a serial order. Optionally, when the electronic device determines that the execution order between the multiple target tasks is a serial order, the multiple target tasks may be added to the second queue as second target tasks.
[0113] As introduced above, the target tasks added to the first queue are those that can be scheduled directly. In order to avoid multiple target tasks for serial execution being added to the first queue and then directly scheduled to the thread for execution at the same time instead of being executed in a serial order, the electronic device, when determining that the execution order of the multiple target tasks is a serial order, can add the multiple target tasks to the second queue as second target tasks that cannot be scheduled directly.
[0114] For example, please refer again to Figure 4 , where: target tasks H1 and H2, target tasks H3 and H4 in "serial task queue 1", and target tasks K1 and K2 in "serial task queue 2"; since their execution order is serial order, they are all added to the corresponding second queue.
[0115] By implementing the above method, when the electronic device determines that the execution order between multiple target tasks is a serial order, the multiple target tasks can be added to the second queue, thereby avoiding the situation where the multiple target tasks for serial execution are added to the first queue and are directly scheduled to the thread for execution at the same time instead of being executed in a serial order. This ensures that the multiple target tasks can be executed in the set execution order, thereby improving the controllability and intelligence of the method.
[0116] 506. Schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0117] As an optional implementation, the method by which the electronic device schedules the second target task from the second queue as the first target task to the first queue may include: the electronic device binds multiple second target tasks with a dependency relationship among the second target tasks included in the second queue into a task set, and adds the task set as the first target task to the first queue.
[0118] The dependency relationship indicates that multiple second target tasks need to be executed serially.
[0119] For example, please refer again to Figure 4 , where: the target tasks H1 and H2 executed serially in the "second queue 3" can be bound as a "task set S3"; the target tasks H3 and H4 executed serially can be bound as a "task set S5"; the target tasks K1 and K2 executed serially in the "second queue 4" can be bound as a "task set S4", etc., without limitation here.
[0120] Furthermore, when the electronic device is in the process of scheduling the first target task in the first queue to a thread, if the currently scheduled first target task contains multiple second target tasks with a dependent relationship, the second target task ranked first among the multiple second target tasks can be scheduled to the thread for execution; and, when the first second target task is completed, the next second target task can be scheduled from the multiple second target tasks to the thread for execution.
[0121] For example, see Figure 7 , Figure 7 This is a scheduling diagram of a task set disclosed in an embodiment of the present application. When the electronic device is scheduled as the first target task of "task set S3" from the first queue, the target task H1 in "task set S3" can be first scheduled to "thread 1" for execution, and then when the target task H1 is completed, the target task H2 in "task set S3" can be immediately scheduled to "thread 1" for execution.
[0122] In another embodiment, if the currently scheduled first target task includes only one target task, the electronic device may directly schedule the first target task to be executed in a thread.
[0123] For example, please refer again to Figure 7 , wherein: when the electronic device schedules the "target task A3" from the first queue, it can directly schedule it to be executed in the "thread 2".
[0124] By implementing the above method, the electronic device can bind multiple target tasks in a serial relationship into a task set and add it to the first queue, and keep the multiple target tasks in the task set to be continuously scheduled for execution, so that even if the electronic device uses parallel sequential scheduling to execute the first target task in the first queue, it can ensure that the target tasks in the task set are executed serially, thereby ensuring that the target tasks can be executed in a preset execution order. In addition; based on this, the electronic device can schedule the first target task without considering the execution order of the first target task in the first queue, which simplifies the task scheduling process and improves the efficiency of task scheduling.
[0125] By implementing the methods disclosed in the above embodiments, the target task can be added to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks makes it unnecessary for the upper-level application to pay attention to the creation and scheduling of the underlying threads, and the upper-level application only needs to pass the target task, thereby reducing the probability of errors. In addition, the first target task that can be directly scheduled in the first queue can be first scheduled to the thread for execution, and when any first target task is completed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution; and the electronic device can add multiple target tasks to the corresponding queue according to the execution order between the multiple target tasks, so that when the subsequent electronic device schedules the target task from the queue to the thread for execution, it is scheduled according to the execution order between the multiple target tasks, thereby ensuring that the subsequent multiple target tasks are executed in the execution order, thereby improving the intelligence and execution effect of the method;
[0126] Furthermore, when the number of threads is sufficient to simultaneously execute multiple target tasks to be executed in parallel, the electronic device can add all of the multiple target tasks to the queue as first target tasks that can be directly scheduled, so that the multiple target tasks can be subsequently scheduled to be executed in the thread, thereby improving the execution efficiency of the task; and, when the electronic device determines that the execution order between the multiple target tasks is a serial order, the multiple target tasks can be added to the second queue, thereby avoiding that the multiple target tasks to be executed in serial are added to the first queue and are simultaneously directly scheduled to be executed in the thread instead of being executed in the serial order, thereby ensuring that the multiple target tasks can be executed in the set execution order, and improving the controllability and intelligence of the method;
[0127] Furthermore, multiple target tasks in a serial relationship can be bound as a task set and added to the first queue, and the multiple target tasks in the task set can be continuously scheduled for execution, so that even if the electronic device uses parallel sequential scheduling to execute the first target task in the first queue, it can ensure that the target tasks in the task set are executed serially, thereby ensuring that the target tasks can be executed in a preset execution order. In addition, based on this, the electronic device can schedule the first target task without considering the execution order of the first target task in the first queue, which simplifies the task scheduling process and improves the efficiency of task scheduling.
[0128] See also Figure 8 , Figure 8 This is a flowchart of another task scheduling method disclosed in an embodiment of the present application. Optionally, the method can be applied to various electronic devices introduced above, or other execution entities, which are not limited here. Optionally, the method can include the following steps:
[0129] 802. Obtain multiple target tasks to be executed.
[0130] 804. Add a first target task among the multiple target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled.
[0131] 806. Schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0132] 808. According to the first priority corresponding to the first target task to be scheduled, schedule the first target task to be scheduled to be executed in a thread corresponding to the first priority.
[0133] In an embodiment of the present application, the electronic device can create one or more threads corresponding to each priority level, and the first target task to be scheduled can be scheduled to the thread of the corresponding priority level for execution according to its corresponding priority level, so that the subsequent execution process of the first target task can obtain the resource allocation corresponding to its priority level, making the execution of the first target task controllable.
[0134] Optionally, the resource may include: one or more of the CPU occupancy rate, the use rights of the output / input ports, and the memory space, which are not limited here.
[0135] By implementing the above method, the electronic device can schedule the first target task to be executed in a thread of corresponding priority according to the priority of the first target task, so that the subsequent execution process of the first target task can obtain resource allocation corresponding to its priority, making the execution of the first target task controllable.
[0136] In an optional embodiment, the electronic device may schedule the first target task to be scheduled to be executed in the thread corresponding to the first priority level in a manner that includes:
[0137] Determine whether there is an idle thread corresponding to the first priority level at present;
[0138] If there is currently an idle thread corresponding to the first priority, the first target task to be scheduled is scheduled to be executed in the idle thread;
[0139] If there is no idle thread corresponding to the first priority at present, a new thread corresponding to the first priority is created, and the first target task to be scheduled is scheduled to be executed in the new thread corresponding to the first priority. As described above, there can be multiple threads corresponding to the first priority, that is, if the number of threads corresponding to the first priority is insufficient, a new thread corresponding to the first priority can be newly created.
[0140] By implementing the above method, the electronic device can give priority to reusing idle threads corresponding to the first priority level to reduce the number of threads corresponding to the first priority level, thereby reducing the memory space occupied by the electronic device; in addition, if there is no idle thread corresponding to the first priority level, a new thread corresponding to the first priority level can be created to meet the need to run the first target task in a timely manner, thereby improving the flexibility of the method.
[0141] As an optional implementation, the electronic device can determine the resource scheduling parameters based on the first priority corresponding to the first target task to be scheduled and the running status of the target process, where the target process is the process to which the thread executing the first target task belongs; and then, resources can be allocated to the thread executing the first target task based on the resource scheduling parameters.
[0142] In the embodiment of the present application, the running state of the target process can be used to reflect the priority of the thread executing the first target task to allocate resources. It should be noted that the thread is the basic scheduling unit in the process and shares the resources of the process. Optionally, the thread executing the first target task can be any thread in the target process.
[0143] Optionally, the running state of the target process may include: running scene information and / or sleep information, etc., which are not limited here. The running scene information may include: foreground running, background running, etc., and the sleep information may include: sleep state, non-sleep state, etc., which are not limited here.
[0144] Optionally, if the target process is running in the foreground and / or in a non-sleeping state, the electronic device allocates more resources to the thread executing the first target task; if the target process is running in the background and / or in a sleeping state, the electronic device allocates fewer resources to the thread executing the first target task, which is not limited here.
[0145] Optionally, the electronic device may include a resource scheduling module, and the resource scheduling module may include: a kernel of the electronic device, etc., which is not limited here.
[0146] Optionally, the electronic device may determine the resource scheduling parameters according to the first priority corresponding to the first target task and the running status of the target process through the resource scheduling module.
[0147] Optionally, the resource allocation method may include a resource allocation priority, which refers to the priority of resource allocation. The higher the resource allocation priority, the higher the priority of resource allocation. Optionally, the resource allocation priority may be determined according to a resource scheduling parameter, and the resource allocation priority may be positively correlated with the resource scheduling parameter.
[0148] Optionally, the resource allocation method may include a resource allocation quantity; optionally, the resource allocation quantity may be determined based on a resource scheduling parameter; the resource allocation quantity may be positively correlated with the resource scheduling parameter, which is not limited here.
[0149] By implementing the above method, the electronic device can determine the resource allocation strategy of the thread executing the first target task based on the priority of the first target task and the running status of the target process, so that the resources allocated to the thread executing the first target task meet the actual usage requirements, thereby improving the intelligence of the method.
[0150] By implementing the methods disclosed in the above embodiments, the target task can be added to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks means that the upper-level applications do not need to pay attention to the underlying thread creation and scheduling issues. The upper-level applications only need to pass the target task, thereby reducing the probability of errors. In addition, the first target task that can be directly scheduled in the first queue can be first scheduled to the thread for execution, and when any first target task is completed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution; and, according to the priority of the first target task, it can be scheduled to the thread of the corresponding priority for execution, so that the subsequent execution process of the first target task can obtain the resource allocation corresponding to its priority, so that the execution of the first target task is controllable; and, the electronic device can preferentially reuse the idle thread corresponding to the first priority to reduce the number of threads corresponding to the first priority, thereby reducing the occupancy of the memory space of the electronic device; in addition, if there is no idle thread corresponding to the first priority, a new thread corresponding to the first priority can be created to meet the demand of timely running the first target task, thereby improving the flexibility of the method.
[0151] See also Fig. 9 , Fig. 9 90 is a schematic diagram of a task scheduling device disclosed in an embodiment of the present application. Optionally, the method can be applied to various electronic devices introduced above, or other execution entities, which are not limited here. Optionally, the device may include an acquisition unit 902, an adding unit 904 and a first scheduling unit 906, wherein:
[0152] An acquisition unit 902 is used to acquire a plurality of target tasks to be executed;
[0153] An adding unit 904 is used to add a first target task among the multiple target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled;
[0154] The first scheduling unit 906 is used to schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
[0155] By implementing the above device, multiple target tasks to be executed can be obtained, and the first target task among the multiple target tasks can be added to the first queue, and / or the second target task can be added to the second queue; wherein, the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; it can be seen that in the embodiment of the present application, the target task can be added to the corresponding task queue for management and scheduling according to whether the target task can be directly scheduled, thereby improving the efficiency of task scheduling management; in addition, scheduling based on tasks makes it unnecessary for the upper-level application to pay attention to the problems of thread creation and scheduling at the bottom layer, and the upper-level application only needs to pass the target task, thereby reducing the probability of error. In addition, in the embodiment of the present application, the first target task that can be directly scheduled in the first queue can be scheduled to the thread for execution first, and when any first target task is executed, the second target task can be scheduled from the second queue as the first target task to the first queue, so that the target task that can be directly scheduled can be scheduled to the thread for execution as soon as possible, thereby improving the efficiency of task execution.
[0156] As an optional implementation, the adding unit 904 is further configured to add the first target task among the multiple target tasks to the first queue and / or add the second target task to the second queue according to the execution order among the multiple target tasks.
[0157] By implementing the above-mentioned device, the electronic device can add multiple target tasks to the corresponding queue according to the execution order between the multiple target tasks, so that when the subsequent electronic device schedules the target task from the queue to the thread for execution, it schedules it according to the execution order between the multiple target tasks, thereby ensuring that the subsequent multiple target tasks are executed in the execution order, thereby improving the intelligence and execution effect of the method.
[0158] As an optional implementation, the execution order includes a parallel order; the adding unit 904 is further used to add the multiple target tasks as the first target task to the first queue when the execution order between the multiple target tasks is a parallel order.
[0159] By implementing the above-mentioned device, when the number of threads is sufficient to simultaneously execute multiple target tasks in parallel, the electronic device can add multiple target tasks to the queue as first target tasks that can be directly scheduled, so that multiple target tasks can be subsequently scheduled to the thread for execution, thereby improving the execution efficiency of the task.
[0160] As an optional implementation, the execution order includes a parallel order; the adding unit 904 is also used to add a first number of target tasks among the multiple target tasks as first target tasks to the first queue, and add other target tasks as second target tasks to the second queue when the execution order between the multiple target tasks is a parallel order and the number of the multiple target tasks is greater than the first number. The other target tasks are target tasks other than the first number of target tasks among the multiple target tasks.
[0161] By implementing the above-mentioned device, when the execution order between multiple target tasks is a parallel order, the electronic device can add as many target tasks as possible to the first queue according to the first number of threads that can be currently scheduled. Therefore, under the premise of ensuring that multiple target tasks are executed in the execution order, as many target tasks as possible can be scheduled to the threads for execution as quickly as possible, thereby improving the execution efficiency of the threads.
[0162] As an optional implementation, the execution order includes a serial order; the adding unit 904 is further used to add the multiple target tasks as second target tasks to the second queue when the execution order between the multiple target tasks is a serial order.
[0163] By implementing the above-mentioned device, when the electronic device determines that the execution order between multiple target tasks is a serial order, the multiple target tasks can be added to the second queue, thereby avoiding the situation where the multiple target tasks for serial execution are added to the first queue and are directly scheduled to the thread for execution at the same time instead of being executed in a serial order. This ensures that the multiple target tasks can be executed in the set execution order, thereby improving the controllability and intelligence of the method.
[0164] As an optional implementation, the first scheduling unit 906 is further used to bind multiple second target tasks with a dependency relationship among the second target tasks included in the second queue into a task set, and add the task set as the first target task to the first queue, wherein the dependency relationship indicates that the multiple second target tasks need to be executed serially;
[0165] Furthermore, if the currently scheduled first target task contains multiple second target tasks with a dependent relationship, the second target task ranked first among the multiple second target tasks is scheduled to be executed in the thread; and, when the first second target task is completed, the next second target task is scheduled from the multiple second target tasks to be executed in the thread.
[0166] By implementing the above device, the electronic device can bind multiple target tasks in a serial relationship into a task set and add it to the first queue, and keep the multiple target tasks in the task set to be continuously scheduled for execution, so that even if the electronic device uses parallel sequential scheduling to execute the first target task in the first queue, it can ensure that the target tasks in the task set are executed serially, thereby ensuring that the target tasks can be executed in a preset execution order. In addition; based on this, the electronic device can schedule the first target task without considering the execution order of the first target task in the first queue, which simplifies the task scheduling process and improves the efficiency of task scheduling.
[0167] As an optional implementation, the first scheduling unit 906 is further configured to schedule a second number of first target tasks from the first queue to different threads for execution, where the second number is less than or equal to a thread number threshold.
[0168] By implementing the above device, the electronic device can flexibly schedule the second number of first target tasks from the first queue to different threads for execution, so that the number of second target tasks scheduled simultaneously is controllable, thereby improving the flexibility and controllability of the method.
[0169] As an optional implementation, each target task corresponds to a priority; Fig. 9 The device shown may also include a second scheduling unit not shown in the figure, wherein:
[0170] The second scheduling unit is used to schedule the first target task to be scheduled to a thread corresponding to the first priority for execution according to the first priority corresponding to the first target task to be scheduled.
[0171] By implementing the above device, the electronic device can schedule the first target task to be scheduled to a thread of corresponding priority for execution according to the priority of the first target task, so that the subsequent execution process of the first target task can obtain resource allocation corresponding to its priority, making the execution of the first target task controllable.
[0172] As an optional implementation, the second scheduling unit is further used to schedule the first target task to be scheduled to the idle thread for execution when there is currently an idle thread corresponding to the first priority;
[0173] Alternatively, when there is no idle thread corresponding to the first priority level, a new thread corresponding to the first priority level is created, and the first target task to be scheduled is scheduled to be executed in the new thread corresponding to the first priority level.
[0174] By implementing the above-mentioned device, the electronic device can preferentially reuse the idle threads corresponding to the first priority level to reduce the number of threads corresponding to the first priority level, thereby reducing the occupation of the memory space of the electronic device; in addition, when there is no idle thread corresponding to the first priority level, a new thread corresponding to the first priority level can be created to meet the demand of timely running the first target task, thereby improving the flexibility of the method.
[0175] See also Fig.10 , Fig.10 Schematic diagram of the structure of an electronic device disclosed in the embodiment of the present application. Fig.10 As shown, the electronic device may include:
[0176] A memory 1001 storing executable program codes;
[0177] A processor 1002 coupled to the memory 1001;
[0178] The processor 1002 calls the executable program code stored in the memory 1001 to execute the task scheduling method disclosed in the above embodiments.
[0179] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the task scheduling method disclosed in the above embodiments.
[0180] The embodiments of the present application also disclose an application publishing platform, wherein the application publishing platform is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes part or all of the steps of the method in the above method embodiments.
[0181] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0182] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0183] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0184] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0185] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present application.
[0186] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0187] The task scheduling method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A task scheduling method, characterized in that: The method comprises: Get multiple target tasks to be executed; Adding a first target task among the multiple target tasks to the first queue, and / or adding a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; The first target task in the first queue is scheduled to be executed in the thread, and when any first target task is completed, the second target task is scheduled from the second queue as the first target task to the first queue.
2. The method according to claim 1, characterized in that The adding a first target task among the plurality of target tasks to the first queue, and / or adding a second target task to the second queue, comprises: According to the execution order of the multiple target tasks, a first target task among the multiple target tasks is added to the first queue, and / or a second target task is added to the second queue.
3. The method according to claim 2, characterized in that The adding, according to the execution order of the multiple target tasks, a first target task among the multiple target tasks to the first queue, and / or adding a second target task to the second queue, comprises: If the execution order of the multiple target tasks is a parallel order, the multiple target tasks are respectively added to the first queue as first target tasks.
4. The method according to claim 2, characterized in that: The adding, according to the execution order of the multiple target tasks, a first target task among the multiple target tasks to the first queue, and / or adding a second target task to the second queue, comprises: If the execution order between the multiple target tasks is a parallel order, and the number of the multiple target tasks is greater than the first number, the first number of target tasks among the multiple target tasks are added as first target tasks to the first queue, and the other target tasks are added as second target tasks to the second queue; the other target tasks are the target tasks among the multiple target tasks except the first number of target tasks.
5. The method according to claim 2, characterized in that: The adding, according to the execution order of the multiple target tasks, a first target task among the multiple target tasks to the first queue, and / or adding a second target task to the second queue, comprises: If the execution order of the multiple target tasks is a serial order, the multiple target tasks are respectively added to the second queue as second target tasks.
6. The method according to claim 1, characterized in that The step of scheduling the second target task from the second queue as the first target task to the first queue includes: Binding a plurality of second target tasks having a dependency relationship among the second target tasks included in the second queue into a task set, and adding the task set as a first target task to the first queue, wherein the dependency relationship indicates that the plurality of second target tasks need to be executed serially; And, scheduling the first target task in the first queue to be executed in a thread includes: If the currently scheduled first target task contains multiple second target tasks with a dependent relationship, the second target task ranked first among the multiple second target tasks is scheduled to be executed in the thread; and, when the execution of the first second target task is completed, the next second target task is scheduled from the multiple second target tasks to be executed in the thread.
7. The method according to claim 1, characterized in that The step of scheduling the first target task in the first queue to be executed in a thread includes: A second number of first target tasks is scheduled from the first queue to different threads for execution, where the second number is less than or equal to a thread number threshold.
8. The method according to claim 1, characterized in that Each of the target tasks corresponds to a priority; the method further comprises: According to a first priority level corresponding to a first target task to be scheduled, the first target task to be scheduled is scheduled to be executed in a thread corresponding to the first priority level.
9. The method according to claim 8, characterized in that The step of scheduling the first target task to be scheduled to be executed in a thread corresponding to the first priority level includes: If there is currently an idle thread corresponding to the first priority, scheduling the first target task to be scheduled to be executed in the idle thread; If there is no idle thread corresponding to the first priority currently, a new thread corresponding to the first priority is created, and the first target task to be scheduled is scheduled to be executed in the new thread corresponding to the first priority.
10. A task scheduling device, characterized in that: The device comprises: An acquisition unit, used for acquiring a plurality of target tasks to be executed; an adding unit, configured to add a first target task among the plurality of target tasks to the first queue, and / or add a second target task to the second queue; the first target task is a target task that can be directly scheduled, and the second target task is a target task that cannot be directly scheduled; The first scheduling unit is used to schedule the first target task in the first queue to the thread for execution, and when any first target task is completed, schedule the second target task from the second queue as the first target task to the first queue.
11. An electronic device, characterized in that: It comprises a memory storing executable program code and a processor coupled to the memory; wherein the processor calls the executable program code stored in the memory to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.