CN111831422A - Task processing method and device - Google Patents

Task processing method and device Download PDF

Info

Publication number
CN111831422A
CN111831422A CN201910300649.8A CN201910300649A CN111831422A CN 111831422 A CN111831422 A CN 111831422A CN 201910300649 A CN201910300649 A CN 201910300649A CN 111831422 A CN111831422 A CN 111831422A
Authority
CN
China
Prior art keywords
subtask
task
processing
processed
ith
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910300649.8A
Other languages
Chinese (zh)
Other versions
CN111831422B (en
Inventor
杨云杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Datang Mobile Communications Equipment Co Ltd
Original Assignee
Datang Mobile Communications Equipment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Datang Mobile Communications Equipment Co Ltd filed Critical Datang Mobile Communications Equipment Co Ltd
Priority to CN201910300649.8A priority Critical patent/CN111831422B/en
Publication of CN111831422A publication Critical patent/CN111831422A/en
Application granted granted Critical
Publication of CN111831422B publication Critical patent/CN111831422B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a task processing method and a task processing device. The method comprises the following steps: creating an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1; processing the ith subtask; under the condition that the ith subtask is successfully processed, creating an (i + 1) th subtask corresponding to the task to be processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask; and processing the (i + 1) th subtask. The invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.

Description

Task processing method and device
Technical Field
The present invention relates to the field of task processing technologies, and in particular, to a task processing method and apparatus.
Background
An eNB (Evolved NodeB)/RRU (Radio Remote Unit) in an LTE (Long Term Evolution) communication network needs to perform software version upgrade at an irregular time to meet the requirements of providing new functions and characteristics and repairing previous version problems. The quantity of eNB/RRU in the large LTE communication network is ten thousand as units, and the requirement on upgrading efficiency is high.
When the eNB and the RRU need to be upgraded, the OMC (Operation maintenance Center) imports an existing version upgrade packet into an FTP Server (File Transfer Protocol Server), and downloads the version upgrade packet from the FTP Server to the eNB and the RRU side and makes it effective by issuing an upgrade command to the eNB/RRU, so as to achieve the purpose of upgrading the device version.
In the software upgrading process, all processes from the beginning of upgrading to the end of upgrading are linear processes, and the verification, the command issuing, the process monitoring and the result processing before the command issuing are processed as a whole process, so that the software cannot jump out in the midway unless the software fails and exits. Upgrading of device software is a time-consuming operation, which conventionally takes at least 10 minutes or more, and under normal network conditions, takes longer. In this case, in order to improve the efficiency of upgrading the software version of the network-wide device, only the number of concurrent threads is increased, but the increase of the concurrent threads increases the consumption of the memory and wastes the execution time of the task.
Disclosure of Invention
The embodiment of the invention provides a task processing method and a task processing device, and aims to solve the problems that the number of concurrent threads needs to be increased and the task execution time needs to be increased when the software version upgrading efficiency is improved in the prior art.
In order to solve the above problem, an embodiment of the present invention discloses a task processing method, including: creating an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1; processing the ith subtask; under the condition that the ith subtask is successfully processed, creating an (i + 1) th subtask corresponding to the task to be processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask; and processing the (i + 1) th subtask.
Preferably, the step of creating an ith sub-task corresponding to the task to be processed includes: calling a first idle thread in a thread pool, and creating the ith subtask; the step of processing the ith sub-task includes: calling the first idle thread to process the ith subtask; the step of creating the (i + 1) th subtask corresponding to the task to be processed includes: calling a second idle thread in the thread pool, and creating the (i + 1) th subtask; the step of processing the (i + 1) th subtask includes: and calling the second idle thread to process the (i + 1) th subtask.
Preferably, after the step of processing the ith sub-task, the method further includes: and under the condition that the processing of the ith subtask fails, finishing the processing operation of the task to be processed.
Preferably, after the step of processing the (i + 1) th subtask, the method further includes: judging whether the (i + 1) th subtask is the last subtask of the task to be processed; and if so, ending the processing operation of the task to be processed.
Preferably, the first idle thread and the second idle thread are the same idle thread; or the first idle thread and the second idle thread are different idle threads.
In order to solve the above problem, an embodiment of the present invention discloses a task processing device, including: the first subtask creation module is used for creating an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1; the first subtask processing module is used for processing the ith subtask; a second subtask creation module, configured to create an i +1 th subtask corresponding to the to-be-processed task when the ith subtask is successfully processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask; and the second subtask processing module is used for processing the (i + 1) th subtask.
Preferably, the first subtask creating module includes: the first subtask creation submodule is used for calling a first idle thread in a thread pool and creating the ith subtask; the first subtask processing module includes: the first subtask processing submodule is used for calling the first idle thread and processing the ith subtask; the second subtask creation module includes: the second subtask creation submodule is used for calling a second idle thread in the thread pool and creating the (i + 1) th subtask; the second subtask processing module includes: and the second subtask processing submodule is used for calling the second idle thread to process the (i + 1) th subtask.
Preferably, the method further comprises the following steps: and the first processing operation ending module is used for ending the processing operation of the task to be processed under the condition that the ith sub-task fails to be processed.
Preferably, the method further comprises the following steps: the last subtask judging module is used for judging whether the (i + 1) th subtask is the last subtask of the task to be processed; and the second processing operation ending module is used for ending the processing operation on the task to be processed when the (i + 1) th subtask is the last subtask.
Preferably, the first idle thread and the second idle thread are the same idle thread; or the first idle thread and the second idle thread are different idle threads.
Compared with the prior art, the embodiment of the invention has the following advantages:
the embodiment of the invention provides a task processing method and a task processing device, wherein an ith sub-task corresponding to a task to be processed is created, i is a positive integer greater than or equal to 1, the ith sub-task is processed, under the condition that the ith sub-task is successfully processed, an (i + 1) th sub-task corresponding to the task to be processed is created, the processing sequence of the ith sub-task is prior to the (i + 1) th sub-task, and the (i + 1) th sub-task is processed. The embodiment of the invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.
Drawings
FIG. 1 is a flow chart illustrating the steps of a task processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a task processing method according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a task processing device according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram illustrating a task processing device according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Example one
Referring to fig. 1, a flowchart illustrating steps of a task processing method according to an embodiment of the present invention is shown, which may specifically include the following steps:
step 101: creating an ith subtask corresponding to the task to be processed; i is a positive integer of 1 or more.
In this embodiment of the present invention, the to-be-processed task refers to a task that can be divided into a plurality of sub-tasks executed by a thread, for example, the to-be-processed task may be a software upgrade task, such as upgrading an RRU software version, or upgrading an eNB software version, and specifically, may be determined according to a service requirement, which is not limited in this embodiment of the present invention.
i is a positive integer greater than or equal to i, i may be 1, 2, 3, etc., and specifically, it may be determined according to actual conditions, for example, when a task to be processed may be divided into 5 subtasks, i may be 1, 2, 3, 4, etc., and the creation timing and the execution timing of the subtasks divided by the task to be processed are sequential, that is, after the creation of the first subtask is completed and the processing is successful, the second subtask is created and the second subtask is executed, and after the processing of the second subtask is successful, the third subtask is created again.
The above process will be described in detail in the following steps, and the embodiments of the present invention will not be described herein.
After creating the ith sub-task corresponding to the task to be processed, step 102 is performed.
Step 102: and processing the ith subtask.
After creating the ith sub-task corresponding to the task to be processed, the ith sub-task may be processed.
Specifically, a thread pool may be preset, and states of respective threads created in advance are recorded in the thread pool, including: the idle state and the non-idle state may call a thread in the idle state in the thread pool to process the ith subtask when the ith subtask needs to be processed, for example, the software upgrading task includes: the method comprises the following steps of downloading a command issuing subtask, downloading process monitoring subtasks and a synchronous command issuing subtask, wherein when the ith subtask is a downloading command issuing subtask, a thread in an idle state in a thread pool can be called, and the downloading command issuing subtask is executed, namely, the idle thread is called to issue a downloading command.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After the ith sub-task is processed, step 103 is performed.
Step 103: under the condition that the ith subtask is successfully processed, creating an (i + 1) th subtask corresponding to the task to be processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask.
In the embodiment of the present invention, a plurality of sub-tasks into which a task to be processed is dynamically divided have corresponding processing sequences, and the (i + 1) th sub-task is a sub-task whose processing sequence is just after the (i) th sub-task, for example, the task to be processed a may be divided into four sub-tasks, which are respectively a, b, c, and d, and the processing sequences of the divided sub-tasks are sequentially a, b, c, and d, and when the (i) th sub-task is a, the (i + 1) th sub-task is b; when the ith subtask is b, the (i + 1) th subtask is c; and when the ith sub-task is c, the (i + 1) th sub-task is d, and the like.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
For a plurality of sub-tasks into which a task to be processed can be divided, besides having a corresponding processing sequence, the creation and processing procedure of the next sub-task can be executed after the processing of the sub-task whose processing sequence is earlier is completed.
And when the processing of the ith subtask fails, the (i + 1) th subtask is not created any more, i.e. no subsequent processing process exists.
And when the ith subtask is successfully processed, an (i + 1) th subtask is created.
After creating the (i + 1) th subtask corresponding to the pending task, step 104 is performed.
Step 104: and processing the (i + 1) th subtask.
After the (i + 1) th subtask corresponding to the task to be processed is created, the (i + 1) th subtask may be processed, and specifically, an idle thread in the thread pool may be called to process the (i + 1) th subtask.
After the i +1 subtasks are processed, it may be determined whether the i +1 th subtask is the last subtask of the to-be-processed task, and if so, the processing operation of the to-be-processed task is ended.
In the process, whether the i +1 th subtask is successfully processed or not does not need to be judged.
When the (i + 1) th subtask is not the last subtask, whether the (i + 1) th subtask is successfully processed or not can be judged, and when the (i + 1) th subtask is failed to be processed, the processing operation of the task to be processed is ended. When the i +1 th subtask is successfully processed, an i +2 th subtask may be created, and then the i +2 th subtask is processed …, and so on, until the processing operation of the task to be processed is completed.
According to the embodiment of the invention, a complete task is dynamically divided into a plurality of subtasks, and the next subtask is triggered to be created and processed only after the subtask with the processing sequence being earlier is processed.
The task processing method provided by the embodiment of the invention processes the ith subtask by creating the ith subtask corresponding to the to-be-processed task, wherein i is a positive integer greater than or equal to 1, and under the condition that the ith subtask is successfully processed, an (i + 1) th subtask corresponding to the to-be-processed task is created, and the processing sequence of the ith subtask is prior to the (i + 1) th subtask and the (i + 1) th subtask is processed. The embodiment of the invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.
Example two
Referring to fig. 2, a flowchart illustrating steps of a task processing method according to an embodiment of the present invention is shown, which may specifically include the following steps:
step 201: and calling a first idle thread in the thread pool, and creating the ith subtask.
In this embodiment of the present invention, the to-be-processed task refers to a task that can be divided into a plurality of sub-tasks executed by a thread, for example, the to-be-processed task may be a software upgrade task, such as upgrading an RRU software version, or upgrading an eNB software version, and specifically, may be determined according to a service requirement, which is not limited in this embodiment of the present invention.
i is a positive integer greater than or equal to i, i may be 1, 2, 3, etc., and specifically, it may be determined according to actual conditions, for example, when a task to be processed may be divided into 5 subtasks, i may be 1, 2, 3, 4, etc., and the creation timing and the execution timing of the subtasks divided by the task to be processed are sequential, that is, after the creation of the first subtask is completed and the processing is successful, the second subtask is created and the second subtask is executed, and after the processing of the second subtask is successful, the third subtask is created again.
The thread pool refers to a memory space created in the system in advance for storing threads.
The threads stored in the thread pool may include two states, an idle state and a non-idle state.
The first idle thread is a thread in an idle state in the thread pool, for example, the thread pool includes thread 1, thread 2, and thread 3, thread 2 and thread 3 are idle threads, and thread 1 is a non-idle thread, and then thread 2 may be used as the first idle thread, and thread 3 may also be used as the first idle thread.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
When a plurality of idle threads exist in the thread pool, a person skilled in the art may select a thread in an idle state as the first idle thread according to actual needs, and specifically, the method may be determined according to actual situations, which is not limited in this embodiment of the present invention.
When an ith subtask corresponding to the task to be processed needs to be created, a first idle thread in the thread pool can be called to create the ith subtask.
After invoking the first idle thread to create the ith subtask, step 202 is performed.
Step 202: and calling the first idle thread to process the ith subtask.
After the ith subtask is created, a first idle thread may be called to process the ith subtask, that is, after the first idle thread is called to create the ith subtask, the ith subtask may continue to be processed by using the first idle thread, for example, the software upgrade task includes: the method comprises the following steps of downloading a command issuing subtask, downloading a process monitoring subtask and a synchronous command issuing subtask, wherein when the ith subtask is a downloading command issuing subtask, a first idle thread can be called, the creation of the downloading command issuing subtask is executed, and then the first idle thread is called to issue a downloading command.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After the ith subtask is processed by calling the first idle thread, step 203 is performed.
Step 203: and under the condition that the processing of the ith subtask fails, finishing the processing operation of the task to be processed.
After the first idle thread is called to process the ith subtask, whether the ith subtask is successfully processed may be determined. For example, when the ith sub-task is a download command issuing sub-task, whether the download command issuing sub-task is processed successfully can be determined by monitoring whether the download command is successfully issued, that is, when the download command is successfully issued, the download command issuing sub-task is processed successfully; and when the download command fails to be issued, the download command issuing subtask fails to process.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
And when the processing of the ith sub-task fails, ending the processing operation of the task to be processed, namely under the condition that the processing of the ith sub-task fails, no (i + 1) th sub-task corresponding to the task to be processed is created, and ending the processing of the task to be processed.
Step 204: and under the condition that the ith subtask is successfully processed, calling a second idle thread in the thread pool to create the (i + 1) th subtask.
In the embodiment of the present invention, a plurality of sub-tasks into which a task to be processed is dynamically divided have corresponding processing sequences, and the (i + 1) th sub-task is a sub-task whose processing sequence is just after the (i) th sub-task, for example, the task to be processed a may be divided into four sub-tasks, which are respectively a, b, c, and d, and the processing sequences of the divided sub-tasks are sequentially a, b, c, and d, and when the (i) th sub-task is a, the (i + 1) th sub-task is b; when the ith subtask is b, the (i + 1) th subtask is c; and when the ith sub-task is c, the (i + 1) th sub-task is d, and the like.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
For a plurality of sub-tasks into which a task to be processed can be divided, besides having a corresponding processing sequence, the creation and processing procedure of the next sub-task can be executed after the processing of the sub-task whose processing sequence is earlier is completed.
The second idle thread is a thread in an idle state in the thread pool.
The second idle thread and the first idle thread may be the same idle thread, or may also be two different threads in the thread pool, and specifically, the present invention may be determined according to an actual situation, and the embodiment of the present invention does not limit this.
After the ith subtask is successfully processed, a second idle thread in the thread pool may be called to create an (i + 1) th subtask corresponding to the task to be processed, and step 205 is performed.
Step 205: and calling the second idle thread to process the (i + 1) th subtask.
After the i +1 th subtask is created, a second idle thread may be called to process the i +1 th subtask, that is, after the second idle thread is called to create the i +1 th subtask, the i +1 th subtask may continue to be processed by the second idle thread, for example, the software upgrade task includes: the method comprises the steps of issuing a download command, issuing a download process monitoring subtask and issuing a synchronous command, and can call a second idle thread to execute the creation of the download process monitoring subtask when the (i + 1) th subtask is the download process monitoring subtask, and then call the second idle thread to execute the download process monitoring subtask to monitor the software download process.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After the second idle thread is invoked to process the (i + 1) th subtask, step 206 is performed.
Step 206: and judging whether the (i + 1) th subtask is the last subtask of the to-be-processed task.
After the second idle thread is called to process the (i + 1) th subtask, whether the (i + 1) th subtask is the last subtask corresponding to the task to be processed can be determined, for example, the subtask corresponding to the task to be processed includes subtask 1, subtask 2, and subtask 3, the processing order of the subtasks is sequentially subtask 1, subtask 2, and subtask 3, and when the (i + 1) th subtask is subtask 2, the (i + 1) th subtask is not the last subtask of the task to be processed; and when the (i + 1) th subtask is the subtask 3, the (i + 1) th subtask is the last subtask of the to-be-processed task.
It should be understood that the above examples are only examples for better understanding of the technical solutions of the embodiments of the present invention, and are not to be taken as the only limitation of the embodiments of the present invention.
After determining whether the (i + 1) th sub-task is the last sub-task of the to-be-processed task, step 207 is executed.
Step 207: and finishing the processing operation of the task to be processed.
When the (i + 1) th subtask is not the last subtask of the to-be-processed task, a thread in an idle state in the thread pool may be called, an (i + 2) th subtask corresponding to the to-be-processed task is created, and then the thread in the idle state is called to process the (i + 2) th subtask.
And when the (i + 1) th subtask is the last subtask of the to-be-processed task, ending the processing operation of the to-be-processed task.
When the (i + 1) th subtask is the last subtask of the to-be-processed task, whether the (i + 1) th subtask is successfully processed or not does not need to be concerned at this time, that is, whether the (i + 1) th subtask is successfully processed or fails, the processing operation of the subtask corresponding to the to-be-processed task is finished.
Next, the above-described process of the present invention will be described in detail in connection with the software upgrade task.
The software upgrading task can be divided into a download command issuing subtask, a download process monitoring subtask, a synchronous command issuing subtask, a synchronous process monitoring subtask, an activation command issuing subtask and an activation process monitoring subtask, and the processing sequence of the subtasks is as follows: the system comprises a download command issuing subtask, a download process monitoring subtask, a synchronous command issuing subtask, a synchronous process monitoring subtask, an activation command issuing subtask and an activation process monitoring subtask.
When software (such as eNB or RRU software) needs to be upgraded, a thread in an idle state in a thread pool can be called to create a download command and issue a subtask, and then the idle thread is called to process the download command and issue the subtask.
After the sub-task processing of the download command is completed, whether the sub-task processing of the download command is successful or not can be judged, and when the sub-task processing of the download command is failed, the task of software upgrading is ended.
And when the subtask processing is successful under the download command, one thread in an idle state in the thread pool can be called again to create the download process monitoring subtask, and then the thread in the idle state is called to process the download process monitoring subtask.
After the monitoring subtask processing of the downloading process is completed, whether the monitoring subtask processing of the downloading process is successful or not can be judged, and when the monitoring subtask processing of the downloading process is failed, the task of software upgrading is ended.
And when the monitoring subtask in the downloading process is successfully processed, one thread in an idle state in the thread pool can be called again, the synchronous command issuing subtask is created, and then the thread in the idle state is called to process the synchronous command issuing subtask.
After the synchronous command issuing subtask processing is completed, whether the synchronous command issuing subtask processing is successful or not can be judged, and when the synchronous command issuing subtask processing is failed, the software upgrading task is ended.
And when the synchronous command issuing subtask is successfully processed, one thread in an idle state in the thread pool can be called again, the synchronous process monitoring subtask is established, and then the thread in the idle state is called again to process the synchronous command issuing subtask.
After the synchronous process monitoring subtask is processed, whether the synchronous process monitoring subtask is successfully processed or not can be judged, and when the synchronous process monitoring subtask is failed to be processed, the task of software upgrading is ended.
When the synchronous process monitoring subtask is successfully processed, one thread in an idle state in the thread pool can be called again, an active command issuing subtask is created, and then the idle thread is called again to process the active command issuing subtask.
After the sub-task processing under the activation command is completed, whether the sub-task processing under the activation command is successful or not can be judged, and when the sub-task processing under the activation command is failed, the task of software upgrading is ended.
When the subtask processing under the activation command is successful, one thread in the thread pool in an idle state can be called again to create an activation process monitoring subtask, and then the thread in the idle state is called again to process the activation process monitoring subtask.
After the activation process monitoring subtask is processed, whether the activation process monitoring subtask is successfully processed or not can be judged, and the software upgrading task is ended when the activation process monitoring subtask is failed or succeeded.
In practical applications, after each subtask is processed, it is necessary to determine whether the processed subtask is the last subtask of the to-be-processed task, and when the processed subtask is the last subtask of the to-be-processed task, the processing operation on the to-be-processed task is finished.
In the embodiment of the invention, whether a software task of the next flow is newly established is dynamically determined according to the result of task processing in the software upgrading process. The dynamic task creating mode effectively avoids the problems of scheduling confusion and extra memory consumption caused by the fact that all tasks in all processes are initially created, simplifies the complexity of task scheduling, and reduces the instantaneous memory consumption of the tasks.
And the method changes the mode that one linear multi-step time-consuming task exclusively occupies one thread into the mode that a plurality of tasks with logical relations share one thread. The sleep time in the prior process is used for processing the upgrading tasks of other network elements, and the cumulative effect of a plurality of network element tasks (software upgrading is carried out on a plurality of network elements) is superposed, so that the time consumed by task execution is greatly shortened.
The task processing method provided by the embodiment of the invention processes the ith subtask by creating the ith subtask corresponding to the to-be-processed task, wherein i is a positive integer greater than or equal to 1, and under the condition that the ith subtask is successfully processed, an (i + 1) th subtask corresponding to the to-be-processed task is created, and the processing sequence of the ith subtask is prior to the (i + 1) th subtask and the (i + 1) th subtask is processed. The embodiment of the invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.
EXAMPLE III
Referring to fig. 3, a schematic structural diagram of a task processing device provided in an embodiment of the present invention is shown, which may specifically include:
a first subtask creating module 310, configured to create an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1; a first subtask processing module 320, configured to process the ith subtask; a second subtask creating module 330, configured to create an i +1 th subtask corresponding to the to-be-processed task when the ith subtask is successfully processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask; and the second sub-task processing module 340 is configured to process the (i + 1) th sub-task.
The task processing device provided in the embodiment of the present invention processes the ith sub-task by creating the ith sub-task corresponding to the to-be-processed task, where i is a positive integer greater than or equal to 1, and creates the (i + 1) th sub-task corresponding to the to-be-processed task under the condition that the processing of the ith sub-task is successful, where the processing order of the ith sub-task is prior to that of the (i + 1) th sub-task, and processes the (i + 1) th sub-task. The embodiment of the invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.
Example four
Referring to fig. 4, a schematic structural diagram of a task processing device provided in an embodiment of the present invention is shown, which may specifically include:
a first subtask creating module 410, configured to create an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1; a first subtask processing module 420, configured to process the ith subtask; a first processing operation ending module 430, configured to end the processing operation on the to-be-processed task when the processing on the ith sub-task fails; a second subtask creating module 440, configured to create an i +1 th subtask corresponding to the to-be-processed task when the ith subtask is successfully processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask; a second subtask processing module 450, configured to process the (i + 1) th subtask; a last subtask determining module 460, configured to determine whether the (i + 1) th subtask is a last subtask of the to-be-processed task; a second processing operation ending module 470, configured to end the processing operation on the to-be-processed task when the (i + 1) th sub-task is the last sub-task.
Preferably, the first subtask creating module 410 includes: a first subtask creating submodule 4101, configured to invoke a first idle thread in a thread pool, and create the ith subtask; the first subtask processing module 420 includes: a first subtask processing submodule 4201, configured to invoke the first idle thread and process the ith subtask; the second subtask creating module 440 includes: a second subtask creating sub-module 4401, configured to invoke a second idle thread in the thread pool, and create the (i + 1) th subtask; the second subtask processing module 450 includes: a second subtask processing submodule 4501, configured to invoke the second idle thread, and process the (i + 1) th subtask.
Preferably, the first idle thread and the second idle thread are the same idle thread; or the first idle thread and the second idle thread are different idle threads.
The task processing device provided in the embodiment of the present invention processes the ith sub-task by creating the ith sub-task corresponding to the to-be-processed task, where i is a positive integer greater than or equal to 1, and creates the (i + 1) th sub-task corresponding to the to-be-processed task under the condition that the processing of the ith sub-task is successful, where the processing order of the ith sub-task is prior to that of the (i + 1) th sub-task, and processes the (i + 1) th sub-task. The embodiment of the invention can effectively reduce the consumption of the memory in the instantaneous processing process and greatly reduce the time for executing the task by dynamically dividing a complete task into a plurality of subtasks for processing.
While specific reference may have been made to the above-described method embodiments for simplicity of explanation, the various acts illustrated in the various blocks, for example, may be performed in any order, or performed in any combination, as those skilled in the art will appreciate that the present invention is not limited by the illustrated ordering of acts, as some steps may occur in other orders or concurrently, in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The task processing method and the task processing device provided by the invention are described in detail, and the principle and the implementation mode of the invention are explained by applying specific examples, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A task processing method, comprising:
creating an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1;
processing the ith subtask;
under the condition that the ith subtask is successfully processed, creating an (i + 1) th subtask corresponding to the task to be processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask;
and processing the (i + 1) th subtask.
2. The method according to claim 1, wherein the step of creating an ith sub-task corresponding to the task to be processed comprises:
calling a first idle thread in a thread pool, and creating the ith subtask;
the step of processing the ith sub-task includes:
calling the first idle thread to process the ith subtask;
the step of creating the (i + 1) th subtask corresponding to the task to be processed includes:
calling a second idle thread in the thread pool, and creating the (i + 1) th subtask;
the step of processing the (i + 1) th subtask includes:
and calling the second idle thread to process the (i + 1) th subtask.
3. The method of claim 1, further comprising, after the step of processing the ith sub-task:
and under the condition that the processing of the ith subtask fails, finishing the processing operation of the task to be processed.
4. The method according to claim 1, further comprising, after the step of processing the (i + 1) th subtask:
judging whether the (i + 1) th subtask is the last subtask of the task to be processed;
and if so, ending the processing operation of the task to be processed.
5. The method of claim 2, wherein the first idle thread and the second idle thread are the same idle thread; or the first idle thread and the second idle thread are different idle threads.
6. A task processing apparatus, comprising:
the first subtask creation module is used for creating an ith subtask corresponding to the task to be processed; i is a positive integer greater than or equal to 1;
the first subtask processing module is used for processing the ith subtask;
a second subtask creation module, configured to create an i +1 th subtask corresponding to the to-be-processed task when the ith subtask is successfully processed; the processing sequence of the ith subtask is prior to the (i + 1) th subtask;
and the second subtask processing module is used for processing the (i + 1) th subtask.
7. The apparatus of claim 6, wherein the first subtask creating module comprises:
the first subtask creation submodule is used for calling a first idle thread in a thread pool and creating the ith subtask;
the first subtask processing module includes:
the first subtask processing submodule is used for calling the first idle thread and processing the ith subtask;
the second subtask creation module includes:
the second subtask creation submodule is used for calling a second idle thread in the thread pool and creating the (i + 1) th subtask;
the second subtask processing module includes:
and the second subtask processing submodule is used for calling the second idle thread to process the (i + 1) th subtask.
8. The apparatus of claim 6, further comprising:
and the first processing operation ending module is used for ending the processing operation of the task to be processed under the condition that the ith sub-task fails to be processed.
9. The apparatus of claim 6, further comprising:
the last subtask judging module is used for judging whether the (i + 1) th subtask is the last subtask of the task to be processed;
and the second processing operation ending module is used for ending the processing operation on the task to be processed when the (i + 1) th subtask is the last subtask.
10. The apparatus of claim 7, wherein the first idle thread and the second idle thread are the same idle thread; or the first idle thread and the second idle thread are different idle threads.
CN201910300649.8A 2019-04-15 2019-04-15 Task processing method and device Active CN111831422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910300649.8A CN111831422B (en) 2019-04-15 2019-04-15 Task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910300649.8A CN111831422B (en) 2019-04-15 2019-04-15 Task processing method and device

Publications (2)

Publication Number Publication Date
CN111831422A true CN111831422A (en) 2020-10-27
CN111831422B CN111831422B (en) 2024-04-30

Family

ID=72915333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910300649.8A Active CN111831422B (en) 2019-04-15 2019-04-15 Task processing method and device

Country Status (1)

Country Link
CN (1) CN111831422B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591721A (en) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 Method and system for distributing thread execution task
CN104572277A (en) * 2014-12-17 2015-04-29 大唐移动通信设备有限公司 Thread flow control method and thread flow control device
CN108255607A (en) * 2018-01-08 2018-07-06 武汉斗鱼网络科技有限公司 Task processing method, device, electric terminal and readable storage medium storing program for executing
CN108804215A (en) * 2018-06-12 2018-11-13 北京奇艺世纪科技有限公司 A kind of task processing method, device and electronic equipment
WO2018219480A1 (en) * 2017-05-29 2018-12-06 Barcelona Supercomputing Center - Centro Nacional De Supercomputación Managing task dependency
CN109308214A (en) * 2017-07-27 2019-02-05 北京京东尚科信息技术有限公司 Data task processing method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591721A (en) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 Method and system for distributing thread execution task
CN104572277A (en) * 2014-12-17 2015-04-29 大唐移动通信设备有限公司 Thread flow control method and thread flow control device
WO2018219480A1 (en) * 2017-05-29 2018-12-06 Barcelona Supercomputing Center - Centro Nacional De Supercomputación Managing task dependency
US20200110634A1 (en) * 2017-05-29 2020-04-09 Barcelona Supercomputing Center - Centro Nacional De Supercomputacion Managing Task Dependency
CN109308214A (en) * 2017-07-27 2019-02-05 北京京东尚科信息技术有限公司 Data task processing method and system
CN108255607A (en) * 2018-01-08 2018-07-06 武汉斗鱼网络科技有限公司 Task processing method, device, electric terminal and readable storage medium storing program for executing
CN108804215A (en) * 2018-06-12 2018-11-13 北京奇艺世纪科技有限公司 A kind of task processing method, device and electronic equipment

Also Published As

Publication number Publication date
CN111831422B (en) 2024-04-30

Similar Documents

Publication Publication Date Title
CN111897633A (en) Task processing method and device
CN108809683B (en) Method and device for deploying cloud application system
CN110750343B (en) Cluster system timing task scheduling control method and cluster system
CN109062681A (en) A kind of execution method, system, device and the storage medium of periodic cycle task
CN110413395A (en) Service call pre-heating mean, device, equipment and storage medium
CN110704172B (en) Cluster system timing task scheduling method and cluster system
CN104702534A (en) Method and device for processing data of multi-process sharing port
CN113434283B (en) Service scheduling method and device, server and computer readable storage medium
CN113485812B (en) Partition parallel processing method and system based on large-data-volume task
CN115001990A (en) Cross-region openstack cluster management method and system based on declarative API
CN106897128B (en) Distributed application quitting method, system and server
CN111831422A (en) Task processing method and device
CN113010330A (en) Method and terminal for retrying micro-service request
CN116599828A (en) Task execution method and device, storage medium and electronic equipment
CN111767122A (en) Distributed task scheduling management method and device
CN113342466A (en) Kubernetes cloud native container-based variable starting resource limitation method and system
CN115220887A (en) Processing method of scheduling information, task processing system, processor and electronic equipment
CN109634749B (en) Distributed unified scheduling method and device
CN113434280A (en) Method for dynamically adjusting scheduling interval based on time
CN110647440A (en) Big data task processing method and system based on state machine
CN110430090A (en) A kind of distributed system election queue optimization method and device
CN114546631A (en) Task scheduling method, control method, core, electronic device and readable medium
CN107317880B (en) Method and device for realizing load balance
CN111309467A (en) Task distribution method and device, electronic equipment and storage medium
JPH06243077A (en) Distributed transaction processing system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant