Task execution method, device, electronic device and computer readable medium

By obtaining the target task according to the task queue priority and determining the method of performing time films in real time, the problem of low task execution efficiency in the existing technology and the large consumption of memory resources have been solved, and more efficient task execution and lower resource consumption have been achieved.

CN112685156BActive Publication Date: 2025-01-28BEIJING 58 INFORMATION TTECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011578565.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-28
Publication Date
2025-01-28
Estimated Expiration
2040-12-28

AI Technical Summary

Technical Problem

The prior art requires artificially setting a fixed time slice in advance when executing tasks, making it difficult to dynamically and flexibly determine the time slice required for task execution, resulting in frequent tasks switching, reducing task execution efficiency, and increasing memory resource consumption.

Method used

According to the task queue of each task queue in the task queue collection, obtain the target task from the task queue collection, and determine the execution time film of the target task in real time to dynamically and flexibly adjust the time film required for the task execution.

Benefits of technology

By prioritizing high -priority tasks and dynamically adjusting the execution time film, the problem of frequent tasks switching is eased, the task execution efficiency is improved, and the consumption of memory resources is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112685156B_ABST
    Figure CN112685156B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a task execution method, device, electronic device and computer-readable medium. A specific implementation of the method includes: obtaining a target task from the task queue set according to the task queue priority of each task queue in the task queue set; determining the execution time slice of the target task; and executing the target task according to the execution time slice. This implementation realizes the dynamic and flexible generation of the time slice required for task execution, improves the task execution efficiency, and reduces the consumption of memory resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a task execution method, device, electronic device, and computer-readable medium. Background Art

[0002] Task execution is a method of taking a task out of a task queue and executing it. At present, when executing a task, the method usually adopted is: executing the task according to a preset time slice. For example, a corresponding time slice is set for the task queue in advance, and when the task in the task queue needs to be executed, the task in the task queue is executed within the preset time slice.

[0003] However, when the above method is used to perform tasks, the following technical problems often occur:

[0004] It is necessary to manually set a fixed time slice for the task queue in advance, and it is difficult to dynamically and flexibly determine the time slice required for task execution. As a result, tasks that require a long execution time may not be completed within the preset time slice and be forcibly interrupted. In turn, it leads to more frequent switching between different tasks, reducing task execution efficiency and increasing memory resource consumption. Summary of the invention

[0005] The content of this disclosure is used to introduce concepts in a brief form, which will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection.

[0006] Some embodiments of the present disclosure propose a task execution method, an apparatus, an electronic device, and a computer-readable medium to solve one or more of the technical problems mentioned in the above background technology section.

[0007] In a first aspect, some embodiments of the present disclosure provide a task execution method, the method comprising: obtaining a target task from the task queue set according to the task queue priority of each task queue in the task queue set; determining an execution time slice of the target task; and executing the target task according to the execution time slice.

[0008] In the second aspect, some embodiments of the present disclosure provide a task execution device, which includes: an acquisition unit, configured to acquire a target task from the task queue set according to the task queue priority of each task queue in the task queue set; a determination unit, configured to determine an execution time slice of the target task; and an execution unit, configured to execute the target task according to the execution time slice.

[0009] In a third aspect, some embodiments of the present disclosure provide an electronic device comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the above-mentioned first aspect.

[0010] In a fourth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any implementation manner of the above-mentioned first aspect is implemented.

[0011] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: first, according to the task queue priority of each task queue in the task queue set, the target task is obtained from the above-mentioned task queue set. Thus, in the process of obtaining the target task, the different task queue priorities are taken into account, and the tasks with higher priority in the task queue can be processed preferentially to ensure that the high-priority tasks are executed preferentially. Then, the execution time slice of the above-mentioned target task is determined. Thus, when the target task is taken out for execution, the execution time slice required for the target task is determined in real time, so as to achieve the effect of dynamically and flexibly determining the time slice required for task execution. Finally, according to the above-mentioned execution time slice, the above-mentioned target task is executed. Thus, when executing tasks according to a preset fixed time slice, the situation of frequent switching of tasks caused by forced interruption due to the target task with a longer execution time cannot be completed within the preset time slice when executing tasks can be alleviated to a certain extent. Thus, the present disclosure can avoid frequent switching of tasks, improve task execution efficiency and reduce the consumption of memory resources to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0013] Figure 1 is a schematic diagram of an application scenario of a task execution method according to some embodiments of the present disclosure;

[0014] Figure 2 is a flow chart of some embodiments of the task execution method according to the present disclosure;

[0015] Figure 3 are flowcharts of other embodiments of the task execution method according to the present disclosure;

[0016] Figure 4 is a schematic diagram of a storage form of historical execution records in other embodiments of the task execution method according to the present disclosure;

[0017] Figure 5 is a schematic diagram of the structure of some embodiments of the task execution device according to the present disclosure;

[0018] Figure 6 It is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

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

[0020] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

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

[0022] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

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

[0024] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0025] Figure 1 It is a schematic diagram of an application scenario of the task execution method of some embodiments of the present disclosure.

[0026] exist Figure 1 In the application scenario, first, the computing device 101 can obtain the target task 103 from the task queue set 102 according to the task queue priority of each task queue in the task queue set 102. Then, the computing device 101 can determine the execution time slice 104 of the target task 103. Finally, the computing device 101 can execute the target task 103 according to the execution time slice 104.

[0027] It should be noted that the computing device 101 can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is embodied as software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made here.

[0028] It should be understood that Figure 1 The number of computing devices in the embodiment is only illustrative. Any number of computing devices may be provided according to implementation requirements.

[0029] Specifically, the reason for frequent task switching, reduced task execution efficiency, and increased memory resource consumption is that it is difficult to dynamically and flexibly adjust the time slices when executing tasks according to a pre-set fixed time slice. Based on this, the above problems can be solved by the steps in process 200 or 300 of some embodiments of the task execution method disclosed in the present invention.

[0030] Continue to refer Figure 2 , shows a process 200 of some embodiments of the task execution method according to the present disclosure. The task execution method comprises the following steps:

[0031] Step 201 , obtaining a target task from the task queue set according to the task queue priority of each task queue in the task queue set.

[0032] In some embodiments, the execution subject of the task execution method (such as Figure 1 The computing device 101 shown in the figure can obtain the target task from the above-mentioned task queue set according to the task queue priority of each task queue in the task queue set. Wherein, each task queue in the above-mentioned task queue set has different task queue priorities. The task queue priority of the above-mentioned task queue can be represented by a number. It can be agreed in advance that the larger the number, the higher the priority of the task queue represented. The task queue priority of the above-mentioned task queue can be preset. The tasks in the above-mentioned task queue can be computer processes. The above-mentioned target task can be the task at the head of the task queue whose product value of the task queue priority and the number of tasks included in the task queue is the largest.

[0033] As an example, the above task queue set may include three task queues. The task queue priorities of the three task queues may be 1, 2 and 3 respectively. Then the task queue with a task queue priority of 3 has the highest priority. The task queue with a task queue priority of 1 has the lowest priority.

[0034] In some optional implementations of some embodiments, the execution subject obtains the target task from the task queue set, which may include the following steps:

[0035] In the first step, a task queue that meets a preset condition is selected from the task queue set as the first target task queue, wherein the preset condition may be: the task queue is the task queue with the highest priority among all non-empty task queues in the task queue set.

[0036] The second step is to obtain the target task from the first target task queue, wherein the task at the head of the first target task queue can be used as the target task.

[0037] In the above implementation, different priorities of task queues are taken into consideration in the process of acquiring target tasks, and tasks with higher priorities in the task queues can be processed preferentially to ensure that tasks with higher priorities are executed first.

[0038] In some optional implementations of some embodiments, the tasks in the above-mentioned task queues may have task priorities. The above-mentioned tasks may be added to the corresponding task queues in the above-mentioned task queue set according to the above-mentioned task priorities. Wherein, the task priority of the task may be artificially pre-set. The representation method of the task priority may be the same as the task queue priority. Then, according to the task priority of the above-mentioned task, the above-mentioned task may be added to the task queue in the above-mentioned task queue set whose task queue priority is the same as the task priority of the above-mentioned task.

[0039] Step 202: determine the execution time slice of the target task.

[0040] In some embodiments, the execution subject may determine the execution time slice of the target task by multiplying the number of tasks included in the first target task queue by the average time slice, wherein the average time slice may be the average execution time of each historical task stored in the task queue set.

[0041] In the above manner, the execution time slice of the target task is dynamically determined according to the number of tasks included in the first target task queue, so that when there are many tasks, the tasks can be executed in a complete time slice as much as possible. It can avoid the tasks that require a long execution time from being frequently terminated to a certain extent, and reduce the consumption of resources such as memory by too frequent task switching.

[0042] Step 203, executing the target task according to the execution time slice.

[0043] In some embodiments, the execution subject may allocate a CPU (Central Processing Unit) occupancy time to the target task according to the execution time slice, so that the target task is executed within the CPU occupancy time. The CPU occupancy time is equal to the time represented by the execution time slice.

[0044] As an example, the execution time slice may be 100 seconds, and a CPU occupancy time of 100 seconds may be allocated to the target task, so that the target task is executed within the CPU occupancy time of 100 seconds.

[0045] In the above implementation, the target task is executed according to the real-time dynamically determined execution time slice, which can alleviate the frequent switching of tasks caused by the forced interruption of the target task with a long execution time that cannot be completed within the preset time slice when executing tasks according to the preset fixed time slice to a certain extent.

[0046] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: first, according to the task queue priority of each task queue in the task queue set, the target task is obtained from the above-mentioned task queue set. Thus, in the process of obtaining the target task, the different task queue priorities are taken into account, and the tasks with higher priority in the task queue can be processed preferentially to ensure that the high-priority tasks are executed preferentially. Then, the execution time slice of the above-mentioned target task is determined. Thus, when the target task is taken out for execution, the execution time slice required for the target task is determined in real time, so as to achieve the effect of dynamically and flexibly determining the time slice required for task execution. Finally, according to the above-mentioned execution time slice, the above-mentioned target task is executed. Thus, when executing tasks according to a preset fixed time slice, the situation of frequent switching of tasks caused by forced interruption due to the target task with a longer execution time cannot be completed within the preset time slice when executing tasks can be alleviated to a certain extent. Thus, the present disclosure can avoid frequent switching of tasks, improve task execution efficiency and reduce the consumption of memory resources to a certain extent.

[0047] Further references Figure 3 , which shows a process 300 of another embodiment of a task execution method. The process 300 of the task execution method includes the following steps:

[0048] Step 301 , obtaining a target task from the task queue set according to the task queue priority of each task queue in the task queue set.

[0049] In some embodiments, the specific implementation of step 301 and the technical effects thereof can be referred to in Figure 2 The corresponding step 201 in the embodiments will not be described in detail here.

[0050] Step 302 : In response to determining that there is no basic time slice corresponding to the target task, determine whether there is a historical execution record of the target task.

[0051] In some embodiments, the execution entity may determine whether there is a historical execution record of the target task in response to determining that there is no basic time slice corresponding to the target task. The basic time slice may be determined when the target task is taken out for execution for the first time after it is added to the task queue set. After determination, the basic time slice may be recorded in the cache until it is cleared from the cache after the target task is executed. The historical execution record may include the historical execution durations of the target task. The historical execution duration may be the sum of the time slices occupied by a complete execution of the target task. The historical execution record of the target task may be searched in a database. This query method requires pre-storing the historical execution duration of the target task in the database. Reference Figure 4 ,The above historical execution records can be stored in a database in the form of a table.

[0052] Step 303: In response to determining that there is a historical execution record, determine a basic time slice according to the historical execution record.

[0053] In some embodiments, the execution subject may determine the basic time slice according to the historical execution record in response to determining that the historical execution record exists.

[0054] As an example, the arithmetic mean of each historical execution duration included in the historical execution record may be determined as the basic time slice.

[0055] As another example, each historical execution time included in the above historical execution record is linearly fitted to obtain the above basic time slice. Each of the above historical execution times can be input into a time series prediction model for linear fitting to obtain the above basic time slice. The above time series prediction model can be a linear trend model, a logarithmic linear trend model or fbprophet (Facebook Prophet), etc. This linear fitting method requires pre-eliminating abnormal historical execution times in historical execution records. The above abnormal historical execution time may refer to an execution time that is too long or too short caused by abnormal task execution. The abnormal historical execution time in the above historical execution record can be determined by an outlier analysis method. The above outlier analysis method can be Interquartile Range, z-score, Isolation Forest, etc.

[0056] In some optional implementations of some embodiments, the execution subject may determine the preset basic time slice as the basic time slice in response to determining that the historical execution record does not exist. The preset basic time slice may be manually set in advance. If the historical execution record of the target task cannot be found in the database, the preset basic time slice is determined as the basic time slice.

[0057] Step 304: Determine the execution time slice according to the basic time slice.

[0058] In some embodiments, the execution entity may determine the execution time slice as the product value of the number of tasks included in the first target task queue and the basic time slice.

[0059] In some optional implementations of some embodiments, the execution subject determines the execution time slice according to the basic time slice, which may include the following steps:

[0060] The first step is to adjust the above basic time slice using the following formula to obtain the adjusted basic time slice:

[0061]

[0062] Wherein, T1 represents the adjusted basic time slice. T0 represents the basic time slice. M represents the total memory of the execution subject. m represents the basic memory allocated by the execution subject for the target task. R represents the total number of tasks currently being executed in the execution subject.

[0063] The second step is to determine the execution time slice according to the adjusted basic time slice and the task queue priority of the task queue corresponding to the target task, wherein the task queue corresponding to the target task may be the task queue where the target task was before being taken out for execution.

[0064] As an example, the product value of the adjusted basic time slice and the task queue priority of the task queue corresponding to the target task may be determined as the execution time slice.

[0065] As an inventive point of the embodiment of the present disclosure, the above steps 302-304 further solve the technical problem mentioned in the background technology that "frequent task switching reduces task execution efficiency and increases memory resource consumption". The factors that lead to relatively frequent task switching, reduce task execution efficiency, and increase memory resource consumption are often as follows: the existing task execution method needs to execute the tasks in the task queue within a pre-set time slice, and this method is difficult to dynamically and flexibly determine the time slice required for task execution. If the above factors are solved, the effect of avoiding frequent task switching, improving task execution efficiency, and reducing memory resource consumption can be achieved to a certain extent. In order to achieve this effect, the present disclosure first introduces the historical execution record of the target task, and determines the basic time slice of the target task based on the historical execution record. The historical execution record provides a historical reference basis for the determination of the basic time slice. Therefore, the reference value of the historical execution time is taken into account when determining the final execution time slice. Make the determined execution time slice more in line with the actual law of task execution. Then, according to the task execution status in the current execution subject, the basic time slice is adjusted. When the total number of tasks being executed in the execution subject is large and the memory resource occupancy is high, the load and pressure in the execution subject are large, and the task execution speed is slow. At this time, appropriately increasing the basic time slice can ensure the smooth execution of the task and avoid excessive consumption of memory resources by frequent switching of tasks. Finally, the adjusted basic time slice is further adjusted according to the priority of the task queue, and the execution time slice of the task in the task queue with a higher priority is further increased to improve its execution efficiency. Thus, the present disclosure further improves the efficiency of task execution and reduces the consumption of memory resources.

[0066] Step 305, executing the target task according to the execution time slice.

[0067] In some embodiments, the specific implementation of step 305 and the technical effects brought about can be referred to Figure 2 The corresponding step 203 in the embodiments will not be described in detail here.

[0068] Step 306 , in response to determining that the target task has not been executed to completion within the execution time slice, terminate the execution of the target task, and add the target task to a second target task queue.

[0069] In some embodiments, the execution subject may terminate the execution of the target task and add the target task to the second target task queue in response to determining that the target task has not been completed within the execution time slice. When there is a task queue in the task queue set whose task queue priority is lower than the task queue priority of the first target task queue, the task queue in the task queue set whose task queue priority is second only to the task queue priority of the first target task queue is used as the second target task queue. When the task queue priority of the first target task queue is the task queue with the lowest task queue priority among all the task queues in the task queue set, the first target task queue is used as the second target task queue.

[0070] from Figure 3 It can be seen that Figure 2 Compared with the description of some corresponding embodiments, Figure 4 The process 300 of the task execution method in some corresponding embodiments embodies the steps of expanding the generation of execution time slices. Therefore, the schemes described in these embodiments introduce the historical execution records of the target task, and determine the basic time slice of the target task according to the historical execution records. The historical execution records provide a historical reference basis for the determination of the basic time slice. Therefore, the reference value of the historical execution duration is taken into account when determining the final execution time slice. The determined execution time slice is more in line with the actual law of task execution. Then, according to the task execution status in the current execution subject, the basic time slice is adjusted. When the total number of tasks being executed in the execution subject is large and the memory resource occupancy is high, the load and pressure in the execution subject are large, and the task execution speed is slow. At this time, appropriately increasing the basic time slice can ensure the smooth execution of the task and avoid excessive consumption of memory resources by frequent switching tasks. Finally, the adjusted basic time slice is further adjusted according to the task queue priority, and the execution time slice of the task in the task queue with higher priority is further increased to improve its execution efficiency. Thus, the present disclosure further improves the task execution efficiency and reduces the consumption of memory resources.

[0071] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a task execution device, and these device embodiments are Figure 2 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.

[0072] like Figure 5As shown, the task execution device 500 of some embodiments includes: an acquisition unit 501, a determination unit 502 and an execution unit 503. Among them, the acquisition unit 501 is configured to acquire the target task from the task queue set according to the task queue priority of each task queue in the task queue set. The determination unit 502 is configured to determine the execution time slice of the target task. The execution unit 503 is configured to execute the target task according to the execution time slice.

[0073] In an optional implementation of some embodiments, the determination unit 502 of the device 500 can be further configured to: in response to determining that there is no basic time slice corresponding to the above-mentioned target task, determine whether there is a historical execution record of the above-mentioned target task; in response to determining that the above-mentioned historical execution record exists, determine the above-mentioned basic time slice based on the above-mentioned historical execution record.

[0074] In an optional implementation of some embodiments, the determination unit 502 of the apparatus 500 may be further configured to: determine the execution time slice according to the basic time slice.

[0075] In an optional implementation of some embodiments, the determination unit 502 of the device 500 can be further configured to: adjust the above-mentioned basic time slice to obtain an adjusted basic time slice; determine the above-mentioned execution time slice according to the above-mentioned adjusted basic time slice and the task queue priority of the task queue corresponding to the above-mentioned target task.

[0076] In an optional implementation of some embodiments, the determining unit 502 of the apparatus 500 may be further configured to: in response to determining that the historical execution record does not exist, determine a preset basic time slice as the basic time slice.

[0077] In an optional implementation of some embodiments, the acquisition unit 501 of the apparatus 500 may be further configured to: select a task queue that meets a preset condition from the task queue set as a first target task queue, and acquire a target task from the first target task queue.

[0078] In an optional implementation of some embodiments, the tasks in the task queues have task priorities, and the tasks are added to the corresponding task queues in the task queue set according to the task priorities.

[0079] In an optional implementation of some embodiments, the apparatus 500 may further include: in response to determining that the target task is not executed to completion within the execution time slice, terminating the execution of the target task, and adding the target task to a second target task queue.

[0080] It is understood that the units described in the device 500 are similar to those described in the reference Figure 2 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the device 500 and the units included therein, and will not be described in detail here.

[0081] Reference below Figure 6 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing some embodiments of the present disclosure. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

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

[0083] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0084] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.

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

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

[0087] The computer-readable medium may be included in the electronic device; or it may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a target task from the task queue set according to the task queue priority of each task queue in the task queue set; determines the execution time slice of the target task; and executes the target task according to the execution time slice.

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

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

[0090] The units described in some embodiments of the present disclosure may be implemented by software or by hardware. The described units may also be arranged in a processor, for example, may be described as: a processor includes an acquisition unit, a determination unit, and an execution unit. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances, for example, the acquisition unit may also be described as "a unit that acquires a target task from the above-mentioned task queue set according to the task queue priority of each task queue in the task queue set".

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

Claims

1. A task execution method, comprising: According to each task queue with different task queue priorities in the task queue set, a target task is obtained from the task queue set, wherein the target task is the task at the head of the task queue with the largest product value of the task queue priority and the number of tasks included in the task queue; According to the basic time slice, the execution time slice of the target task is determined in real time. When there are many tasks, the target task that takes a long time to execute is guaranteed to be completed in a complete time slice, so as to avoid the target task that takes a long time to execute being frequently terminated, including: In response to determining that there is no basic time slice corresponding to the target task, determining whether there is a historical execution record of the target task; In response to determining that the historical execution record exists, determining an arithmetic average of each historical execution duration included in the historical execution record as the basic time slice; Execute the target task according to the execution time slice; Wherein, determining the execution time slice of the target task in real time according to the basic time slice further includes: According to the basic time slice, the total memory, the basic memory allocated for the target task, and the total number of tasks currently being executed, the basic time slice is adjusted to obtain an adjusted basic time slice; The execution time slice is determined according to the adjusted basic time slice and the task queue priority of the task queue corresponding to the target task.

2. The method according to claim 1, wherein: The step of determining the execution time slice of the target task further includes: In response to determining that the historical execution record does not exist, a preset basic time slice is determined as the basic time slice.

3. The method according to claim 1, wherein: The acquiring the target task from the task queue set includes: Selecting a task queue that meets a preset condition from the task queue set as a first target task queue; Obtain the target task from the first target task queue.

4. The method according to claim 1, wherein: The tasks in the task queue have task priorities; the tasks are added to the corresponding task queues in the task queue set according to the task priorities.

5. The method according to claim 3, wherein: The method further comprises: In response to determining that the target task has not been completed within the execution time slice, the execution of the target task is terminated, and the target task is added to the second target task queue. When there is a task queue in the task queue set whose task queue priority is lower than the task queue priority of the first target task queue, the task queue in the task queue set whose task queue priority is second only to the task queue priority of the first target task queue is used as the second target task queue. When the task queue priority of the first target task queue is the task queue with the lowest task queue priority among all the task queues in the task queue set, the first target task queue is used as the second target task queue.

6. A task execution device, comprising: an acquisition unit configured to acquire a target task from the task queue set according to each task queue having different task queue priorities in the task queue set, wherein the target task is a task at the head of the task queue having the largest product value of the task queue priority and the number of tasks included in the task queue; The determination unit is configured to determine the execution time slice of the target task in real time according to the basic time slice, and when there are many tasks, ensure that the target task requiring a long execution time is completed in a complete time slice, so as to avoid the target task requiring a long execution time being frequently terminated, including: In response to determining that there is no basic time slice corresponding to the target task, determining whether there is a historical execution record of the target task; In response to determining that the historical execution record exists, determining an arithmetic average of each historical execution duration included in the historical execution record as the basic time slice; an execution unit, configured to execute the target task according to the execution time slice; Wherein, the determining unit is further configured to: According to the basic time slice, the total memory, the basic memory allocated for the target task, and the total number of tasks currently being executed, the basic time slice is adjusted to obtain an adjusted basic time slice; The execution time slice is determined according to the adjusted basic time slice and the task queue priority of the task queue corresponding to the target task.

7. An electronic device comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Business processing method and device based on thread pool

    CN106802826A

  • Method for predicting batch job executive time based on common features of big data processing framework

    CN106897199A

  • Task management method and system, server cluster and computer readable medium

    CN110096344A