Software task management method, device, equipment, and medium
By declaring task attributes in the software and using topological sorting technology, the task scheduling sequence is optimized, which solves the problems of slow startup and waste of computing power in multi-threaded task management, and achieves efficient task execution and computing power utilization.
Patent Information
- Application Number
- CN201910491672.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-06
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-03-23
AI Technical Summary
Multi-threaded task management in existing software results in slow startup, chaotic execution and waste of computing power on terminal devices, and lacks effective task scheduling and optimization mechanisms.
By declaring task attributes, including task type, dependencies and weights, and using topological sorting and mark positioning technology, the task scheduling sequence is optimized to ensure that backbone tasks are executed in advance and non-backbone tasks are delayed, making full use of the computing power of terminal equipment.
It achieves efficient execution of tasks in a multi-threaded environment, improves software startup speed and terminal device computing power utilization, reduces the execution of unnecessary tasks, and improves system stability and maintainability.
Smart Images

Figure CN112052077B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a method, device, equipment and storage medium for software task management. Background Art
[0002] In various current software, there are often phenomena such as useless code stacking. Thousands of lines of code will involve many businesses and need to be initialized. During the startup process, as the code complexity increases, logical conflicts are prone to occur, resulting in slow startup; and one of the tasks may require several modules to be initialized. In the past, there was no code management, no startup order management, and low maintainability, resulting in concurrency. Each software starts multiple threads. At the same time, due to the huge amount of data to be processed, in order to improve processing efficiency, multiple threads will be used to simultaneously execute different tasks such as data calculation and transmission. This will occur in the same application, where non-main or non-essential tasks are performed simultaneously with main tasks or necessary tasks, consuming the computing power of the terminal device. Therefore, the software multi-threaded task management method in the prior art will not only cause problems such as slow startup and chaotic execution, but also cause a large waste of computing power of the terminal device. Summary of the invention
[0003] Technical Problems to be Solved by the Invention
[0004] For software task management, in order to address the problems existing in the above-mentioned prior art, it is necessary to compress all compressible tasks during multi-threaded task execution and schedule all necessary tasks to be executed on the optimal node, so as to advance the main tasks or necessary tasks, separate and postpone non-main or non-essential tasks, and maximize the available computing power.
[0005] The present invention is completed to solve the above-mentioned problems, and its purpose is to provide a simple and efficient method, device, equipment and storage medium for software task management.
[0006] Technical solutions to solve problems
[0007] In order to solve the above technical problems, an embodiment of the present invention provides a method for software task management, which adopts the following technical solution:
[0008] The method comprises an initialization step of declaring task attributes for a task to be executed in the software, wherein the task attributes include an execution thread type acceptable to the task to be executed;
[0009] A task sorting step, determining the scheduling order of the tasks to be executed according to the task attributes;
[0010] A scheduling step, uniformly scheduling the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order;
[0011] In the execution step, the task execution thread requests scheduling of the executable tasks and executes them, wherein the scheduling request is reissued after each execution is completed until all the executable tasks are executed.
[0012] Furthermore, in the aforementioned method for software task management, the task attributes further include: task type, task dependency, and task weight.
[0013] Further, in the method for software task management as described above, the task types include: executable tasks, frozen tasks, canceled tasks, resolved tasks, and rejected tasks;
[0014] The execution thread types include: main thread, global thread, and common thread.
[0015] Furthermore, the software task management method as described above further includes a detection step of detecting dependency duration and / or dependency errors between tasks to be executed that have task dependencies.
[0016] Furthermore, in the software task management method as described above, detecting the dependency error includes determining whether there is a conflict and / or loop in the related tasks, reporting an error if there is, and proceeding to the next step if not.
[0017] Furthermore, in the aforementioned method for software task management, in the task sorting step, the tasks are sorted according to the task types and task weights by topological sorting to obtain a queue of tasks to be executed sorted in the scheduling order.
[0018] Furthermore, in the software task management method as described above, the execution step further includes a marking and positioning step, reporting the execution status of the asynchronously executed tasks through marking and positioning, and adjusting the task types of different tasks through the execution status.
[0019] Furthermore, in the method of software task management as described above, the execution step also includes a judgment step, judging whether the uniformly scheduled tasks to be executed meet the execution conditions; if the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed; if the task type of the tasks to be executed does not meet and / or is not executable, the tasks to be executed are skipped and the request continues to be sent.
[0020] Furthermore, the software task management method as described above,
[0021] The executable task to be executed includes that the task type is an executable task and has no dependent tasks or the dependent tasks have been completed.
[0022] The unexecutable task to be executed includes at least one situation that the task type is a frozen task, a canceled task, a resolved task, a refused task, or a dependent task is not completed.
[0023] Furthermore, the software task management method as described above further includes a monitoring step, monitoring and recording the task execution status to feed back to the scheduling step for adjustment,
[0024] The task execution status includes dependency, execution process, and execution time.
[0025] Another aspect of the present invention provides a software task management device, comprising:
[0026] An initialization module, declaring task attributes for a task to be executed in the software, wherein the task attributes include an execution thread type acceptable to the task to be executed;
[0027] A task sorting module, which sorts the scheduling order of the tasks to be executed according to the task attributes;
[0028] A scheduling module, which uniformly schedules the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order;
[0029] In the execution module, the task execution thread requests the scheduling of executable tasks and executes them, and reissues the scheduling request after the execution is completed until all executable tasks are executed.
[0030] Furthermore, the software task management device as described above further includes a detection module for detecting dependency duration and / or dependency errors between to-be-executed tasks having task dependency relationships.
[0031] Furthermore, the software task management device as described above further includes a marking and positioning module, which reports the execution status of the asynchronously executed tasks through marking and positioning, and adjusts the task types of different tasks according to the execution status.
[0032] Furthermore, the software task management device as described above also includes a judgment module, which judges whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed; if the task type of the tasks to be executed does not meet and / or is not executable, the tasks to be executed are skipped and the request continues to be sent.
[0033] Furthermore, the software task management device as described above further includes a monitoring module, which monitors and records the task execution status and feeds it back to the scheduling module for adjustment.
[0034] The task execution status includes dependency, execution process, and execution time.
[0035] Another aspect of the present invention provides a terminal device, including a memory and a processor, wherein the memory stores an application program, and the processor implements the steps of the software task management method as described in any one of the above when executing the application program.
[0036] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the software task management method as described in any one of the above are implemented.
[0037] Effects of the Invention
[0038] The software task management method of the present invention can compress all compressible tasks and arrange all necessary tasks to the optimal node for execution during the multi-threaded task execution process, thereby realizing the advance of backbone tasks or necessary tasks, such as early analysis of the first frame layout; separating and delaying non-backbone or non-essential tasks, such as the initialization of business modules; and running at full available computing power as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is an exemplary system architecture diagram in which the present invention can be applied;
[0040] Figure 2 A flowchart of an embodiment of a method for software task management according to the present invention;
[0041] Figure 3 A schematic diagram of an embodiment of a method for software task management according to the present invention;
[0042] Figure 4 It is a schematic structural diagram of an embodiment of a terminal device according to the present invention. DETAILED DESCRIPTION
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present invention; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention; the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present invention or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0044] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0045] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.
[0046] [System Structure]
[0047] First, the structure of a system according to an embodiment of the present invention is described. Figure 1 As shown, the system structure 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. Among them, the terminal device 101 is a small-screen display device, and the terminal devices 102 and / or 103 are large-screen display devices.
[0048] In this embodiment, the method for software task management is executed on an electronic device (eg Figure 1 The terminal device 101 or 102 or 103 shown in the figure can transmit various information through the network 104. The network 104 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc. It should be noted that the above wireless connection methods can include but are not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultrawideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0049] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0050] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV), laptop computers, desktop computers, etc.
[0051] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0052] It should be noted that the software task management method provided in the embodiment of the present invention is generally performed by a server and a terminal device. In this embodiment, the server is used to transmit information with the terminal devices 101, 102, 103, for example, providing various data to the terminal devices 101, 102, 103 for processing by the terminal devices.
[0053] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0054] [Embodiment]
[0055] In order to implement the technical solution in the embodiment of the present invention, the present invention provides a device for software task management, the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices. Figure 2 The illustrated method will be described in detail below.
[0056] The software task management device described in this embodiment includes: an initialization module, a task sorting module, a scheduling module, a detection module, an execution module, a marking and positioning module, a judgment module, and a monitoring module.
[0057] The initialization module is used to execute the initialization step S201 to declare task attributes for the tasks to be executed in the software, wherein the task attributes include the execution thread type, task type, task dependency, task weight and other attributes acceptable to the tasks to be executed.
[0058] Among them, a task is the smallest unit of an executable task, and each task is unique in the global multi-threaded task management executed by the software. Here, the types of tasks include: executable tasks, frozen tasks, canceled tasks, resolved tasks, and rejected tasks. An executable task refers to a task that can be executed after being requested, a frozen task refers to a task that needs to be awakened by an external trigger during the execution process, a canceled task refers to a task in the queue of tasks to be executed that will no longer be executed as long as there is a canceled task, a resolved task refers to a task that has been completed, and a rejected task refers to a task that does not need to be executed.
[0059] Among them, the execution thread types include: main thread, global thread, and ordinary thread. Among them, the main thread refers to the main thread in the software task management process, there is only one and other tasks are not allowed to be blocked; the global thread refers to the thread dedicated to processing CPU-intensive tasks in the software task management process, there is only one globally; the ordinary thread is used to execute tasks other than the above tasks, and there can be multiple globally.
[0060] The detection module is used to perform the detection step S202 to detect the dependency duration and / or dependency errors between the tasks to be executed that have task dependencies. Here, if there is a dependency duration between the upstream and downstream tasks, the timeout of the dependency duration should not be set too long, for example, within 30 seconds. If the execution times out, the type of the task is automatically identified as a task that is refused to be executed. Here, dependency error detection includes determining whether there are conflicts and / or loops in the related tasks. If there are conflicts and / or loops, an error is reported because all of them cannot be completed. If not, proceed to the next step.
[0061] The task sorting module is used to perform the task sorting step S203, and sort the scheduling order of the tasks to be executed according to the task attributes including acceptable execution thread types, task types, task dependencies, task weights and other attributes. Here, through topological sorting, sorting is performed according to the task type and task weight to obtain a queue of tasks to be executed sorted in the scheduling order. Here, the topological sorting is preferably a directed acyclic graph topological sorting, and a linear array conforming to the directional order is generated. Here, the directed acyclic graph topological sorting may include a loose directed acyclic graph and a strict directed acyclic graph, wherein the downstream tasks in the loose directed acyclic graph only ensure that the direct upstream tasks are all executed, but do not ensure the execution order of the upstream; while the downstream tasks in the strict directed acyclic graph ensure that the direct upstream tasks are all executed, and ensure that the upstream tasks have a clear execution order. In this embodiment, the topological sorting of the loose directed acyclic graph is preferred.
[0062] The scheduling module is used to execute the scheduling step S204, and uniformly schedules the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order, determines the actual execution order and execution priority of the task according to the execution request and the weight of the task to be executed, and schedules the task to be executed to the execution thread type acceptable to the task to be executed.
[0063] The execution module is used to execute the execution step S205, wherein the task execution thread requests the scheduling of the executable tasks and executes them, and reissues the scheduling request after the execution is completed until all the executable tasks are executed.
[0064] The judgment module is used to execute the judgment step S206 to judge whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed. If the task type to be executed does not meet and / or is not executable, the task is skipped and the request continues to be sent.
[0065] Here, the task being executable includes that the task type is an executable task and has no dependent tasks or the dependent tasks have been completed.
[0066] The task being unexecutable includes at least one of the following situations: the task type is a frozen task, a canceled task, a resolved task, a refused task, or a dependent task is not completed.
[0067] The marking and positioning module is used to perform the marking and positioning step S207, report the execution status of each asynchronously executed task through marking and positioning, and adjust the task type of different tasks according to the execution status. For example, marking the completed task as a resolved task, and marking the task that exceeds the dependency time as a rejected task.
[0068] The monitoring module is used to execute the monitoring step S208, monitor and record the task execution status to feed back to the scheduling step for adjustment. Here, the task execution status includes dependency, execution process, and execution time.
[0069] [Example Method]
[0070] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for software task management according to the present invention. The method for software task management comprises the following steps:
[0071] In the initialization step S201, the initialization module declares task attributes for the task to be executed in the software, wherein the task attributes include the execution thread type, task type, task dependency, task weight and other attributes acceptable to the task to be executed.
[0072] Among them, a task is the smallest unit of an executable task, and each task is unique in the global multi-threaded task management executed by the software. Here, the types of tasks include: executable tasks, frozen tasks, canceled tasks, resolved tasks, and rejected tasks. An executable task refers to a task that can be executed after being requested, a frozen task refers to a task that needs to be awakened by an external trigger during the execution process, a canceled task refers to a task in the queue of tasks to be executed that will no longer be executed as long as there is a canceled task, a resolved task refers to a task that has been completed, and a rejected task refers to a task that does not need to be executed.
[0073] Among them, the execution thread types include: main thread, global thread, and ordinary thread. Among them, the main thread refers to the main thread in the software task management process, there is only one and other tasks are not allowed to be blocked; the global thread refers to the thread dedicated to processing CPU-intensive tasks in the software task management process, there is only one globally; the ordinary thread is used to execute tasks other than the above tasks, and there can be multiple globally.
[0074] In the detection step S202, the detection module detects the dependency duration and / or dependency errors between the tasks to be executed that have task dependencies. Here, if there is a dependency duration between the upstream and downstream tasks, the timeout of the dependency duration should not be set too long, for example, within 30 seconds. If the execution times out, the type of the task is automatically identified as a task that is refused to be executed. Here, dependency error detection includes determining whether there are conflicts and / or loops in the related tasks. If there are conflicts and / or loops, an error is reported because all of them cannot be completed. If not, proceed to the next step.
[0075] In the task sorting step S203, the task sorting module sorts the scheduling order of the tasks to be executed according to the task attributes including acceptable execution thread types, task types, task dependencies, task weights and other attributes. Here, through topological sorting, sorting is performed according to the task types and task weights to obtain a queue of tasks to be executed sorted in the scheduling order. Here, the topological sorting is preferably a directed acyclic graph topological sorting, and a linear array conforming to the directional order is generated. Here, the directed acyclic graph topological sorting may include a loose directed acyclic graph and a strict directed acyclic graph, wherein the downstream tasks in the loose directed acyclic graph only ensure that the direct upstream tasks are all executed, but do not ensure the execution order of the upstream; while the downstream tasks in the strict directed acyclic graph ensure that the direct upstream tasks are all executed, and ensure that the upstream tasks have a clear execution order. In this embodiment, the topological sorting of the loose directed acyclic graph is preferred.
[0076] Scheduling step S204, the scheduling module uniformly schedules the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order, determines the actual execution order and execution priority of the task according to the execution request and the weight of the task to be executed, and schedules the task to be executed to the execution thread type according to the acceptable execution thread type of the task to be executed.
[0077] Step S205 is executed, the task execution thread in the execution module requests scheduling of the executable tasks and executes them, and reissues the scheduling request after the execution is completed until all the executable tasks are executed.
[0078] In judgment step S206, the judgment module judges whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed. If the task type to be executed does not meet and / or is not executable, the task is skipped and the request continues to be sent.
[0079] Here, the task being executable includes that the task type is an executable task and has no dependent tasks or the dependent tasks have been completed.
[0080] The task being unexecutable includes at least one of the following situations: the task type is a frozen task, a canceled task, a resolved task, a refused task, or a dependent task is not completed.
[0081] In the execution mark positioning step S207, the mark positioning module reports the execution status of each asynchronously executed task through mark positioning, and adjusts the task type of different tasks according to the execution status. For example, the completed task is marked as a resolved task, and the task that exceeds the dependency time is marked as a rejected task.
[0082] In the monitoring step S208, the monitoring module monitors and records the task execution status to feed back to the scheduling step for adjustment. Here, the task execution status includes dependency, execution process, and execution time.
[0083] [Example]
[0084] Below, refer to Figure 3 A schematic diagram of an embodiment describes in detail the method for software task management of the present invention.
[0085] like Figure 3As shown, in step 1, the initialization module declares task attributes for each task to be executed in the software, wherein the task attributes include the execution thread type, task type, task dependency, task weight and other attributes acceptable to the task to be executed. For example, in this embodiment, 10 tasks are defined, wherein the type of task 5 is a frozen task type task, which can only be executed after being woken up by an external trigger, and task 5 depends on task 7 and task 8, wherein the dependency duration of task 7 is set to 5s, the dependency duration of task 8 is set to 30s, and task 8 depends on task 2.
[0086] Step 2, the detection module detects the dependency duration and / or dependency errors between the existing task dependencies between tasks 1-10. Here, the dependency duration of task 7 is 5s, and the dependency duration of task 8 is 30s. If the execution exceeds the set dependency duration and still fails to execute successfully, the type of the task is automatically identified as a task that refuses to execute. In addition, it is also necessary to detect the dependency error detection between tasks 1-10, including determining whether there are conflicts and / or loops in the related tasks. If there are conflicts and / or loops, an error is reported because all of them cannot be completed. If not, proceed to the next step.
[0087] Step 3, the task sorting module sorts the scheduling order of the tasks to be executed according to the task attributes between tasks 1-10, including acceptable execution thread types, task types, task dependencies, task weights and other attributes. Here, by topological sorting, sorting is performed according to the task type and task weight to obtain a queue of tasks to be executed sorted in the scheduling order. Here, the topological sorting is preferably a directed acyclic graph topological sorting, and a linear array conforming to the directional order is generated. Here, the directed acyclic graph topological sorting may include a loose directed acyclic graph and a strict directed acyclic graph, wherein the downstream tasks in the loose directed acyclic graph only ensure that the direct upstream tasks are all executed, but do not ensure the execution order of the upstream; and the downstream tasks in the strict directed acyclic graph ensure that the direct upstream tasks are all executed, and ensure that the upstream tasks have a clear execution order. In this embodiment, the topological sorting of the loose directed acyclic graph is preferred. For example, after topological sorting, the sequence 0, 1, 2, 6, 9 / / 7, 8 / / 5 / / 3, 4 / / 10 (the sequence is not unique, / / represents the execution dependency of the task queue) is obtained.
[0088] Step 4, the scheduling module uniformly schedules the actual execution order, the execution thread type and the task execution priority of the tasks to be executed according to the scheduling order, determines the actual execution order and execution priority of the tasks to be executed according to the execution request and the weight of the tasks to be executed, and schedules the tasks to be executed to the execution thread type according to the acceptable execution thread type of the tasks to be executed. Here, regarding the weight attribute, for example, task 10 has nothing to do with any other task, so it can be the first execution or the last execution. If it is hoped that it will be executed as soon as possible, the scheduling module will increase its weight so that it will be executed earliest among the same level. In addition, if some dependent tasks whose accepting thread type is the main thread, such as task 8 is executed in the main thread, assuming that task 8 depends on task 2, the scheduling module automatically increases the weight of all dependent tasks of task 8, then the sequence of the above scheduling order forms a new actual execution order of 10 / / 2, 0, 1, 6, 9 / / 7, 8 / / 5 / / 3, 4, and so on. After obtaining the request sent by the execution module, the scheduling module sends the tasks to be executed to the execution module according to the actual execution order.
[0089] Step 5: The task execution thread in the execution module requests to schedule the executable tasks and executes them, and reissues the scheduling request after the execution is completed until all the executable tasks are executed.
[0090] Step 6, the judgment module judges whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed. The execution module starts to execute task 10, and then executes the tasks 2, 0, 1, 6, and 9 with the highest downstream weights; then tasks 7 and 8 are also executed; task 5 is a frozen task type and is not executed; tasks 3 and 4 depend on 5 and are not executed either.
[0091] Step 7: The marking and positioning module reports the execution status of each asynchronously executed task through marking and positioning, and adjusts the task type of different tasks according to the execution status.
[0092] Mark the above-mentioned completed tasks and mark the type of each task as a resolved task. When an external trigger wakes up task 5 (i.e., task 5 unfreezes the task type), check whether its dependent tasks 7 and 8 are executed successfully and marked as resolved tasks. If not, the execution module executes the subsequent tasks or waits according to the requirements. If tasks 7 and 8 have been executed successfully and task 5 has unfrozen the task type, execute task 5 and mark it as a resolved task type. The execution module triggers a re-traversal, detects the downstream tasks 3 and 4 of task 5, and executes and marks them.
[0093] Step 8: The monitoring module monitors and records the task execution status to feed back to the scheduling step for adjustment. Here, the task execution status includes dependency, execution process, and execution time.
[0094] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0095] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0096] To solve the above technical problems, the embodiment of the present invention also provides a terminal device. Figure 4 , Figure 4 This is a basic structural block diagram of the terminal device in this embodiment.
[0097] The terminal device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a terminal device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the terminal device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0098] The terminal device may be a computing device such as a mobile phone, tablet computer, desktop computer, notebook, PDA, cloud server, etc. The terminal device may interact with the user through a touch screen, keyboard, mouse, remote control, touch pad, or voice control device.
[0099] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the terminal device 4, such as a hard disk or memory of the terminal device 4. In other embodiments, the memory 41 can also be an external storage device of the terminal device 4, such as a plug-in hard disk equipped on the terminal device 4, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 41 can also include both the internal storage unit of the terminal device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the terminal device 4, such as the program code of the method of software task management, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0100] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the terminal device 4. In this embodiment, the processor 42 is used to run the program code stored in the memory 41 or process data, such as running the program code of the software task management method.
[0101] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the terminal device 4 and other electronic devices.
[0102] The present invention also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores a software task management program, and the software task management program can be executed by at least one processor to enable the at least one processor to perform the steps of the software task management method as described above.
[0103] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0104] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.
Claims
1. A method for software task management, characterized in that: include: Initialization step, declaring task attributes for the task to be executed in the software, wherein the task attributes include the execution thread type acceptable to the task to be executed, and the task attributes also include: task type, task dependency, and task weight; The task sorting step determines the scheduling order of the tasks to be executed according to the task attributes, and sorts the tasks according to the task types and task weights through topological sorting to obtain a queue of tasks to be executed sorted in the scheduling order; A scheduling step, uniformly scheduling the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order, and scheduling the tasks to be executed to the execution thread type according to the execution thread type acceptable to the tasks to be executed; In the execution step, the task execution thread requests to schedule the executable tasks and executes them, wherein the scheduling request is reissued after each execution is completed until all the executable tasks are executed; The execution thread types include: main thread, global thread, and common thread.
2. The method for software task management according to claim 1, characterized in that: The task types include: executable tasks, frozen tasks, canceled tasks, resolved tasks, and rejected tasks.
3. The method for software task management according to claim 1, characterized in that: The method further includes a detection step of detecting dependency duration and / or dependency errors between tasks to be executed that have task dependencies.
4. The method for software task management according to claim 3, characterized in that: Detecting the dependency error includes determining whether there is a conflict and / or loop in the related tasks, reporting an error if there is, and proceeding to the next step if there is no conflict and / or loop in the related tasks.
5. The method for software task management according to claim 1, characterized in that: The execution step further includes a marking and positioning step, in which the execution status of the asynchronously executed task is reported through marking and positioning, and the task types of different tasks are adjusted through the execution status.
6. The method for software task management according to claim 1, characterized in that: The execution step also includes a judgment step, which judges whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets the conditions and is executable, the tasks to be executed are executed. If the task type of the tasks to be executed does not meet the conditions and / or is not executable, the tasks to be executed are skipped and the request continues to be sent.
7. The method for software task management according to claim 6, characterized in that: The executable task to be executed includes that the task type is an executable task and has no dependent tasks or the dependent tasks have been completed. The unexecutable task to be executed includes at least one situation that the task type is a frozen task, a canceled task, a resolved task, a refused task, or a dependent task is not completed.
8. The method for software task management according to any one of claims 1 to 7, characterized in that: It also includes a monitoring step, which monitors and records the execution of tasks to provide feedback to the scheduling step for adjustment. The task execution status includes dependency, execution process, and execution time.
9. A software task management device, characterized in that: include: An initialization module declares task attributes for a task to be executed in the software, wherein the task attributes include an acceptable execution thread type for the task to be executed, and further includes: task type, task dependency, and task weight; A task sorting module sorts the scheduling order of the tasks to be executed according to the task attributes, and sorts the tasks according to the task types and task weights through topological sorting to obtain a queue of tasks to be executed sorted in the scheduling order; A scheduling module, which uniformly schedules the actual execution order, execution thread type and task execution priority of the tasks to be executed according to the scheduling order, and schedules the tasks to be executed to the execution thread type according to the execution thread type acceptable to the tasks to be executed; In the execution module, the task execution thread requests the scheduling of executable tasks and executes them, and reissues the scheduling request after the execution is completed until all executable tasks are executed; The execution thread types include: main thread, global thread, and common thread.
10. The software task management device according to claim 9, characterized in that: It also includes a detection module for detecting dependency duration and / or dependency errors between tasks to be executed that have task dependencies.
11. The software task management device according to claim 10, characterized in that: It also includes a marking positioning module, which reports the execution status of the asynchronously executed tasks through marking positioning, and adjusts the task types of different tasks according to the execution status.
12. The software task management device according to claim 11, characterized in that: It also includes a judgment module, which judges whether the uniformly scheduled tasks to be executed meet the execution conditions. If the task type of the tasks to be executed meets and is executable, the tasks to be executed are executed. If the task type of the tasks to be executed does not meet and / or is not executable, the tasks to be executed are skipped and the request continues to be sent.
13. The device for software task management according to any one of claims 9 to 12, characterized in that: It also includes a monitoring module, which monitors and records the execution of tasks and feeds back to the scheduling module for adjustment. The task execution status includes dependency, execution process, and execution time.
14. A terminal device, comprising a memory and a processor, wherein the memory stores an application program, and the processor implements the steps of the method for software task management according to any one of claims 1 to 8 when executing the application program.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for software task management according to any one of claims 1 to 8.
