Task scheduling method, electronic device, and computer-readable storage medium

By determining the time-consuming pattern of tasks in the task pool and scheduling them to the appropriate execution thread based on this, the problems of extended and stuck task execution are solved, and more efficient task execution is achieved.

CN114721791BActive Publication Date: 2025-10-03ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210234515.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-10
Publication Date
2025-10-03
Estimated Expiration
2042-03-10

AI Technical Summary

Technical Problem

In the prior art, the task execution time is prolonged and easily stuck, which cannot effectively shorten the task execution time.

Method used

By obtaining the to-be-executed tasks corresponding to the triggered events from the task pool, determining their time-consuming patterns, and determining the execution threads based on the time-consuming patterns, the tasks are then scheduled to the appropriate execution threads for execution.

Benefits of technology

It effectively avoids the delay of subsequent tasks caused by time-consuming tasks, shortens task execution time, improves the stuck phenomenon, and reduces thread switching overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721791B_ABST
    Figure CN114721791B_ABST
Patent Text Reader

Abstract

This application discloses a task scheduling method, electronic device, and computer-readable storage medium. The task scheduling method includes: obtaining pending tasks corresponding to triggered events from a task pool; determining the time consumption pattern of the pending tasks; determining an execution thread for the pending tasks based on the time consumption pattern; and executing the pending tasks using the execution thread. This method can shorten task execution latency and alleviate stuck situations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a task scheduling method, an electronic device, and a computer-readable storage medium. Background Art

[0002] When an event corresponding to a task in the task pool (also known as the thread pool or event pool) is triggered, an execution thread is required to execute the task to handle the event; at the same time, when other tasks in the task pool are subsequently executed, there will be no significant delay or even freezing due to the current execution of the task. Summary of the Invention

[0003] The main technical problem solved by this application is how to shorten the task execution delay and improve the stuck phenomenon.

[0004] To solve the above technical problems, this application adopts a technical solution: providing a task scheduling method. The task scheduling method includes: obtaining the pending task corresponding to the triggered event from a task pool; determining the time consumption pattern of the pending task; determining the execution thread of the pending task based on the time consumption pattern, and executing the pending task using the execution thread.

[0005] In order to solve the above technical problems, a technical solution adopted in this application is: to provide an electronic device, which includes a processor and a memory coupled to the processor, and the processor is used to execute program instructions stored in the memory to achieve: obtaining the task to be executed corresponding to the triggered event from the task pool; determining the time consumption mode of the task to be executed; determining the execution thread of the task to be executed based on the time consumption mode, and using the execution thread to execute the task to be executed.

[0006] In order to solve the above technical problems, a technical solution adopted in this application is: providing a computer-readable storage medium on which program instructions are stored, which, when executed by a processor, implement: obtaining the to-be-executed task corresponding to the triggered event from the task pool; determining the time-consuming pattern of the to-be-executed task; determining the execution thread of the to-be-executed task based on the time-consuming pattern, and using the execution thread to execute the to-be-executed task.

[0007] The beneficial effect of the present application is that, unlike the prior art, the task scheduling method of the present application first obtains the to-be-executed task corresponding to the triggered event from the task pool, then determines the time-consuming pattern of the to-be-executed task, and finally determines the execution thread of the to-be-executed task based on the time-consuming pattern, and uses the execution thread to execute the to-be-executed task. In this way, the present application determines the execution thread of the to-be-executed task based on the time-consuming pattern of the to-be-executed task, and can schedule to-be-executed tasks with different time-consuming times to different execution threads for execution, thereby avoiding the long-consuming to-be-executed task from causing a significant delay to the subsequent to-be-executed tasks, shortening the task execution delay and improving the stuck phenomenon. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1 This is a flowchart of an embodiment of the task scheduling method of the present application;

[0009] Figure 2 yes Figure 1 Specific flow diagram of step S12 in the embodiment;

[0010] Figure 3 This is a schematic diagram of the short cycle time of this application task;

[0011] Figure 4 This is a schematic diagram of the long cycle time of this application task;

[0012] Figure 5 This is a schematic diagram showing the alternating length of the application task cycle;

[0013] Figure 6 yes Figure 1 Specific flow diagram of step S13 in the embodiment;

[0014] Figure 7 This is a schematic diagram of the irregular short time consumption of this application task;

[0015] Figure 8 yes Figure 1 Specific flow diagram of step S13 in the embodiment;

[0016] Figure 9 This is a flowchart of an embodiment of the task scheduling method of the present application;

[0017] Figure 10 This is a structural diagram of an embodiment of an electronic device of the present application;

[0018] Figure 11 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0020] The task pool provides a kind of class library to realize distributed task queue.The task scheduling method of the present embodiment can be used for distributed or independent nodes. The node is mainly composed of a registration center, a scheduling task and a task pool. The nodes are all provided with their own servers and memories. The registration center is used for scheduling tasks and task registration. The task pool (thread pool) in the node contains multiple independent threads, which is responsible for the actual execution of the specific task instance extracted. When the node starts, it will self-register and register the task information that can be executed in the registration node, including information such as task type and task quantity. The number of tasks or task types that the node can be used for actual task execution can be the same or different.

[0021] Backend real-time processing business platforms usually decompose data input and output into logical tasks of different stages or granularities according to the timeline (hereinafter referred to as task sequence), and each piece of data to be processed can be called a task (or event, message).

[0022] The task pool requires a management class to manage threads and their pending tasks of the same type. Threads wait to execute tasks fed to them. When the number of tasks exceeds the number of threads, tasks are queued. When the number of threads exceeds the number of tasks, threads are suspended in a blocked waiting state.

[0023] This application first proposes a task scheduling method, such as Figure 1 As shown, Figure 1 This is a flow chart of an embodiment of the task scheduling method of the present application. The task scheduling method of this embodiment specifically includes the following steps:

[0024] Step S11: Obtain the to-be-executed task corresponding to the triggered event from the task pool.

[0025] When an event is triggered, a task request message is generated, including scheduled tasks and event tasks. Scheduled tasks refer to tasks that are executed at regular intervals according to a certain time frequency; event tasks are tasks that are triggered and executed in real time; the task request message is submitted to the task pool, that is, the task queue, and when the submission is completed, it starts to monitor the execution status of the tasks to be executed in the task pool; the task scheduling engine monitors the task pool, and when a new task request message is found in the task pool, it immediately obtains the task request message, parses the task request message, and obtains the task registration message; and obtains the task execution message according to the task type of the task registration message.

[0026] Step S12: Determine the time consumption pattern of the task to be executed.

[0027] Optionally, this embodiment can be implemented as follows Figure 2 The method shown implements step S12. The method of this embodiment includes steps S21 and S22.

[0028] Step S21: Obtain the execution history record of the processing function of the task to be executed.

[0029] From the above analysis, we can see that when a node is started, the registration center will register the task and register the task information that can be executed in the node. In addition to the task type and task quantity, the task information also includes the task processing function.

[0030] The task scheduling engine obtains the execution history records of the processing function of the task to be executed to obtain the historical time consumption information of the task execution.

[0031] Step S22: predicting the time consumption pattern of the task to be executed based on the execution history records.

[0032] In this embodiment, the task scheduling engine can obtain the time consumption pattern of the user executing the task based on the historical time consumption information of the task processing function.

[0033] The task scheduling engine counts the time consumed each time a task is processed by its processing function, and obtains the time consumption pattern of the task based on information such as the relationship between the time consumption and the threshold and the regularity of the time consumption.

[0034] Step S13: determining an execution thread for the task to be executed based on the time consumption pattern, and executing the task to be executed using the execution thread.

[0035] The task scheduling engine determines the execution thread of the task to be executed based on the time consumption pattern, and sends the task execution message to the execution thread so that the execution thread executes the task to be executed.

[0036] Different from the existing technology, the task scheduling method of this embodiment first obtains the pending task corresponding to the triggered event from the task pool, then determines the time consumption pattern of the pending task, and finally determines the execution thread of the pending task based on the time consumption pattern, and uses the execution thread to execute the pending task. In this way, this embodiment determines the execution thread of the pending task based on the time consumption pattern of the pending task, and can schedule pending tasks with different time consumption to different execution threads for execution, thereby preventing the long-time pending task from causing significant delays to the subsequent pending tasks, shortening the task execution delay and improving the stuck phenomenon.

[0037] Optionally, in one embodiment, the time consumption mode includes a periodic short time consumption mode. From the above analysis, it can be seen that the input and output of each task are decomposed into task sequences of different stages or different granularities according to the time axis. The periodic short time consumption of a task means that the time consumption of each task sequence of the task is less than the first threshold, such as Figure 3 shown.

[0038] If the task scheduling engine predicts that the time consumption mode of the task to be executed is a periodic short time consumption mode, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, and the current listening thread retains the event monitoring right of the task pool, that is, the task registration processing function is directly called by the current listening thread of the task pool (the current listening thread is switched to the execution mode), and the event monitoring right of the task pool is temporarily reserved for the current listening thread, which can avoid the thread switching overhead.

[0039] Optionally, the time consumption mode of this embodiment includes a periodic long time consumption mode; the periodic long time consumption of a task means that the time consumption of each task sequence of the task is greater than a second threshold value (which may be the same as or different from the first threshold value), such as Figure 4 shown.

[0040] If the task scheduling engine predicts that the time-consuming mode is a periodic long-time-consuming mode, the general execution thread of the task pool is determined to be the execution thread of the task to be executed; specifically, the task scheduling engine can schedule the task to be executed to the executor of the task pool (the task is executed by the general execution thread), and the event monitoring right of the task pool is reserved for the current monitoring thread. Since the time required for the task to be executed in the periodic long-time-consuming mode is relatively long, it will cause a significant delay to the tasks to be executed that are queued up later. Therefore, the present embodiment schedules the task to be executed in the periodic long-time-consuming mode to the executor of the task pool, which can avoid causing a significant delay to the tasks to be executed that are queued up later; and there is no need to switch the event monitoring right of the task pool, so that the general execution thread has the effect of maximum shared execution.

[0041] Optionally, in another embodiment, the time consumption mode of this embodiment includes a periodic long and short time consumption alternation mode, a periodic short time consumption mode (refer to the above introduction) and a periodic long time consumption mode (refer to the above introduction); the periodic long and short time consumption alternation of tasks refers to the alternation of the time consumption of the task sequence of the tasks, such as Figure 5 shown.

[0042] This embodiment can be used as Figure 6 The method shown implements step S13. The method of this embodiment includes steps S61 to S64.

[0043] Step S61 : If the time consumption pattern is a periodic alternating pattern of long and short time consumption, then predict the time consumption pattern of the current task sequence of the task to be executed.

[0044] If the task scheduling engine predicts that the time consumption pattern is a periodic long and short time consumption alternating pattern, multiple task timings of the task are scheduled in sequence, and the time consumption pattern is predicted for the current task timing.

[0045] Step S62: If the time consumption mode of the current task sequence is the periodic short time consumption mode, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, and the current listening thread retains the event monitoring right of the task pool.

[0046] Step S63: If the time consumption mode of the current task sequence is a periodic long time consumption mode, the general execution thread of the task pool is determined as the execution thread of the task to be executed.

[0047] Step S64: Utilize the execution thread to execute the task to be executed.

[0048] Step S62 and step S63 can refer to the above embodiment and are not described in detail here.

[0049] This embodiment adopts a scheduling strategy corresponding to the time consumption pattern for each task sequence for tasks with periodic alternating long and short time consumption patterns, which can further shorten the task execution delay and improve the stuck phenomenon.

[0050] Optionally, in another embodiment, the time consumption pattern of this embodiment includes an irregular time consumption pattern; the irregular time consumption of a task refers to the irregularity of the time consumption of the task sequence, such as Figure 7 shown.

[0051] This embodiment can be used as Figure 8 The method shown implements step S13. The method of this embodiment includes steps S81 to S85.

[0052] Step S81: If the time consumption pattern is an irregular time consumption pattern, determine whether there is an idle thread in the task pool.

[0053] If the task scheduling engine predicts that the time consumption pattern is an irregular time consumption pattern, it is determined whether there are idle threads in the task pool.

[0054] Step S82: If yes, determine that the current listening thread of the task pool is the execution thread of the task to be executed.

[0055] If the task scheduling engine determines that there are idle threads in the task pool, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, that is, the processing function of the task registration is directly called by the current listening thread of the task pool (the current listening thread is switched to execution mode).

[0056] Step S83: Authorize the event monitoring right of the task pool to other threads of the task pool.

[0057] The task scheduling engine takes back the event monitoring right of the current monitoring thread and authorizes the event monitoring right of the task pool to the next thread of the task pool.

[0058] Step S84: If not, determine the general execution thread of the task pool as the execution thread of the task to be executed.

[0059] If the task scheduling engine determines that there are idle threads in the task pool, the general execution thread of the task pool is determined to be the execution thread of the task to be executed; specifically, the task scheduling engine can schedule the task to be executed to the executor of the task pool (the general execution thread executes the task), and reserve the event monitoring right of the task pool to the current monitoring thread. When there are no idle threads in the task pool, this embodiment schedules the task to be executed with irregular time-consuming patterns to the executor of the task pool, which can avoid causing significant delays to the tasks to be executed that are queued up later; and there is no need to switch the event monitoring right of the task pool, so that the general execution thread has the effect of maximum shared execution.

[0060] Step S85: Utilize the execution thread to execute the task to be executed.

[0061] Please refer to the above embodiments for details.

[0062] In another embodiment, Figure 9 As shown, the thread TaskThread[n] of the task pool TaskPool[x] is authorized to listen to the event pool, that is, the task pool; the thread TaskThread[n] receives the event message, that is, the task request message, and finds the corresponding task to be executed Task and the historical record of this Task executing the user registration processing function (the processing function of the task to be executed).

[0063] If the time consumption mode of the task to be executed is predicted to be a short-cycle time consumption mode based on historical records, the thread TaskThread[n] directly calls the processing function registered by the user and retains the ownership of the event pool monitoring, that is, the event monitoring right of the task pool; further, if the thread TaskThread[n] directly calls the processing function registered by the user and returns successfully, then the step of returning to the above-mentioned task pool TaskThread[n] being authorized to monitor the event pool is returned; if the thread TaskThread[n] directly calls the processing function registered by the user and does not return successfully, the task pool TaskPool[x] takes back the event monitoring right, isolates the current thread TaskThread[n], and starts another thread TaskThread[n], that is, in response to the failure of the execution thread to execute the task to be executed, the event monitoring right of the execution thread is authorized to other threads in the task pool, and the execution thread is isolated.

[0064] If the time consumption mode of the task to be executed is predicted to be a long period time consumption mode based on historical records, the task to be executed is scheduled to the executor TaskPool_Executor of the task pool, and the step of returning to the thread TaskThread[n] of the task pool TaskPool[x] being authorized to listen to the event pool is returned.

[0065] Based on historical records, if the time consumption pattern of the task to be executed is predicted to be a time consumption pattern of alternating long and short cycles, the time consumption pattern of the current task sequence of the task to be executed is further predicted, and based on the prediction results, the above strategy is used for task scheduling.

[0066] If the time consumption pattern of the task to be executed is predicted to be an irregular time consumption pattern based on historical records, it is determined whether there is an idle thread TaskThread in the task pool TaskPool[x]. If so, the task pool TaskPool[x] reclaims the event pool monitoring right, and the current thread TaskThread[n] switches to the Executor execution mode, enables another thread TaskThread[n] to monitor, and returns to the step where the thread TaskThread[n] of the above task pool TaskPool[x] is authorized to monitor the event pool; if not, the task to be executed is scheduled to the executor TaskPool_Executor of the task pool, and returns to the step where the thread TaskThread[n] of the above task pool TaskPool[x] is authorized to monitor the event pool.

[0067] This application further proposes an electronic device, such as Figure 10 As shown, Figure 10 The electronic device 100 of this embodiment includes a processor 101 , a memory 102 coupled to the processor 101 , an input / output device 103 , and a bus 104 .

[0068] The processor 101, memory 102, and input / output device 103 are respectively connected to the bus 104. The memory 102 stores program data. The processor 101 is used to execute the program data to achieve: obtaining the to-be-executed task corresponding to the triggered event from the task pool; determining the time consumption pattern of the to-be-executed task; determining the execution thread of the to-be-executed task based on the time consumption pattern, and using the execution thread to execute the to-be-executed task.

[0069] When the processor 101 executes the program data, the task scheduling method of the above embodiment is also implemented.

[0070] In this embodiment, the processor 101 may also be referred to as a CPU (Central Processing Unit). The processor 101 may be an integrated circuit chip having signal processing capabilities. The processor 101 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or the processor 101 may be any conventional processor.

[0071] This application further proposes a computer-readable storage medium, such as Figure 11 As shown, Figure 11 The present invention is a schematic diagram of the structure of an embodiment of a computer-readable storage medium of the present invention. Computer-readable storage medium 1001 stores program instructions 1002 thereon. When executed by a processor (not shown), program instructions 1002: retrieve a pending task corresponding to a triggered event from a task pool; determine a time consumption pattern for the pending task; determine an execution thread for the pending task based on the time consumption pattern; and execute the pending task using the execution thread.

[0072] When the program instructions 1002 are executed by the processor, the task scheduling method of the above embodiment is also implemented.

[0073] The computer-readable storage medium 1001 of this embodiment can be, but is not limited to, a USB flash drive, an SD card, a PD optical drive, a mobile hard drive, a large-capacity floppy drive, a flash memory, a multimedia memory card, a server, etc.

[0074] The task scheduling method of the present application first obtains the to-be-executed task corresponding to the triggered event from the task pool, then determines the time-consuming pattern of the to-be-executed task, and finally determines the execution thread of the to-be-executed task based on the time-consuming pattern, and uses the execution thread to execute the to-be-executed task. In this way, the present application determines the execution thread of the to-be-executed task based on the time-consuming pattern of the to-be-executed task, and can schedule to-be-executed tasks with different time-consuming times to different execution threads for execution, thereby avoiding the long-consuming to-be-executed task from causing a significant delay to the subsequent to-be-executed tasks, shortening the task execution delay and improving the stuck phenomenon.

[0075] Furthermore, the present application can achieve the minimum number of execution thread switches, and directly benefit from this part of the switching overhead on the execution thread.

[0076] In addition, if the above functions are implemented as software functions and sold or used as independent products, they can be stored in a storage medium readable by a mobile terminal. That is, the present application also provides a storage device storing program data, which can be executed to implement the methods of the above embodiments. The storage device can be, for example, a USB flash drive, an optical disk, a server, etc. In other words, the present application can be embodied in the form of a software product, which includes a number of instructions for causing a smart terminal to execute all or part of the steps of the methods described in each embodiment.

[0077] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0078] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of such features. Throughout the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.

[0079] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application belong.

[0080] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (which can be a personal computer, server, network device, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.

[0081] The above description is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A task scheduling method, characterized in that: include: Get the pending tasks corresponding to the triggered events from the task pool; Determining a time consumption pattern of the task to be performed; Determining an execution thread for the task to be executed based on the time consumption pattern, and executing the task to be executed using the execution thread; The step of determining the time consumption mode of the task to be executed includes: Obtain the execution history of the processing function of the task to be executed to obtain the historical time consumption information of the task processing function; Based on the relationship between historical time consumption information and thresholds, as well as time consumption regularity information, the time consumption pattern of executing tasks is obtained; The time-consuming mode includes a periodic short time-consuming mode; and determining the execution thread of the task to be executed based on the time-consuming mode includes: If the time-consuming mode is the periodic short time-consuming mode, determining the current listening thread of the task pool as the execution thread of the task to be executed, and retaining the event monitoring right of the current listening thread to the task pool; The time consumption pattern includes a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time-consuming mode is the periodic long time-consuming mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes a periodic long and short time consumption alternating pattern, a periodic short time consumption pattern, and a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the periodic long and short time consumption alternating pattern, predicting the time consumption pattern of the current task sequence of the task to be executed; If the time consumption mode of the current task sequence is the periodic short time consumption mode, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, and the event monitoring right of the current listening thread to the task pool is reserved; If the time consumption mode of the current task sequence is the periodic long time consumption mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes an irregular time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the irregular time consumption pattern, determining whether there is an idle thread in the task pool; If yes, determining that the current listening thread of the task pool is the execution thread of the task to be executed; Authorize the event monitoring right of the task pool to other threads of the task pool; The determining of the execution thread of the task to be executed based on the time consumption pattern further includes: If not, the general execution thread of the task pool is determined to be the execution thread of the task to be executed.

2. The task scheduling method according to claim 1, characterized in that: Further including: In response to the execution thread failing to execute the task to be executed, authorizing the event monitoring right of the execution thread to other threads in the task pool; The execution thread is isolated.

3. An electronic device, characterized in that: The electronic device includes a processor and a memory coupled to the processor, wherein the processor is configured to execute program instructions stored in the memory to implement: Get the pending tasks corresponding to the triggered events from the task pool; Determining a time consumption pattern of the task to be performed; Determining an execution thread for the task to be executed based on the time consumption pattern, and executing the task to be executed using the execution thread; The step of determining the time consumption mode of the task to be executed includes: Obtain the execution history of the processing function of the task to be executed to obtain the historical time consumption information of the task processing function; Based on the relationship between historical time consumption information and thresholds, as well as time consumption regularity information, the time consumption pattern of executing tasks is obtained; The time-consuming mode includes a periodic short time-consuming mode; and determining the execution thread of the task to be executed based on the time-consuming mode includes: If the time-consuming mode is the periodic short time-consuming mode, determining the current listening thread of the task pool as the execution thread of the task to be executed, and retaining the event monitoring right of the current listening thread to the task pool; The time consumption pattern includes a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time-consuming mode is the periodic long time-consuming mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes a periodic long and short time consumption alternating pattern, a periodic short time consumption pattern, and a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the periodic long and short time consumption alternating pattern, predicting the time consumption pattern of the current task sequence of the task to be executed; If the time consumption mode of the current task sequence is the periodic short time consumption mode, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, and the event monitoring right of the current listening thread to the task pool is reserved; If the time consumption mode of the current task sequence is the periodic long time consumption mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes an irregular time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the irregular time consumption pattern, determining whether there is an idle thread in the task pool; If yes, determining that the current listening thread of the task pool is the execution thread of the task to be executed; Authorize the event monitoring right of the task pool to other threads of the task pool; The determining of the execution thread of the task to be executed based on the time consumption pattern further includes: If not, the general execution thread of the task pool is determined to be the execution thread of the task to be executed.

4. A computer-readable storage medium, characterized in that Program instructions are stored thereon, which, when executed by a processor, implement: Get the pending tasks corresponding to the triggered events from the task pool; Determining a time consumption pattern of the task to be performed; Determining an execution thread for the task to be executed based on the time consumption pattern, and executing the task to be executed using the execution thread; The step of determining the time consumption mode of the task to be executed includes: Obtain the execution history of the processing function of the task to be executed to obtain the historical time consumption information of the task processing function; Based on the relationship between historical time consumption information and thresholds, as well as time consumption regularity information, the time consumption pattern of executing tasks is obtained; The time-consuming mode includes a periodic short time-consuming mode; and determining the execution thread of the task to be executed based on the time-consuming mode includes: If the time-consuming mode is the periodic short time-consuming mode, determining the current listening thread of the task pool as the execution thread of the task to be executed, and retaining the event monitoring right of the current listening thread to the task pool; The time consumption pattern includes a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time-consuming mode is the periodic long time-consuming mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes a periodic long and short time consumption alternating pattern, a periodic short time consumption pattern, and a periodic long time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the periodic long and short time consumption alternating pattern, predicting the time consumption pattern of the current task sequence of the task to be executed; If the time consumption mode of the current task sequence is the periodic short time consumption mode, the current listening thread of the task pool is determined to be the execution thread of the task to be executed, and the event monitoring right of the current listening thread to the task pool is reserved; If the time consumption mode of the current task sequence is the periodic long time consumption mode, determining the general execution thread of the task pool as the execution thread of the task to be executed; The time consumption pattern includes an irregular time consumption pattern; and determining the execution thread of the task to be executed based on the time consumption pattern includes: If the time consumption pattern is the irregular time consumption pattern, determining whether there is an idle thread in the task pool; If yes, determining that the current listening thread of the task pool is the execution thread of the task to be executed; Authorize the event monitoring right of the task pool to other threads of the task pool; The determining of the execution thread of the task to be executed based on the time consumption pattern further includes: If not, the general execution thread of the task pool is determined to be the execution thread of the task to be executed.

Citation Information

Patent Citations

  • Task processing method and device

    CN112181640A