CN102902573A - Task processing method and device based on shared resources - Google Patents

Task processing method and device based on shared resources Download PDF

Info

Publication number
CN102902573A
CN102902573A CN2012103533297A CN201210353329A CN102902573A CN 102902573 A CN102902573 A CN 102902573A CN 2012103533297 A CN2012103533297 A CN 2012103533297A CN 201210353329 A CN201210353329 A CN 201210353329A CN 102902573 A CN102902573 A CN 102902573A
Authority
CN
China
Prior art keywords
task
resource
waiting task
waiting
task queue
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
CN2012103533297A
Other languages
Chinese (zh)
Other versions
CN102902573B (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.)
Beijing Sohu New Media Information Technology Co Ltd
Original Assignee
Beijing Sohu New Media Information 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 Beijing Sohu New Media Information Technology Co Ltd filed Critical Beijing Sohu New Media Information Technology Co Ltd
Priority to CN201210353329.7A priority Critical patent/CN102902573B/en
Publication of CN102902573A publication Critical patent/CN102902573A/en
Application granted granted Critical
Publication of CN102902573B publication Critical patent/CN102902573B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

An embodiment of the invention discloses a task processing method based on shared resources. The method includes receiving tasks to be processed; placing the tasks to be processed into task queues of corresponding resource nodes of multi-stage classification combination queue groups according to resource identifications needed by the tasks to be processed, wherein the task queues of multi-stage classification combination queue groups and resource nodes of a resource node tree built according to a resource superior and subordinate relation have a corresponding relation; and judging whether tasks needed to be processed meeting preset conditions exist in the task queues corresponding to the resource nodes in the multi-stage classification combination queue groups, if the tasks needed to be processed meeting preset conditions exist, the tasks needed to be processed meeting preset conditions exist are extracted and processed. The embodiment of the invention further provides a task processing device based on shared resources. According to the task processing method and device based on shared resources, the processing efficiency of the tasks to be processed is improved.

Description

A kind of disposal route and device of the task based on shared resource
Technical field
The application relates to the access technique field of shared resource, particularly a kind of disposal route and related device thereof of the task based on shared resource.
Background technology
Along with the development of infotech, for satisfying various application demands, need task quantity to be processed sharply to expand, it is also more and more to process resource kind and the quantity used in the process of these tasks.But over a period to come, the total resources of processing various tasks is relatively limited.For the assurance task is processed smoothly, resource needs to share usually, i.e. the common resource of use of a plurality of tasks or the processing of several resource to finish the work.In the resource sharing situation, must exist the coordination system to coordinate various tasks to the taking of resource, avoid occurring conflict in the resource access process, thereby guarantee correct execution and the processing of task.
For the waiting task of shared resource, prior art normal a kind of coordination system that adopts in processing procedure is mutual exclusion lock mechanism.At first obtain mutual exclusion lock corresponding to resource by a plurality of tasks of resource that need of this mechanism, then use exclusively resource, after the task of acquisition mutual exclusion lock utilizes resource to be finished, remove mutual exclusion lock, carry out the task of self so that other tasks are fought for mutual exclusion lock.Although this mutual exclusion lock mechanism has guaranteed " harmony " based on the task of shared resource.But, the resource type that relates to along with pending task and the increase of quantity, because the dissimilar conservation of resources has mutual exclusion lock separately, the task of processing the type then needs a plurality of mutual exclusion lock, thereby to the operation of the mutual exclusion lock very complex that becomes, cause extremely easily " deadlock ".This shows that the lock mechanism that existing processing based on shared resource of task adopts has reduced the task throughput of system, affected the execution efficient of task.
Summary of the invention
For solving the problems of the technologies described above, the embodiment of the present application provides a kind of disposal route and related device thereof of the task based on shared resource, to improve the execution efficient based on the task of shared resource.
The disposal route based on the task of shared resource that the embodiment of the present application provides comprises:
Receive waiting task;
According to the task queue that the sign of the resource of waiting task needs is put into multiclass classification combination set of queues respective resources node with waiting task, the task queue of described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
Judge whether to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfy pre-conditioned waiting task, if exist, then take out and satisfy pre-conditioned waiting task and process.
Preferably, judge whether to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfy pre-conditioned waiting task and specifically comprise:
Judge whether to exist in the task queue corresponding with other resource node of first grade in the multiclass classification combination set of queues and satisfy pre-conditioned waiting task, if exist, then take out and satisfy pre-conditioned waiting task and process; If there is no, judge then whether to exist in the task queue corresponding with other resource node of other next stage of first grade and satisfy pre-conditioned waiting task that if so, then taking-up is satisfied pre-conditioned waiting task and processed.
Further preferably, described method also comprises: set up to be used for the mark of each tasks carrying situation in task queue corresponding to reflection resource node, then: judge that multiclass classification makes up whether to exist in task queue corresponding to each resource node of set of queues and satisfy pre-conditioned waiting task and specifically comprise:
Read the label information of the task in task queue corresponding to resource node;
Judge whether to exist in task queue corresponding to resource node according to the label information that reads and satisfy pre-conditioned waiting task; After satisfying pre-conditioned waiting task and finishing dealing with, revise its corresponding label information.
Further preferably, described mark comprises that current task the finish dealing with mark, resource of the current task of child node of mark, current resource node of finishing dealing with abdicate mark and/or marks for treatment immediately.
Preferably, after receiving waiting task, the waiting task that receives is put into candidate's task queue, read waiting task in candidate's task queue according to preset rules; Then the task queue that waiting task is put into the corresponding resource node of multiclass classification combination set of queues of the sign of described resource according to the waiting task needs is specially:
This waiting task is put into the task queue of multiclass classification combination set of queues respective resources node according to the sign of the resource of the waiting task needs that from candidate's task, read.
Preferably, described taking-up is satisfied pre-conditioned waiting task and is processed specifically and comprise:
From thread pool, take out idle thread;
Utilize this idle thread to carry out the waiting task that takes out.
The embodiment of the present application also provides a kind for the treatment of apparatus of the task based on shared resource.This device comprises: receiving element, first is put into unit, judging unit and processing unit, wherein:
Described receiving element is used for receiving waiting task;
Described first puts into the unit, be used for the task queue of waiting task being put into multiclass classification combination set of queues respective resources node according to the sign of the resource of waiting task needs, the task queue of described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
Whether described judging unit is used for judging existing in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfies pre-conditioned waiting task, if existence then triggers processing unit;
Described processing unit satisfies pre-conditioned waiting task for taking-up and processes.
Preferably, described judging unit comprises: the first judgment sub-unit and the second judgment sub-unit, wherein:
Whether described the first judgment sub-unit is used for judging existing in task queue corresponding to other resource node of multiclass classification combination set of queues and first grade and satisfies pre-conditioned waiting task, if exist, then triggers processing unit; If there is no, then trigger the second judgment sub-unit;
Whether described the second judgment sub-unit is used for judging existing in the task queue corresponding with other resource node of other next stage of first grade and satisfies pre-conditioned waiting task, if so, then triggers processing unit.
Further preferably, described device also comprises: indexing unit and updating block, wherein: described indexing unit, be used for each tasks carrying situation in task queue corresponding to markup resources node, described updating block, be used for update mark information after satisfying pre-conditioned waiting task and finishing dealing with, then: described judging unit also comprises and reads subelement, be used for reading the label information of the task in task queue corresponding to resource node, described the first judgment sub-unit and/or the second judgment sub-unit satisfy pre-conditioned waiting task for judging whether to exist in task queue corresponding to resource node according to the label information that reads.
Preferably, described device also comprises: second puts into the unit, is used for after receiving waiting task the waiting task that receives being put into candidate's task queue according to timestamp; Then described first put into the unit, be used for reading waiting task candidate's task queue from candidate's task queue according to preset rules the task queue of this waiting task being put into multiclass classification combination set of queues respective resources node according to the sign of the resource of the waiting task needs that from candidate's task queue, read.
The embodiment of the present application is put into the waiting task that receives among the task queue of the corresponding resource node of multiclass classification combination formation according to the sign of the resource of its needs, then judge whether to exist in task queue corresponding to each resource node and satisfy pre-conditioned waiting task, if exist, then take out and satisfy pre-conditioned waiting task and process.Compared with prior art, because the multiclass classification of the embodiment of the present application combination set of queues comprises the task queue corresponding with the resource node tree, this resource node tree has been determined level and the restricting relation of task queue according to the resource relationship between superior and subordinate, thereby when processing waiting task, need not take mutual exclusion lock mechanism, have accessible waiting task in the task queue as long as judge, can take out this task and process.The embodiment of the present application has been abandoned traditional mutual exclusion lock mechanism, and the series of problems of having avoided mutual exclusion lock mechanism to bring has improved the treatment effeciency based on the task of shared resource, has improved the task throughput of system.
Description of drawings
In order to be illustrated more clearly in the embodiment of the present application or technical scheme of the prior art, the below will do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art, apparently, the accompanying drawing that the following describes only is some embodiment that put down in writing among the application, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the process flow figure based on the task of shared resource of the embodiment of the present application one;
Fig. 2 is the process flow figure based on the task of shared resource of the embodiment of the present application two;
Fig. 3 is the multiclass classification combination set of queues synoptic diagram of the described embodiment of Fig. 2;
Fig. 4 is mark synoptic diagram corresponding to the resource node of the described embodiment of Fig. 2;
Fig. 5 is the structured flowchart based on the treating apparatus of the task of shared resource of the embodiment of the present application three.
Embodiment
In order to make those skilled in the art person understand better technical scheme among the application, below in conjunction with the accompanying drawing in the embodiment of the present application, technical scheme in the embodiment of the present application is clearly and completely described, obviously, described embodiment only is the application's part embodiment, rather than whole embodiment.Based on the embodiment among the application, those of ordinary skills are not making the every other embodiment that obtains under the creative work prerequisite, all should belong to the scope of the application's protection.
Embodiment one
Referring to Fig. 1, the figure shows the process flow diagram based on the disposal route of the task of shared resource.This embodiment comprises:
Step S101: receive waiting task;
Waiting task is to utilize various types of resources that computer system provides to carry out the task of corresponding operatings, this task can show as multiple concrete form, such as the task of calculation task, mounting software program, the task of writing data into memory, task of configuration network etc.Because total resources is relatively deficient with respect to the task total amount, therefore, a plurality of waiting tasks need to be shared (sharing) one or more resources.That is to say that individual task may need to call the processing of finishing the work of a plurality of resources, a plurality of tasks also may all need be called the processing of finishing the work of identical resource.The waiting task of present embodiment is the task based on shared resource, and this task may need a resource, also may need a plurality of resources.The waiting task of the disposable reception of present embodiment can be one, also can be a plurality of.
Step S102: according to the task queue that the sign of the resource of waiting task needs is put into multiclass classification combination set of queues respective resources node with waiting task, the task queue in the described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
For satisfying various application needs, after producing waiting task and producing, namely need to call relevant resource and finish this task.The corresponding task queue that present embodiment is put into multiclass classification combination set of queues and the corresponding resource node of this resource identification according to the resource identification of the resource of processing task needs with this task is so that subsequent step is processed.Here " sign of resource " can be presented as resource ID, can be presented as that also other have the sign of distinguishing different resource.What deserves to be explained is: resource ID is on the different stage of resource tree, the concrete resource form of its sensing may there are differences, such as, when resource (node) tree had both comprised the abstract resource that is positioned at the upper strata, when also comprising the actual resource that is positioned at the end (descending) layer, described resource ID may for a resource class (also comprising other resource subclass of a plurality of more next stage or concrete resource under this resource class) on upper strata, also may be an actual resource of lower floor.For example, suppose according to the resource tree that the resource relationship between superior and subordinate is determined to be: the Root Resource node is " data center ", next rank resource node of this Root Resource node is " resource pool ", be " server " under " resource pool " resource node, in this resource tree, if the resource node that waiting task is determined according to the resource ID of its needs is " data center ", then this resource node is actually a resource class, comprised a plurality of " resource pool " resource under it, if the resource node that waiting task is determined according to the resource ID of its needs is " server ", then this resource node is a concrete actual resource.
Here " multiclass classification combination set of queues " comprises a plurality of task queues, each task queue is corresponding with the resource node that a resource node of determining according to the resource relationship between superior and subordinate is set, that is to say, there are mapping relations in task queue in the multiclass classification combination set of queues and the resource node on the resource node tree, thereby so that the task queue in the multiclass classification combination set of queues has also had " resource relationship between superior and subordinate ", each pending task has had hierarchical relationship and restricting relation in the task queue.In actual application, Root Resource node on the corresponding resource node tree of super objective formation in the multiclass classification combination set of queues, the task in this task queue can be monopolized system resource, also can carry out with subordinate's resource concurrence, when exclusive resource, the task on the child node will wait pending.
Step S103: judge whether to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfy pre-conditioned waiting task, if exist, execution in step S104 then.
After waiting task put into corresponding task queue according to resource identification, can judge whether to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfy pre-conditioned waiting task." pre-conditioned " can carry out according to different application needs difference setting: such as, when needs consider that waiting task enters the task queue time order and function, can be with the task the earliest of timestamp in the task queue as satisfying pre-conditioned waiting task; Also such as, when needs are considered the priority level of waiting task, task that can the task queue medium priority is the highest is as satisfying pre-conditioned waiting task, also such as, when needs are considered concerning between waiting task and his father's task, can be with the task without any father's task, perhaps comprise father's task but task that this father's task has been finished as satisfying pre-conditioned task.After judging the task of having determined to satisfy condition, can change the processing that the task treatment step carries out this task over to.
Need to prove: when the waiting task of each reception was one, this step can be carried out once in aforementioned S102 step and carry out afterwards; When the waiting task of each reception when being a plurality of, this step can whenever execute once in aforementioned S102 step and namely carry out afterwards, also can just execution after aforementioned S102 step all be put into a plurality of waiting tasks multiclass classification combination formation.
Step S104: taking-up is satisfied pre-conditioned waiting task and is processed;
After from the task queue of multiclass classification combination set of queues, selecting the waiting task that to carry out immediately, can carry out the processing of task.In actual application, processing threads can be concentrated on thread pool, after determining the task of needing to carry out, from thread pool, take out an idle thread, utilize this idle thread to execute the task, if the current thread that does not have the free time in the thread pool is then waited for this task of idle thread aftertreatment occurring.The processing threads here is executable application program.
Present embodiment is put into the waiting task that receives among the task queue of the corresponding resource node of multiclass classification combination formation according to the sign of the resource of its needs, then judge whether to exist in task queue corresponding to each resource node and satisfy pre-conditioned waiting task, if exist, then take out the waiting task that satisfies condition and process.Compared with prior art, because each task queue of the multiclass classification of the embodiment of the present application combination set of queues has corresponding relation with the resource node tree that makes up according to the resource relationship between superior and subordinate, make task queue have level and restricting relation as resource node tree, thereby when processing waiting task, need not take mutual exclusion lock mechanism, satisfy pre-conditioned waiting task as long as judge to have in the task queue, can take out this task and process.Present embodiment has been abandoned traditional mutual exclusion lock mechanism, and the series of problems of having avoided mutual exclusion lock mechanism to bring has improved the treatment effeciency based on the task of shared resource, has improved the task throughput of system.
Embodiment two
Previous embodiment is mentioned searching in multiclass classification combination set of queues and is satisfied pre-conditioned waiting task, although the embodiment of the present application need not to limit the mode of searching multiclass classification combination set of queues and pre-conditioned, also can realize the application's goal of the invention.But, choose appropriate mode of patrolling and examining the task of task queue in the multiclass classification combination set of queues, and set suitable pre-conditionedly, will greatly improve the treatment effeciency of waiting task, improve the task throughput of system.Present embodiment is taked to satisfy searching of pre-conditioned task according to the hierarchical relationship of resource node tree, and pre-conditioned being set as in the mode of zone bit judged.For the technical scheme of present embodiment more clearly is described, the below is introduced the data structure of the multiclass classification combination formation of present embodiment and the setting of marker bit first, and then describes the technical characterictic of present embodiment in detail in conjunction with process flow diagram.
Referring to Fig. 3, the figure shows the structure of the multiclass classification combination set of queues of present embodiment.Entity_id is the pointer of resource node among the figure, a resource node Object on the corresponding resource node tree of this pointer, the corresponding task queue of resource node Object.In order to accelerate in multiclass classification combination formation, to find resource node corresponding to resource that waiting task needs, can realize above-mentioned pointer structure by the HASH table.After receiving a waiting task, resource identification according to the resource of waiting task needs is searched resource node Object corresponding to entity_id in multiclass classification combination formation, the task queue that this resource node Object is corresponding namely is the task queue that waiting task should be put into.
Referring to Fig. 4, this illustrates the mark corresponding to resource node of present embodiment.Listed a plurality of marker bits among the figure: whether the current task marker bit of finishing dealing with is used for the previous waiting task of task queue corresponding to identifying resource node and finishes dealing with; Priority balance factor marker bit, for the weights of markup resources node, this value participates in calculating when task is processed, and generates the task processing priority; Carry out immediately marker bit, certain task that is used for the mark task queue can not need or wait for that its father node task finishes dealing with, generally speaking, when the resource non shared resources of waiting task demand or its discord father node resource contention, waiting task can concurrently be carried out, thereby improves the tasks carrying concurrency of system; The current task of the child node of the current resource node mark of finishing dealing with, whether the current task of child node that is used for the current resource node at mark waiting task place finishes dealing with, this zone bit mainly is applicable to need child node to discharge some resources when father node is carried out some task, reaches the exclusive reference purpose; Resource is abdicated marker bit, and the tasks carrying that is used for sign parent resource node need to use the resource of this node, and this node is abdicated resource for the parent resource node.What need to some be described is: according to the practical application needs, more zone bit can also be set, be used for the situation of mark aspect, satisfy pre-conditioned waiting task conveniently to judge whether to exist in the task queue; Arranging in the situation of zone bit, the value that " pre-conditioned " can be set to the zone bit position is "True" (available 1 expression is true, and 0 expression is false), if be " vacation " by the value of judgement symbol position, then think do not satisfy pre-conditioned; Arranging in the situation of zone bit, after satisfying pre-conditioned waiting task and being disposed, needing the label information of updating mark position, to satisfy the accuracy of information; Aforementioned a plurality of zone bit can be combined to a tag field, also can bring into play independently of one another the mark effect take " position " as unit; Aforementioned zone bit can one the corresponding tag field of task queue, also can be the tag field of each task configuration in the task queue.
Introduce the technical scheme of present embodiment below in conjunction with accompanying drawing.Referring to Fig. 2, the figure shows the flow process based on the disposal route of the task of shared resource of the embodiment of the present application two.This flow process comprises:
Step S201: receive waiting task;
Step S202: according to the task queue that the sign of the resource of waiting task needs is put into the corresponding resource node of multiclass classification combination set of queues with waiting task, the task queue in the described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of setting up according to the resource relationship between superior and subordinate;
Step S203: the label information that reads the waiting task of task queue corresponding to resource node;
Step S204: it is pre-conditioned whether the label information of judging the waiting task of task queue corresponding with other resource node of first grade in the multiclass classification combination set of queues satisfies, if so, and execution in step S206 then; If not, execution in step S205 then;
It is that to abdicate marker bit be "True" for the current task of the child node of " vacation " and/or the current resource node marker bit of finishing dealing with for "True", resource that herein pre-conditioned can be set to the current task marker bit of finishing dealing with, satisfy above-mentioned default condition if satisfy these marker bits, think that then waiting task corresponding to these marker bits is the waiting tasks that need to process immediately.Similarly, pre-conditionedly can also have other multiple set-up modes, such as, set current task finish marker bit be "True" and immediately the marks for treatment position also be "True".
Step S205: it is pre-conditioned whether the label information of judging the waiting task of the task queue corresponding with other resource node of other next stage of first grade satisfies, if so, and execution in step S206 then; If not, then return step S204;
Step S206: the taking-up flag information satisfies pre-conditioned waiting task to be processed;
Step S207: update mark information after flag information satisfies pre-conditioned waiting task and finishes dealing with.
Present embodiment adopts step by step inspection mode from from the even higher level of node of resource node to the next stage node to the waiting task of task queue in the multiclass classification combination formation, take full advantage of level and restricting relation that the resource node tree is set up for task queue, made things convenient for to search whether to exist in the multiclass classification combination formation and satisfied pre-conditioned waiting task, and then further improved the treatment effeciency of waiting task.And the label information of present embodiment by the judgement symbol position judges whether to satisfy pre-conditioned, simplified deterministic process, also is conducive to improve find the efficient that needs waiting task to be processed.
Need to prove: the step S202 in the present embodiment, S203, S204, S205 can be according to the needs of actual conditions in actual application, carry out one or many, that is: for step S202, when the waiting task of disposable reception has when a plurality of, after a waiting task being put into the task queue of multiclass classification combination set of queues, can be not execution in step S203 immediately, but continue to carry out the operation of waiting task being put into task queue, until the waiting task that receives is all put in the multiclass classification combination set of queues, then just carry out the step of the label information that reads task queue; For step S203, can only read the label information of the task queue of having put into recently waiting task (task), also can read comprise the task queue of having put into recently waiting task the associated task formation (such as, the superior and the subordinate's task queue of this task queue) label information, even label information corresponding to whole task queues (interior task) in the whole multiclass classification combination set of queues; For step S204, S205, in judging other task queue of some levels, exist and satisfy pre-conditioned waiting task, can carry out immediately the waiting task that satisfies condition, also can continue to judge other the level other task queues (such as, this other task queue of other next stage of level), carry out in the lump after finding out a plurality of waiting tasks that satisfy condition, and, preferably, can begin to search from task queue corresponding to root node of resource node tree and satisfy pre-conditioned waiting task, until task queue corresponding to bottom node of resource node tree, these that then will find out have the task of hierarchical relationship to be carried out in the lump.
Also need to prove: present embodiment is before putting into the waiting task that receives multiclass classification combination set of queues, candidate's task queue can also be set, be used for depositing the waiting task of reception, then from candidate's task queue, read the operation that waiting task is put into the multiclass classification set of queues according to certain rule, the time order of magnitude that this mode is suitable for receiving the time order of magnitude of waiting task and search corresponding task formation in the multiclass classification set of queues differs larger situation, such as, the waiting task quantity of disposable reception is more, and the huge structure of multiclass classification set of queues consequently can not in time be put into these tasks task queue, candidate's task queue is set under this situation can plays buffer action, it is excessive or lose to be unlikely to the generation task, thus balance " reception " (outside native system, receiving waiting task) and " writing " (putting into the waiting task of reception to the task queue of multiclass classification set of queues) speed.In addition, the task queue that candidate's task queue can also be applicable to the multiclass classification set of queues is set does not consider the situations such as time order and function or priority level, such as, the zone bit of the task queue of multiclass classification set of queues only is the situation of whether finishing dealing with about the current task of the child node of current resource node, then can in candidate queue, be pressed into waiting task according to timestamp (or priority of waiting task), thereby take out the operation that waiting task is put into the multiclass classification set of queues according to time sequencing (priority of waiting task), candidate's task queue is set under this situation can plays the effect that cooperates the processing that realizes waiting task with the multiclass classification set of queues.
Embodiment three
Above-mentioned narrating content all is the descriptions to the application's embodiment of the method, and correspondingly, the embodiment of the present application also provides the treating apparatus based on the task of shared resource.Referring to Fig. 5, the figure shows the structural framing for the treatment of apparatus of task of the shared resource of the embodiment of the present application three.This device embodiment 500 comprises: receiving element 501, first is put into unit 502, judging unit 503 and processing unit 504, wherein:
Receiving element 501 is used for receiving waiting task;
First puts into unit 502, be used for the task queue of waiting task being put into multiclass classification combination set of queues respective resources node according to the sign of the resource of waiting task needs, the task queue in the described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
Whether judging unit 503 is used for judging existing in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfies pre-conditioned waiting task, if existence then triggers processing unit;
Processing unit 504 satisfies pre-conditioned waiting task for taking-up and processes.
The course of work of present embodiment is: receiving element 501 is put into the task queue that waiting task is put into according to the sign of the resource of waiting task needs the corresponding resource node of multiclass classification combination set of queues in unit 502 by first after receiving waiting task; Then, whether judging unit 503 is judged to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and is satisfied pre-conditioned waiting task, if exist, then trigger processing unit, satisfy pre-conditioned waiting task by processing unit 504 taking-ups and process.
This device embodiment puts into the waiting task that receives among the task queue of the corresponding resource node of multiclass classification combination formation according to the sign of the resource of its needs, then judge whether to exist in task queue corresponding to each resource node and satisfy pre-conditioned waiting task, if exist, then take out the waiting task that satisfies condition and process.Compared with prior art, because each task queue of the multiclass classification of this device embodiment combination set of queues has corresponding relation with the resource node tree that makes up according to the resource relationship between superior and subordinate, make task queue have level and restricting relation as resource node tree, thereby when processing waiting task, need not take mutual exclusion lock mechanism, satisfy pre-conditioned waiting task as long as judge to have in the task queue, can take out this task and process.This device embodiment has abandoned traditional mutual exclusion lock mechanism, and the series of problems of having avoided mutual exclusion lock mechanism to bring has improved the treatment effeciency based on the task of shared resource, has improved the task throughput of system.
Judging unit among this device embodiment can be taked multiple concrete judgment mode to judge whether the task queue of multiclass classification combination set of queues has to satisfy pre-conditioned waiting task, the composition structure that different judgment modes is corresponding different.Such as the task queue that can select randomly to judge, also can satisfy the task queue that certain rules selection is judged.This device embodiment preferred " from top to bottom " and the mode of searching step by step (being the judgment mode of depth-first), under this judgment mode, the judging unit of this device embodiment can comprise the first judgment sub-unit 5031 and the second judgment sub-unit 5032, the first judgment sub-unit 5031 satisfies pre-conditioned waiting task for judging whether to exist in task queue corresponding to other resource node of multiclass classification combination set of queues and first grade, if exist, then trigger processing unit; If there is no, then trigger the second judgment sub-unit 5032; The second judgment sub-unit 5032, but be used for judging in the task queue corresponding with other resource node of other next stage of first grade whether have Processing tasks, if so, then trigger processing unit.
This device embodiment is taking in the aforesaid judgment mode situation, can further include indexing unit and updating block, wherein: indexing unit is used for each tasks carrying situation in task queue corresponding to markup resources node, updating block is used for update mark information after but Processing tasks is finished dealing with, then: described judging unit also comprises and reads subelement, be used for reading the label information of task in task queue corresponding to resource node, described the first judgment sub-unit and/or the second judgment sub-unit satisfy pre-conditioned waiting task for judging whether to exist in task queue corresponding to resource node according to the label information that reads.
This device embodiment can also comprise that second puts into the unit except above various improvement, be used for after receiving waiting task the waiting task that receives being put into candidate's task queue; Then described first put into the unit, be used for reading waiting task candidate's task queue from candidate's task queue according to preset rules the task queue of this waiting task being put into the corresponding resource node of multiclass classification combination set of queues according to the sign of the resource of the waiting task needs that from candidate's task queue, read.This structure setting can have the effect of two aspects at least: the one, when the time order of magnitude that receives waiting task differs larger with the time order of magnitude of searching corresponding task formation in the multiclass classification set of queues, play buffer action, it is excessive or lose to be unlikely to the generation task, thus balance " reception " (outside native system, receiving waiting task) and " writing " (putting into the waiting task of reception to the task queue of multiclass classification set of queues) speed; The 2nd, when the situations such as time order and function or priority level are not considered in the task queue of multiclass classification set of queues, can play the effect that cooperates the processing that realizes waiting task with the multiclass classification set of queues.
For the convenience of describing, be divided into various unit with function when describing above device and describe respectively.Certainly, when implementing the application, can in same or a plurality of softwares and/or hardware, realize the function of each unit.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the application and can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that the application's technical scheme contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, such as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the application or embodiment.
Each embodiment in this instructions adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses is difference with other embodiment.Especially, for system embodiment, because its basic simlarity is in embodiment of the method, so describe fairly simplely, relevant part gets final product referring to the part explanation of embodiment of the method.System embodiment described above only is schematic, wherein said unit as the separating component explanation can or can not be physically to separate also, the parts that show as the unit can be or can not be physical locations also, namely can be positioned at a place, perhaps also can be distributed on a plurality of network element.Can select according to the actual needs wherein some or all of module to realize the purpose of present embodiment scheme.Those of ordinary skills namely can understand and implement in the situation of not paying creative work.
The application can be used in numerous general or special purpose computingasystem environment or the configuration.For example: personal computer, server computer, handheld device or portable set, plate equipment, multicomputer system, the system based on microprocessor, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, comprise distributed computing environment of above any system or equipment etc.
The application can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises the routine carrying out particular task or realize particular abstract data type, program, object, assembly, data structure etc.Also can in distributed computing environment, put into practice the application, in these distributed computing environment, be executed the task by the teleprocessing equipment that is connected by communication network.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.
The above only is the application's embodiment; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the application's principle; can also make some improvements and modifications, these improvements and modifications also should be considered as the application's protection domain.

Claims (10)

1. the disposal route based on the task of shared resource is characterized in that, described method comprises:
Receive waiting task;
According to the task queue that the sign of the resource of waiting task needs is put into multiclass classification combination set of queues respective resources node with waiting task, the task queue of described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
Judge whether to exist in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfy pre-conditioned waiting task, if exist, then take out and satisfy pre-conditioned waiting task and process.
2. whether method according to claim 1 is characterized in that, exist in task queue corresponding to described each resource node of judging multiclass classification combination set of queues to satisfy pre-conditioned waiting task and specifically comprise:
Judge whether to exist in the task queue corresponding with other resource node of first grade in the multiclass classification combination set of queues and satisfy pre-conditioned waiting task, if exist, then take out and satisfy pre-conditioned waiting task and process; If there is no, judge then whether to exist in the task queue corresponding with other resource node of other next stage of first grade and satisfy pre-conditioned waiting task that if so, then taking-up is satisfied pre-conditioned waiting task and processed.
3. method according to claim 2, it is characterized in that, described method also comprises: set up to be used for the mark of each tasks carrying situation in task queue corresponding to reflection resource node, then: judge that multiclass classification makes up whether to exist in task queue corresponding to each resource node of set of queues and satisfy pre-conditioned waiting task and specifically comprise:
Read the label information of the task in task queue corresponding to resource node;
Judge whether to exist in task queue corresponding to resource node according to the label information that reads and satisfy pre-conditioned waiting task; Update mark information after satisfying pre-conditioned waiting task and finishing dealing with.
4. method according to claim 3 is characterized in that, described mark comprises that current task the finish dealing with mark, resource of the current task of child node of mark, current resource node of finishing dealing with abdicate mark and/or marks for treatment immediately.
5. any one described method in 4 according to claim 1 is characterized in that, after receiving waiting task, the waiting task that receives is put into candidate's task queue, reads waiting task in candidate's task queue according to preset rules; Then the task queue that waiting task is put into multiclass classification combination set of queues respective resources node of the sign of described resource according to the waiting task needs is specially:
This waiting task is put into the task queue of multiclass classification combination set of queues respective resources node according to the sign of the resource of the waiting task needs that from candidate's task queue, read.
6. any one described method in 4 according to claim 1 is characterized in that, described taking-up is satisfied pre-conditioned waiting task and processed specifically and comprise:
From thread pool, take out idle thread;
Utilize this idle thread to carry out the waiting task that takes out.
7. the treating apparatus based on the task of shared resource is characterized in that, this device comprises: receiving element, first is put into unit, judging unit and processing unit, wherein:
Described receiving element is used for receiving waiting task;
Described first puts into the unit, be used for the task queue of waiting task being put into multiclass classification combination set of queues respective resources node according to the sign of the resource of waiting task needs, the task queue of described multiclass classification combination set of queues has corresponding relation with the resource node of the resource node tree of determining according to the resource relationship between superior and subordinate;
Whether described judging unit is used for judging existing in task queue corresponding to each resource node of multiclass classification combination set of queues and satisfies pre-conditioned waiting task, if existence then triggers processing unit;
Described processing unit satisfies pre-conditioned waiting task for taking-up and processes.
8. device according to claim 7 is characterized in that, described judging unit comprises: the first judgment sub-unit and the second judgment sub-unit, wherein:
Whether described the first judgment sub-unit is used for judging existing in task queue corresponding to other resource node of multiclass classification combination set of queues and first grade and satisfies pre-conditioned waiting task, if exist, then triggers processing unit; If there is no, then trigger the second judgment sub-unit;
Whether described the second judgment sub-unit is used for judging existing in the task queue corresponding with other resource node of other next stage of first grade and satisfies pre-conditioned waiting task, if so, then triggers processing unit.
9. device according to claim 8, it is characterized in that, this device also comprises: indexing unit and updating block, wherein: described indexing unit, the implementation status that is used for each task in task queue corresponding to markup resources node, described updating block, be used for update mark information after satisfying pre-conditioned waiting task and finishing dealing with, then: described judging unit also comprises and reads subelement, be used for reading the label information of the task in task queue corresponding to resource node, described the first judgment sub-unit and/or the second judgment sub-unit satisfy pre-conditioned waiting task for judging whether to exist in task queue corresponding to resource node according to the label information that reads.
10. any one described device in 9 according to claim 7, it is characterized in that described device also comprises: second puts into the unit, is used for after receiving waiting task the waiting task that receives being put into candidate's task queue; Then described first put into the unit, be used for reading waiting task candidate's task queue from candidate's task queue according to preset rules the task queue of this waiting task being put into multiclass classification combination set of queues respective resources node according to the sign of the resource of the waiting task needs that from candidate's task queue, read.
CN201210353329.7A 2012-09-20 2012-09-20 Task processing method and device based on shared resources Active CN102902573B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210353329.7A CN102902573B (en) 2012-09-20 2012-09-20 Task processing method and device based on shared resources

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210353329.7A CN102902573B (en) 2012-09-20 2012-09-20 Task processing method and device based on shared resources

Publications (2)

Publication Number Publication Date
CN102902573A true CN102902573A (en) 2013-01-30
CN102902573B CN102902573B (en) 2014-12-17

Family

ID=47574819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210353329.7A Active CN102902573B (en) 2012-09-20 2012-09-20 Task processing method and device based on shared resources

Country Status (1)

Country Link
CN (1) CN102902573B (en)

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103279385A (en) * 2013-06-01 2013-09-04 北京华胜天成科技股份有限公司 Method and system for scheduling cluster tasks in cloud computing environment
CN103473138A (en) * 2013-09-18 2013-12-25 柳州市博源环科科技有限公司 Multi-tasking queue scheduling method based on thread pool
CN103473129A (en) * 2013-09-18 2013-12-25 柳州市博源环科科技有限公司 Multi-task queue scheduling system with scalable number of threads and implementation method thereof
CN104035818A (en) * 2013-03-04 2014-09-10 腾讯科技(深圳)有限公司 Multiple-task scheduling method and device
CN106685853A (en) * 2016-11-23 2017-05-17 泰康保险集团股份有限公司 Data processing method and apparatus
WO2017166777A1 (en) * 2016-03-29 2017-10-05 华为技术有限公司 Task scheduling method and device
CN107766129A (en) * 2016-08-17 2018-03-06 北京金山云网络技术有限公司 A kind of task processing method, apparatus and system
CN107967549A (en) * 2016-10-20 2018-04-27 南京途牛科技有限公司 Multipaths Task Processing Unit and method
CN108228349A (en) * 2017-12-26 2018-06-29 北京市商汤科技开发有限公司 For handling the method for task, system and storage medium
CN108667864A (en) * 2017-03-29 2018-10-16 华为技术有限公司 A kind of method and apparatus carrying out scheduling of resource
CN108829521A (en) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 Task processing method and device, computer equipment and storage medium
CN109901921A (en) * 2019-02-22 2019-06-18 北京致远互联软件股份有限公司 Task queue running time prediction method, apparatus and realization device
CN110046809A (en) * 2019-04-02 2019-07-23 中国工商银行股份有限公司 Job scheduling method and device
CN110659303A (en) * 2019-10-10 2020-01-07 北京优炫软件股份有限公司 Read-write control method and device for database nodes
CN110795222A (en) * 2019-10-25 2020-02-14 北京浪潮数据技术有限公司 Multithreading task scheduling method, device, equipment and readable medium
CN111582629A (en) * 2020-03-24 2020-08-25 青岛奥利普自动化控制系统有限公司 Resource scheduling method, device, equipment and storage medium
CN112988407A (en) * 2019-12-16 2021-06-18 浙江宇视科技有限公司 Data processing method and device, electronic equipment and computer readable storage medium
CN113282382A (en) * 2020-02-19 2021-08-20 中科寒武纪科技股份有限公司 Task processing method and device, computer equipment and storage medium
CN113448719A (en) * 2020-03-27 2021-09-28 北京沃东天骏信息技术有限公司 Distributed task processing system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030005263A1 (en) * 2001-06-28 2003-01-02 International Business Machines Corporation Shared resource queue for simultaneous multithreaded processing
CN101009642A (en) * 2006-12-31 2007-08-01 华为技术有限公司 A resource allocation method and device based on the task packet
CN102387173A (en) * 2010-09-01 2012-03-21 中国移动通信集团公司 MapReduce system and method and device for scheduling tasks thereof
US20120089735A1 (en) * 2010-10-11 2012-04-12 International Business Machines Corporation Two-Level Management of Locks on Shared Resources
CN102455934A (en) * 2010-10-25 2012-05-16 北大方正集团有限公司 Workflow scheduling method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030005263A1 (en) * 2001-06-28 2003-01-02 International Business Machines Corporation Shared resource queue for simultaneous multithreaded processing
CN101009642A (en) * 2006-12-31 2007-08-01 华为技术有限公司 A resource allocation method and device based on the task packet
CN102387173A (en) * 2010-09-01 2012-03-21 中国移动通信集团公司 MapReduce system and method and device for scheduling tasks thereof
US20120089735A1 (en) * 2010-10-11 2012-04-12 International Business Machines Corporation Two-Level Management of Locks on Shared Resources
CN102455934A (en) * 2010-10-25 2012-05-16 北大方正集团有限公司 Workflow scheduling method and device

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104035818A (en) * 2013-03-04 2014-09-10 腾讯科技(深圳)有限公司 Multiple-task scheduling method and device
CN103279385A (en) * 2013-06-01 2013-09-04 北京华胜天成科技股份有限公司 Method and system for scheduling cluster tasks in cloud computing environment
CN103473138A (en) * 2013-09-18 2013-12-25 柳州市博源环科科技有限公司 Multi-tasking queue scheduling method based on thread pool
CN103473129A (en) * 2013-09-18 2013-12-25 柳州市博源环科科技有限公司 Multi-task queue scheduling system with scalable number of threads and implementation method thereof
CN103473129B (en) * 2013-09-18 2017-01-18 深圳前海大数金融服务有限公司 Multi-task queue scheduling system with scalable number of threads and implementation method thereof
WO2017166777A1 (en) * 2016-03-29 2017-10-05 华为技术有限公司 Task scheduling method and device
US10891158B2 (en) 2016-03-29 2021-01-12 Huawei Technologies Co., Ltd. Task scheduling method and apparatus
CN107766129A (en) * 2016-08-17 2018-03-06 北京金山云网络技术有限公司 A kind of task processing method, apparatus and system
CN107766129B (en) * 2016-08-17 2021-04-16 北京金山云网络技术有限公司 Task processing method, device and system
CN107967549A (en) * 2016-10-20 2018-04-27 南京途牛科技有限公司 Multipaths Task Processing Unit and method
CN106685853A (en) * 2016-11-23 2017-05-17 泰康保险集团股份有限公司 Data processing method and apparatus
CN108667864A (en) * 2017-03-29 2018-10-16 华为技术有限公司 A kind of method and apparatus carrying out scheduling of resource
CN108667864B (en) * 2017-03-29 2020-07-28 华为技术有限公司 Method and device for scheduling resources
CN108228349A (en) * 2017-12-26 2018-06-29 北京市商汤科技开发有限公司 For handling the method for task, system and storage medium
WO2019237593A1 (en) * 2018-06-13 2019-12-19 平安科技(深圳)有限公司 Task processing method and apparatus, and computer device and storage medium
CN108829521A (en) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 Task processing method and device, computer equipment and storage medium
CN109901921A (en) * 2019-02-22 2019-06-18 北京致远互联软件股份有限公司 Task queue running time prediction method, apparatus and realization device
CN110046809B (en) * 2019-04-02 2021-11-19 中国工商银行股份有限公司 Job scheduling method and device
CN110046809A (en) * 2019-04-02 2019-07-23 中国工商银行股份有限公司 Job scheduling method and device
CN110659303A (en) * 2019-10-10 2020-01-07 北京优炫软件股份有限公司 Read-write control method and device for database nodes
CN110795222A (en) * 2019-10-25 2020-02-14 北京浪潮数据技术有限公司 Multithreading task scheduling method, device, equipment and readable medium
CN110795222B (en) * 2019-10-25 2022-03-22 北京浪潮数据技术有限公司 Multithreading task scheduling method, device, equipment and readable medium
CN112988407A (en) * 2019-12-16 2021-06-18 浙江宇视科技有限公司 Data processing method and device, electronic equipment and computer readable storage medium
CN112988407B (en) * 2019-12-16 2024-04-05 浙江宇视科技有限公司 Data processing method and device, electronic equipment and computer readable storage medium
CN113282382A (en) * 2020-02-19 2021-08-20 中科寒武纪科技股份有限公司 Task processing method and device, computer equipment and storage medium
CN113282382B (en) * 2020-02-19 2024-03-19 中科寒武纪科技股份有限公司 Task processing method, device, computer equipment and storage medium
CN111582629A (en) * 2020-03-24 2020-08-25 青岛奥利普自动化控制系统有限公司 Resource scheduling method, device, equipment and storage medium
CN111582629B (en) * 2020-03-24 2023-11-17 青岛奥利普奇智智能工业技术有限公司 Resource scheduling method, device, equipment and storage medium
CN113448719A (en) * 2020-03-27 2021-09-28 北京沃东天骏信息技术有限公司 Distributed task processing system

Also Published As

Publication number Publication date
CN102902573B (en) 2014-12-17

Similar Documents

Publication Publication Date Title
CN102902573A (en) Task processing method and device based on shared resources
Huang et al. Flexps: Flexible parallelism control in parameter server architecture
CN104980454B (en) A kind of resource data sharing method, server and system
US9563477B2 (en) Performing concurrent rehashing of a hash table for multithreaded applications
US9158832B1 (en) Method and computing device for maintaining dependencies among reference elements
CN101571810B (en) Method for implementing program, method for verifying program result, devices and system
US20160239550A1 (en) Frequent Pattern Mining
US20160335013A1 (en) Support of non-trivial scheduling policies along with topological properties
US20070143759A1 (en) Scheduling and partitioning tasks via architecture-aware feedback information
US11075991B2 (en) Partitioning data according to relative differences indicated by a cover tree
BRPI0710036A2 (en) declarative model for control and simultaneous through lightweight lines
CN103765376A (en) Graphics processor with non-blocking concurrent architecture
US9141677B2 (en) Apparatus and method for arranging query
CN112579586A (en) Data processing method, device, equipment and storage medium
KR20110086066A (en) Calculation device, system management device, calculation method, and program
US9189279B2 (en) Assignment method and multi-core processor system
CN106933857B (en) Method and device for scheduling tasks in data warehouse
JP2013225184A (en) Production simulation device, production simulation method, and production simulation program
CN106575296B (en) Dynamic N-dimensional cube for hosted analytics
CN115883550A (en) Task processing method, device, electronic equipment, storage medium and program product
Nishioka et al. Scalable task-parallel SGD on matrix factorization in multicore architectures
CN102750353A (en) Method for analyzing distributed data in key value library
Rheinländer et al. Scalable sequence similarity search and join in main memory on multi-cores
Guan et al. Semi-sparse algorithm based on multi-layer optimization for recommendation system
Melichercik Measuring concurrency of parallel algorithms

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 100086 12, 1201, 3 building, 2 South Road, Haidian District Academy of Sciences, Beijing.

Patentee after: Beijing Sohu New Media Information Technology Co., Ltd.

Address before: 100084 Beijing Haidian District Zhongguancun East Road 1 hospital 9 building Sohu cyber Building 8 floor 802 room.

Patentee before: Beijing Sohu New Media Information Technology Co., Ltd.