CN109766171A - Task processing method, device, equipment and storage medium - Google Patents

Task processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN109766171A
CN109766171A CN201811489995.7A CN201811489995A CN109766171A CN 109766171 A CN109766171 A CN 109766171A CN 201811489995 A CN201811489995 A CN 201811489995A CN 109766171 A CN109766171 A CN 109766171A
Authority
CN
China
Prior art keywords
thread
task
busy
timer
condition
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
CN201811489995.7A
Other languages
Chinese (zh)
Other versions
CN109766171B (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.)
Zebra Network Technology Co Ltd
Original Assignee
Zebra Network Technology 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 Zebra Network Technology Co Ltd filed Critical Zebra Network Technology Co Ltd
Priority to CN201811489995.7A priority Critical patent/CN109766171B/en
Publication of CN109766171A publication Critical patent/CN109766171A/en
Application granted granted Critical
Publication of CN109766171B publication Critical patent/CN109766171B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention provides a kind of task processing method, device, equipment and storage medium, this method comprises: obtaining the priority ranking of set of tasks in the service of computer system middle layer, wherein the task in set of tasks includes task of timer and request task;The task in set of tasks is distributed to first thread and the second thread according to priority ranking, wherein each task in set of tasks is distributed to a thread;Obtain the busy-idle condition of first thread and the busy-idle condition of the second thread, wherein busy-idle condition includes at least busy condition and idle state;When the busy-idle condition of the busy-idle condition of first thread and the second thread is not identical, the quantity of first thread processing task and the quantity of the second thread process task are adjusted, so that the thread in busy condition distributes untreated task to the thread being in idle condition.Untreated task is distributed to other threads, handles task in time;Task of timer and request task thread are shared, improve thread utilization rate.

Description

Task processing method, device, equipment and storage medium
Technical field
The present invention relates to field of computer technology more particularly to a kind of task processing method, device, equipment and storage to be situated between Matter.
Background technique
In computer systems, middle layer service is the bridge connected between upper layer application and bottom hardware, each service It needs to handle respectively and issues a large amount of requests reported with bottom hardware from upper layer application, these requests are usually abstracted into unification Task handled.Some tasks need to guarantee cycling service simultaneously, it is therefore desirable to timer be arranged in system service.
In order to guarantee the timeliness of task processing and not block the normal logic of main thread, these tasks are usually distributed to Asynchronous process is carried out in mission thread.Some tasks need to guarantee cycling service simultaneously, it is therefore desirable to set in system service Set timer.When computer system is encountering multitask and more timers situation to be processed, timer is placed on to single processing Thread, task are placed in the thread pool independently created and are handled, and independent process is distributed between each thread in thread pool To the task of this thread.
However, since timer processing thread and task handle thread independent process, and between each task processing thread Independent process is easy to cause each thread in system when some task of some thread process or when taking a long time of timer Busy and idle state it is inconsistent, thread resources are unable to fully utilize.
Summary of the invention
The present invention provides a kind of task processing method, device, equipment and storage medium, it is intended to solve at existing task Reason method takes independent process mode, and thread resources in system is caused to be unable to fully the technical issues of utilizing.
In a first aspect, the present invention provides a kind of task processing method, comprising: obtain and appoint in the service of computer system middle layer The priority ranking for set of being engaged in, wherein the task in set of tasks includes task of timer and request task;It is arranged according to priority Sequence distributes the task in set of tasks to first thread and the second thread, wherein each task in set of tasks distribute to One thread;Obtain the busy-idle condition of first thread and the busy-idle condition of the second thread, wherein busy-idle condition includes at least busy State and idle state;When the busy-idle condition of the busy-idle condition of first thread and the second thread is not identical, first thread is adjusted The quantity of the quantity of processing task and the second thread process task, so that the thread in busy condition divides untreated task It is assigned to the thread being in idle condition.
In a kind of task processing method provided by the invention, will task of timer and request task mix after arrange Sequence, and thread is distributed according to ranking results after mixing.And the busy-idle condition of per thread is obtained, according to the busy-idle condition tune of thread The quantity of whole per thread processing task, so that the thread in busy condition distributes untreated task in idle shape The thread of state so that in system each thread it is busy consistent with idle state, realize making full use of for thread.
Optionally, the quantity of the quantity of adjustment first thread processing task and the second thread process task, specifically includes: when The busy-idle condition of first thread be busy condition, and the busy-idle condition of the second thread be idle state when, first thread is not located The task of reason is distributed to the second thread;Alternatively, working as the busy-idle condition of first thread for idle state, and the busy shape of the second thread When state is busy condition, the untreated task of the second thread is distributed to first thread.
In a kind of task processing method provided by the invention, the thread in busy condition distributes untreated task To the thread being in idle condition so that in system each thread it is busy consistent with idle state, realize the abundant benefit of thread With.
Optionally, it after the quantity of adjustment first thread processing task and the quantity of the second thread process task, also wraps It includes: when the busy-idle condition of the busy-idle condition of first thread and the second thread is busy, increasing third thread in thread pool, Third thread is in idle condition, wherein thread pool includes first thread, the second thread and third thread;By first thread Untreated task and the untreated task of the second thread are distributed to third thread.
In a kind of task processing method provided by the invention, when threads all in thread pool are in busy condition, It increases new thread in thread pool newly, so that new thread can share the task for the thread that other are in busy condition, handles in time Task improves task treatment effeciency.
Optionally, according to priority ranking by the task in set of tasks distribute to first thread and the second thread it Afterwards, further includes: obtain the time limit state of task of timer;Wherein, the time limit state of task of timer includes timeout mode and not Timeout mode;According to the busy-idle condition tune of the time limit state of task of timer, the busy-idle condition of first thread and the second thread The thread that whole task of timer is distributed, wherein the thread that task of timer is distributed is first thread or the second thread.
In a kind of task processing method provided by the invention, stringent situation was required the time limit for task of timer, The realization state of supervision timer task, according to the busy-idle condition and timer of first thread in thread pool and the second thread Time limit state avoid task of timer to adjust timer assigned thread and timeout case occur.
Optionally, according to the time limit state of task of timer, the busy of the busy-idle condition of first thread and the second thread The thread that is distributed of state adjustment task of timer, specifically includes: when timer is distributed to first thread, task of timer when Limit state is the state of timeout mode and the second thread when being idle state, and timer is distributed to the second thread;Alternatively, when fixed When device distribute to first thread, the time limit state of task of timer is that the state of timeout mode and the second thread is busy condition When, increase by the 4th thread in thread pool, task of timer is distributed to the 4th thread, wherein the 4th thread is in idle shape State, thread pool include first thread, the second thread and the 4th thread.
In a kind of task processing method provided by the invention, when the state of task of timer is timeout mode, it will determine When have a high regard for business to turn distribution to the thread being in idle condition, processing is in the task of timer of timeout mode in time, improves thread Handle the efficiency of task of timer.
Optionally, according to priority ranking by the task in set of tasks distribute to first thread and the second thread it Afterwards, further includes: when the sum of the quantity of the first thread in busy condition and the quantity of the second thread in busy condition are small When the quantity of task, first thread or the second thread are closed;Alternatively, when in busy condition first thread quantity and When the sum of quantity of the second thread in busy condition is greater than the quantity of task, increase by the 5th thread in thread pool, wherein Thread pool includes first thread, the second thread and the 5th thread, and the 5th thread is for handling task.
In a kind of task processing method provided by the invention, according to the quantity of the thread in busy condition and task The relationship of quantity, closing or newly-increased thread, to realize the dynamic adjustment of number of threads.
Task Processing Unit, electronic equipment and storage medium are introduced below, implementing principle and technical effect with Above method principle is similar with technical effect, and details are not described herein again.
Second aspect, the present invention provide a kind of Task Processing Unit characterized by comprising first obtains module, is used for Obtain the priority ranking of set of tasks in the service of computer system middle layer, wherein the task in set of tasks includes timing Have a high regard for business and request task;First distribution module, for distributing the task in set of tasks to first according to priority ranking Thread and the second thread, wherein each task in set of tasks is distributed to a thread;First acquisition module is also used to obtain The busy-idle condition of the busy-idle condition of first thread and the second thread, wherein busy-idle condition includes at least busy condition and idle shape State;The first adjustment module, for adjusting first when the busy-idle condition of the busy-idle condition of first thread and the second thread is not identical The quantity of the quantity of thread process task and the second thread process task, so that the thread in busy condition is by untreated Business is distributed to the thread being in idle condition.
Optionally, the first adjustment module specifically includes: when the busy-idle condition of first thread is busy condition, and the second line When the busy-idle condition of journey is idle state, the untreated task of first thread is distributed to the second thread;Alternatively, working as first thread Busy-idle condition be idle state, and the busy-idle condition of the second thread be busy condition when, by the untreated task of the second thread It distributes to first thread.
Optionally, further includes: increase module, for when first thread busy-idle condition and the second thread busy-idle condition it is equal When being busy, increase third thread in thread pool, third thread is in idle condition, wherein thread pool include first thread, Second thread and third thread;Second distribution module, for the untreated task of first thread and the second thread is untreated Task distribute to third thread.
Optionally, further includes: second obtains module, for obtaining the time limit state of task of timer;Wherein, periodically have a high regard for The time limit state of business includes timeout mode and has not timed out state;Second adjustment module, for the time limit shape according to task of timer The thread that the busy-idle condition adjustment task of timer of state, the busy-idle condition of first thread and the second thread is distributed, wherein fixed When to have a high regard for the distributed thread of being engaged in be first thread or the second thread.
Optionally, second adjustment module specifically includes: when timer is distributed to first thread, the time limit shape of task of timer State is the state of timeout mode and the second thread when being idle state, and timer is distributed to the second thread;Alternatively, working as timer Distribution is to first thread, and the time limit state of task of timer is the state of timeout mode and the second thread when being busy condition, Increase by the 4th thread in thread pool, task of timer is distributed to the 4th thread, wherein the 4th thread is in idle condition, line Cheng Chi includes first thread, the second thread and the 4th thread.
Optionally, further includes: third adjusts module, for the quantity when the first thread in busy condition and in busy When the sum of quantity of the second thread of commonplace state is less than the quantity of task, first thread or the second thread are closed;Alternatively, when place When the sum of quantity in the first thread of busy condition and the quantity of the second thread in busy condition are greater than the quantity of task, Increase by the 5th thread in thread pool, wherein thread pool includes first thread, the second thread and the 5th thread, the 5th thread For handling task.
The third aspect, a kind of electronic equipment of the present invention characterized by comprising at least one processor and memory;Its In, memory stores computer executed instructions;At least one processor executes the computer executed instructions of memory storage, so that At least one processor executes the task processing method that first aspect and optinal plan are related to.
Fourth aspect, a kind of computer readable storage medium of the present invention, which is characterized in that in computer readable storage medium Computer executed instructions are stored with, when processor executes computer executed instructions, realize that first aspect and optinal plan are related to Task processing method.
Task processing method, device, equipment and storage medium provided by the invention will be determined in task processing method When have a high regard for business and request task to be ranked up, and task of timer and request task are distributed to line using the priority after sequence Journey realizes that the thread of task of timer and request task is shared, and the busy-idle condition of monitoring thread, when thread busy-idle condition not When consistent, untreated task in the thread in busy condition is distributed to the thread being in idle condition to other, to realize Processing task in time, and the thread of task of timer and request task is shared, and thread utilization rate can be improved.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is this hair Bright some embodiments for those of ordinary skill in the art without any creative labor, can be with It obtains other drawings based on these drawings.
Fig. 1 is the flow diagram of present invention task processing method shown according to an exemplary embodiment;
Fig. 2 is the flow diagram for the task processing method that the present invention is shown according to another exemplary embodiment;
Fig. 3 is the flow diagram for the task processing method that the present invention is shown according to a further exemplary embodiment;
Fig. 4 is flow diagram of the present invention according to the task processing method shown in another exemplary embodiment;
Fig. 5 is the structural schematic diagram of present invention Task Processing Unit shown according to an exemplary embodiment;
Fig. 6 is the structural schematic diagram of present invention electronic equipment shown according to an exemplary embodiment.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
The present invention provides a kind of task processing method, device, equipment and storage medium, it is intended to solve at existing task Reason method takes independent process mode, and thread resources in system is caused to be unable to fully the technical issues of utilizing.
Fig. 1 is the flow diagram of present invention task processing method shown according to an exemplary embodiment.Such as Fig. 1 institute Show, task processing method provided in this embodiment, comprising:
S101, the priority ranking for obtaining set of tasks in the service of computer system middle layer.
More specifically, the task in set of tasks includes task of timer and request task.Ordinary circumstance, task of timer Priority be higher than request task.Priority between task of timer is overtime according to the timeout mode of task of timer, distance Time determines.Priority between request task is true according to the initiation time of the object and request task of initiating request task It is fixed.
Such as: it include task of timer 1, task of timer 2, request task 3 and request task 4 in set of tasks. Under normal circumstances, the priority of task of timer 1 and task of timer 2 is higher than request task 3 and request task 4.Timing is had a high regard for Business 1 and task of timer 2 have not timed out, and task of timer 1 is greater than task of timer 2 apart from time-out time, then periodically has a high regard for The priority of business 2 is higher than task of timer 1.Request task 3 and request task 4 are sent by bottom hardware, and request task 3 The initiation request time that request time is later than request task 4 is initiated, the priority of request task 4 is higher than the preferential of request task 3 Grade, the then priority of set of tasks are as follows: task of timer 2, task of timer 1, request task 4 and request task 3.
Another example is: including task of timer 1, task of timer 2, request task 3 and request task in set of tasks 4.1 time-out of task of timer, task of timer 2 have not timed out, then the priority of task of timer 1 is higher than task of timer 2.Please Task 3 is asked to be sent by upper layer application, request task 4 is sent by bottom hardware, and the priority of request task 3 is higher than request task 4 Priority, then the priority of set of tasks are as follows: task of timer 1, task of timer 2, request task 3 and request task 4.
S102, the task in set of tasks is distributed to first thread and the second thread according to priority ranking.
More specifically, thread pool includes first thread and the second thread, each task in set of tasks is distributed to one Thread distributes thread according to the priority of set of tasks, and the thread of task distribution can be first thread or the second thread.
Such as: obtain the priority of set of tasks are as follows: task of timer 2, task of timer 1, request task 4 and request Task 3.And first thread and the second thread are untreated any task.Then task of timer 2 is distributed to first thread, it will The distribution of task of timer 1 is to the second thread, by the distribution of request task 4 to first thread, by the distribution of request task 3 to the second line Journey.
Another example is: obtaining the priority of set of tasks are as follows: task of timer 2, task of timer 1, request task 4 and ask Seek task 3.And task is to be processed there are two first threads, the untreated any task of the second thread.Second thread process two is fixed When have a high regard for business the time required to be greater than first thread handle two waiting task times, then by task of timer 2, task of timer 1 and request task 3 be sequentially allocated distribution to the second thread so that the sequence of the second thread process task are as follows: task of timer 2, task of timer 1 and request task 3.Request task 4 is distributed to first thread, so that first thread is handling two After waiting task, request task 3 can handle, and guarantee request task 3 prior to request task 4.
The busy-idle condition of S103, the busy-idle condition for obtaining first thread and the second thread.
More specifically, the busy-idle condition of thread includes at least busy condition and idle state.Obtain the busy of first thread The busy-idle condition of state and the second thread, to adjust the quantity of first thread processing task and the number of the second thread process task Amount.
Whether S104, the busy-idle condition for judging first thread and the second thread busy-idle condition are consistent, if the determination result is YES, Then enter step S105.If judging result be it is no, enter step S106.
The quantity of S105, the quantity for not adjusting first thread processing task and the second thread process task.
More specifically, not adjusted then when the busy-idle condition for judging first thread and the second thread busy-idle condition are consistent First thread handles the quantity of task and the quantity of the second thread process task.
The quantity of S106, the quantity of adjustment first thread processing task and the second thread process task.
If judging result be it is no, adjustment first thread processing task quantity and the second thread process task quantity, with Distribute the thread in busy condition untreated task to the thread being in idle condition.
More specifically, when the busy-idle condition of first thread is busy condition, and the busy-idle condition of the second thread is idle shape When state, the untreated task of first thread is distributed to the second thread.When the busy-idle condition of first thread is idle state, and the When the busy-idle condition of two threads is busy condition, the untreated task of the second thread is distributed to first thread.So that First Line The busy-idle condition of the busy-idle condition of journey and the second thread is consistent.When the busy-idle condition of first thread and the busy-idle condition of the second thread When being idle state, alternatively, when the busy-idle condition of the busy-idle condition of first thread and the second thread is busy condition, The quantity of first thread processing task and the quantity of the second thread process task are not adjusted.
In task processing method provided in this embodiment, it is ranked up after task of timer and request task are mixed, And distributed task of timer and request task to thread, and the busy-idle condition of monitoring thread using the priority after sequence, when When the busy-idle condition of thread is inconsistent, untreated task in the thread in busy condition is distributed to other threads, with reality Task is now handled in time, and the thread of task of timer and request task is shared, and thread utilization rate can be improved.
Fig. 2 is the flow diagram for the task processing method that the present invention is shown according to another exemplary embodiment.Such as Fig. 2 institute Show, task processing method provided in this embodiment includes:
S201, the priority ranking for obtaining set of tasks in the service of computer system middle layer.
S202, the task in set of tasks is distributed to first thread and the second thread according to priority ranking.
The busy-idle condition of S203, the busy-idle condition for obtaining first thread and the second thread.
Whether S204, the busy-idle condition for judging first thread and the second thread busy-idle condition are consistent, if the determination result is YES, Then enter step S205.If judging result be it is no, enter step S206.
The quantity of S205, the quantity for not adjusting first thread processing task and the second thread process task.
The quantity of S206, the quantity of adjustment first thread processing task and the second thread process task.
Whether S207, the busy-idle condition for judging first thread and the second thread busy-idle condition are busy condition.If judgement As a result be it is no, then terminate process.If the determination result is YES, then enter S208.
S208, when the busy-idle condition of the busy-idle condition of first thread and the second thread is busy, increase in thread pool Add third thread.
More specifically, judging whether the busy-idle condition of first thread and the second thread busy-idle condition are consistent, if judging result Be it is yes, whether the busy-idle condition for continuing the busy-idle condition for judging first thread and the second thread is busy condition, if judgement knot Fruit be it is yes, then increase third thread in thread pool, and third thread is in idle condition, so that thread pool includes First Line Journey, the second thread and third thread.
S209, the untreated task of first thread and the untreated task of the second thread are distributed to third thread.
More specifically, the untreated task of first thread and the untreated task of the second thread are distributed to third thread, Untreated task can be made to be handled in time, especially to the higher task of timer of time requirement.
In task processing method provided in this embodiment, when threads all in thread pool are in busy condition, online Cheng Chizhong increases new thread newly, so that new thread can share the task for the thread that other are in busy condition, processing is appointed in time Business improves task treatment effeciency.
Fig. 3 is the flow diagram for the task processing method that the present invention is shown according to a further exemplary embodiment.Such as Fig. 3 institute Show, task processing method provided in this embodiment includes:
S301, the priority ranking for obtaining set of tasks in the service of computer system middle layer.
S302, the task in set of tasks is distributed to first thread and the second thread according to priority ranking.
S303, the time limit state for obtaining task of timer.
More specifically, the time limit state of task of timer includes timeout mode and has not timed out state.
S304, according to the busy shape of the time limit state of task of timer, the busy-idle condition of first thread and the second thread The thread that state adjustment task of timer is distributed.
More specifically, the time limit state of task of timer is timeout mode when task of timer is distributed to first thread, the When the state of two threads is idle state, timer is distributed to the second thread, so that the task of timer of timeout mode is timely Processing.
When task of timer is distributed to first thread, the time limit state of task of timer is timeout mode and the second thread When state is busy condition, increases by the 4th thread in thread pool, task of timer is distributed to the 4th thread, so that thread pool Including first thread, the second thread and the 4th thread, wherein the 4th thread is in idle condition.
Accordingly, when task of timer is distributed to the second thread, the time limit state of task of timer is timeout mode, first When the state of thread is idle state, timer is distributed to first thread, so that the task of timer of timeout mode is located in time Reason.
When task of timer is distributed to the second thread, the time limit state of task of timer is timeout mode and first thread When state is busy condition, increases by the 4th thread in thread pool, task of timer is distributed to the 4th thread, so that overtime shape The task of timer of state is handled in time.
It, will timing when the state of task of timer is timeout mode in task processing method provided in this embodiment Business is had a high regard for turn distribution to the thread being in idle condition, processing is in the task of timer of timeout mode in time, improves at thread Manage the efficiency of task of timer.
Fig. 4 is flow diagram of the present invention according to the task processing method shown in another exemplary embodiment.Such as Fig. 4 institute Show, task processing method provided in this embodiment includes:
S401, the priority ranking for obtaining set of tasks in the service of computer system middle layer.
S402, the task in set of tasks is distributed to first thread and the second thread according to priority ranking.
S403, judgement in busy condition first thread quantity and the second thread in busy condition quantity it If the determination result is YES then enter S404, otherwise, into S405 with the quantity for being less than task.
S404, first thread or the second thread are closed.
More specifically, when the quantity of the first thread in busy condition and the quantity of the second thread in busy condition The sum of when being less than the quantity of task, close first thread or the second thread, to reduce number of threads, improve thread utilization rate.
S405, increase by the 5th thread in thread pool.
More specifically, when the quantity of the first thread in busy condition and the quantity of the second thread in busy condition The sum of be greater than task quantity when, in thread pool increase the 5th thread so that thread pool include first thread, the second thread with And the 5th thread, wherein the 5th thread, to handle task in time, improves task treatment effeciency for handling task.
In task processing method provided in this embodiment, according to the number of the quantity of the thread in busy condition and task The relationship of amount, closing or newly-increased thread, to realize the dynamic adjustment of number of threads.
Fig. 5 is the structural schematic diagram of present invention Task Processing Unit shown according to an exemplary embodiment.Such as Fig. 5 institute Show, Task Processing Unit provided in this embodiment includes: the first acquisition module 101, for obtaining computer system middle layer clothes The priority ranking of set of tasks in business, wherein the task in set of tasks includes task of timer and request task;First point With module 102, for the task in set of tasks to be distributed to first thread and the second thread according to priority ranking, wherein Each task in set of tasks is distributed to a thread;First acquisition module 101 is also used to obtain the busy shape of first thread The busy-idle condition of state and the second thread, wherein busy-idle condition includes at least busy condition and idle state;The first adjustment module 103, for when the busy-idle condition of the busy-idle condition of first thread and the second thread is not identical, adjustment first thread to handle task Quantity and the second thread process task quantity so that the thread in busy condition distributes untreated task to being in The thread of idle state.
Optionally, the first adjustment module 103, specifically includes: when the busy-idle condition of first thread is busy condition, and second When the busy-idle condition of thread is idle state, the untreated task of first thread is distributed to the second thread;Alternatively, working as First Line The busy-idle condition of journey be idle state, and the busy-idle condition of the second thread be busy condition when, by the second thread untreated Business is distributed to first thread.
Optionally, further includes: increase module 104, for when the busy-idle condition of first thread and the busy shape of the second thread When state is busy, increase third thread in thread pool, third thread is in idle condition, wherein thread pool includes first Thread, the second thread and third thread;Second distribution module 105 is used for the untreated task of first thread and the second line The untreated task of journey is distributed to third thread.
Optionally, further includes: second obtains module 106, for obtaining the time limit state of task of timer;Wherein, timing The time limit state for having a high regard for business includes timeout mode and has not timed out state;Second adjustment module 107, for according to task of timer The thread that the busy-idle condition adjustment task of timer of time limit state, the busy-idle condition of first thread and the second thread is distributed, Wherein, the thread that task of timer is distributed is first thread or the second thread.
Optionally, second adjustment module 107 specifically includes: when timer is distributed to first thread, task of timer when Limit state is the state of timeout mode and the second thread when being idle state, and timer is distributed to the second thread;Alternatively, when fixed When device distribute to first thread, the time limit state of task of timer is that the state of timeout mode and the second thread is busy condition When, increase by the 4th thread in thread pool, task of timer is distributed to the 4th thread, wherein the 4th thread is in idle shape State, thread pool include first thread, the second thread and the 4th thread.
Optionally, further includes: third adjusts module 108, for working as quantity and the place of the first thread in busy condition When the sum of quantity of the second thread of busy condition is less than the quantity of task, first thread or the second thread are closed;Alternatively, When the sum of the quantity of the first thread in busy condition and the quantity of the second thread in busy condition are greater than the number of task When amount, increasing by the 5th thread in thread pool, wherein thread pool includes first thread, the second thread and the 5th thread, and the 5th Thread is for handling task.
Fig. 6 is the structural schematic diagram of present invention electronic equipment shown according to an exemplary embodiment, as shown in fig. 6, this The electronic equipment 200 of embodiment includes: processor 201 and memory 202, wherein
Memory 202, for storing computer executed instructions;
Processor 201 is set for executing the computer executed instructions of memory storage with realizing to receive in above-described embodiment Standby performed each step.It specifically may refer to the associated description in preceding method embodiment.
Optionally, memory 202 can also be integrated with processor 201 either independent.
When memory 202 is independently arranged, which further includes bus 203, for connecting the storage Device 202 and processor 201.
The embodiment of the present invention also provides a kind of computer readable storage medium, stores in the computer readable storage medium There are computer executed instructions, when processor executes the computer executed instructions, realizes task processing method as described above.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution The range of scheme.

Claims (10)

1. a kind of task processing method characterized by comprising
Obtain the priority ranking of set of tasks in the service of computer system middle layer, wherein the task in the set of tasks Including task of timer and request task;
The task in the set of tasks is distributed to first thread and the second thread according to the priority ranking, wherein institute Each task in set of tasks is stated to distribute to a thread;
Obtain the busy-idle condition of the first thread and the busy-idle condition of second thread, wherein the busy-idle condition is at least Including busy condition and idle state;
When the busy-idle condition of the busy-idle condition of the first thread and second thread is not identical, the first thread is adjusted The quantity of the quantity of processing task and the second thread process task, so that the thread in busy condition is by untreated Business is distributed to the thread being in idle condition.
2. the method according to claim 1, wherein the quantity of adjustment first thread processing task and The quantity of the second thread process task, specifically includes:
When the busy-idle condition of the first thread is busy condition, and the busy-idle condition of second thread is idle state, The untreated task of the first thread is distributed to second thread;
Alternatively,
When the busy-idle condition of the first thread is idle state, and the busy-idle condition of second thread is busy condition, The untreated task of second thread is distributed to the first thread.
3. according to the method described in claim 2, it is characterized in that, handling the quantity of task in the adjustment first thread After the quantity of the second thread process task, further includes:
When the busy-idle condition of the busy-idle condition of the first thread and second thread is busy, increase in thread pool Third thread, the third thread are in idle condition, wherein the thread pool includes the first thread, second line Journey and the third thread;
The untreated task of the first thread and the untreated task of second thread are distributed to described Three threads.
4. the method according to claim 1, wherein will be in the set of tasks according to the priority ranking Task distribute to first thread and the second thread, further includes:
Obtain the time limit state of the task of timer;Wherein, the time limit state of the task of timer include timeout mode and Have not timed out state;
According to the time limit state of the task of timer, the busy of the busy-idle condition of the first thread and second thread State adjusts the thread that the task of timer is distributed, wherein the thread that the task of timer is distributed is described first Thread or second thread.
5. according to the method described in claim 4, it is characterized in that, the time limit state according to the task of timer, institute The busy-idle condition of the busy-idle condition and second thread of stating first thread adjusts the thread that the task of timer is distributed, It specifically includes:
When the task of timer is distributed to the first thread, the time limit state of the task of timer is timeout mode and institute When the state for stating the second thread is idle state, the timer is distributed to second thread;
Alternatively,
When the task of timer is distributed to the first thread, the time limit state of the task of timer is timeout mode and institute When the state for stating the second thread is busy condition, increases by the 4th thread in the thread pool, the task of timer is distributed To the 4th thread, wherein the 4th thread is in idle condition, and the thread pool includes the first thread, described Second thread and the 4th thread.
6. the method according to claim 1, wherein will be in the set of tasks according to the priority ranking Task distribute to first thread and the second thread, further includes:
When the quantity of the first thread in busy condition and the sum of the quantity of second thread in busy condition Less than the task quantity when, close the first thread or second thread;
Alternatively,
When the quantity of the first thread in busy condition and the sum of the quantity of second thread in busy condition Greater than the task quantity when, in thread pool increase the 5th thread, wherein the thread pool include the first thread, Second thread and the 5th thread, the 5th thread is for handling the task.
7. a kind of Task Processing Unit characterized by comprising
First obtains module, for obtaining the priority ranking of set of tasks in the service of computer system middle layer, wherein described Task in set of tasks includes task of timer and request task;
First distribution module, for the task in the set of tasks to be distributed to first thread according to the priority ranking and Second thread, wherein each task in the set of tasks is distributed to a thread;
The first acquisition module is also used to obtain the busy-idle condition of the busy-idle condition and second thread of the first thread, Wherein, the busy-idle condition includes at least busy condition and idle state;
The first adjustment module, for when the first thread busy-idle condition and second thread busy-idle condition it is not identical When, the quantity of the first thread processing task and the quantity of the second thread process task are adjusted, so as to be in busy shape The thread of state distributes untreated task to the thread being in idle condition.
8. device according to claim 7, which is characterized in that the first adjustment module specifically includes:
When the busy-idle condition of the first thread is busy condition, and the busy-idle condition of second thread is idle state, The untreated task of the first thread is distributed to second thread;
Alternatively,
When the busy-idle condition of the first thread is idle state, and the busy-idle condition of second thread is busy condition, The untreated task of second thread is distributed to the first thread.
9. a kind of electronic equipment characterized by comprising at least one processor and memory;
Wherein, the memory stores computer executed instructions;
At least one described processor executes the computer executed instructions of the memory storage, so that at least one described processing Device executes task processing method as claimed in claim 1 or 2.
10. a kind of computer readable storage medium, which is characterized in that be stored with computer in the computer readable storage medium It executes instruction, when processor executes the computer executed instructions, realizes as claim is as claimed in claim 1 or 2 Task processing method.
CN201811489995.7A 2018-12-06 2018-12-06 Task processing method, device, equipment and storage medium Active CN109766171B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811489995.7A CN109766171B (en) 2018-12-06 2018-12-06 Task processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811489995.7A CN109766171B (en) 2018-12-06 2018-12-06 Task processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109766171A true CN109766171A (en) 2019-05-17
CN109766171B CN109766171B (en) 2021-03-30

Family

ID=66451281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811489995.7A Active CN109766171B (en) 2018-12-06 2018-12-06 Task processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109766171B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134578A (en) * 2019-05-23 2019-08-16 浙江齐治科技股份有限公司 A kind of data processing method and device
CN111651272A (en) * 2020-05-28 2020-09-11 苏州大学 Thread time management method and device for embedded real-time operation
CN111767125A (en) * 2020-06-15 2020-10-13 杭州数梦工场科技有限公司 Task execution method and device, electronic equipment and storage medium
CN113342886A (en) * 2021-06-23 2021-09-03 杭州数梦工场科技有限公司 Data exchange method and device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101262367A (en) * 2008-03-07 2008-09-10 中兴通讯股份有限公司 Collection method and device for performance data
CN101739293A (en) * 2009-12-24 2010-06-16 航天恒星科技有限公司 Method for scheduling satellite data product production tasks in parallel based on multithread
CN103645909A (en) * 2013-12-30 2014-03-19 中国烟草总公司湖南省公司 Handling method and device for timed task
CN105760234A (en) * 2016-03-17 2016-07-13 联动优势科技有限公司 Thread pool management method and device
CN106445659A (en) * 2016-09-09 2017-02-22 北京控制工程研究所 Periodic hybrid random task scheduling method for spacecraft
CN106874090A (en) * 2017-01-23 2017-06-20 北京思特奇信息技术股份有限公司 Job scheduling method and system based on cloud system
CN108268546A (en) * 2016-12-30 2018-07-10 中国移动通信集团黑龙江有限公司 A kind of method and device for optimizing database
CN108446180A (en) * 2018-03-23 2018-08-24 南京航空航天大学 A kind of data center dynamic method for scheduling task based on Data Migration

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101262367A (en) * 2008-03-07 2008-09-10 中兴通讯股份有限公司 Collection method and device for performance data
CN101739293A (en) * 2009-12-24 2010-06-16 航天恒星科技有限公司 Method for scheduling satellite data product production tasks in parallel based on multithread
CN103645909A (en) * 2013-12-30 2014-03-19 中国烟草总公司湖南省公司 Handling method and device for timed task
CN105760234A (en) * 2016-03-17 2016-07-13 联动优势科技有限公司 Thread pool management method and device
CN106445659A (en) * 2016-09-09 2017-02-22 北京控制工程研究所 Periodic hybrid random task scheduling method for spacecraft
CN108268546A (en) * 2016-12-30 2018-07-10 中国移动通信集团黑龙江有限公司 A kind of method and device for optimizing database
CN106874090A (en) * 2017-01-23 2017-06-20 北京思特奇信息技术股份有限公司 Job scheduling method and system based on cloud system
CN108446180A (en) * 2018-03-23 2018-08-24 南京航空航天大学 A kind of data center dynamic method for scheduling task based on Data Migration

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134578A (en) * 2019-05-23 2019-08-16 浙江齐治科技股份有限公司 A kind of data processing method and device
CN111651272A (en) * 2020-05-28 2020-09-11 苏州大学 Thread time management method and device for embedded real-time operation
CN111651272B (en) * 2020-05-28 2023-02-03 苏州大学 Thread time management method and device for embedded real-time operation
CN111767125A (en) * 2020-06-15 2020-10-13 杭州数梦工场科技有限公司 Task execution method and device, electronic equipment and storage medium
CN111767125B (en) * 2020-06-15 2023-07-25 杭州数梦工场科技有限公司 Task execution method, device, electronic equipment and storage medium
CN113342886A (en) * 2021-06-23 2021-09-03 杭州数梦工场科技有限公司 Data exchange method and device

Also Published As

Publication number Publication date
CN109766171B (en) 2021-03-30

Similar Documents

Publication Publication Date Title
CN109766171A (en) Task processing method, device, equipment and storage medium
CN108762896B (en) Hadoop cluster-based task scheduling method and computer equipment
CN104156267B (en) Method for allocating tasks, task allocation apparatus and network-on-chip
CN102004670B (en) Self-adaptive job scheduling method based on MapReduce
CN103999051B (en) Strategy for tinter resource allocation in the minds of shader core
US8695004B2 (en) Method for distributing computing time in a computer system
US8799547B2 (en) Data packet processing method for a multi core processor
CN106933669B (en) Apparatus and method for data processing
CN102916953A (en) Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection
US20110145461A1 (en) Method and device for balancing interrupt load of multicore processor
CN110109756A (en) A kind of network target range construction method, system and storage medium
CN105760234A (en) Thread pool management method and device
CN109542831A (en) Airborne platform multi-core virtual multidomain treat-ment system
CN107273206A (en) A kind of priority dispatching method controlled based on business and data volume
CN110297661B (en) Parallel computing method, system and medium based on AMP framework DSP operating system
CN105117285B (en) A kind of nonvolatile memory method for optimizing scheduling based on mobile virtual system
CN103927225A (en) Multi-core framework Internet information processing and optimizing method
US20190087236A1 (en) Resource scheduling device, system, and method
CN108958944A (en) A kind of multiple core processing system and its method for allocating tasks
CN106528065B (en) A kind of thread acquisition methods and equipment
CN111339027A (en) Automatic design method of reconfigurable artificial intelligence core and heterogeneous multi-core chip
CN111782355A (en) Cloud computing task scheduling method and system based on mixed load
CN103944997A (en) Load balancing method with combination of random sampling and virtualization technology
CN102662761A (en) Method and device for scheduling memory pool in multi-core central processing unit system
CN104052677A (en) Soft load balancing method and apparatus of single data source

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