CN102902573B - 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
CN102902573B
CN102902573B CN201210353329.7A CN201210353329A CN102902573B CN 102902573 B CN102902573 B CN 102902573B CN 201210353329 A CN201210353329 A CN 201210353329A CN 102902573 B CN102902573 B CN 102902573B
Authority
CN
China
Prior art keywords
task
resource
queue
waiting task
waiting
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.)
Active
Application number
CN201210353329.7A
Other languages
Chinese (zh)
Other versions
CN102902573A (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

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 of the task based on shared resource and device
Technical field
The application relates to the access technique field of shared resource, particularly a kind of disposal route of the task based on shared resource and related device thereof.
Background technology
Along with the development of infotech, for meeting various application demand, needing task quantity to be processed sharply to expand, processing the resource category that uses in the process of these tasks and quantity also gets more and more.But over a period to come, the total resources processing various task is relatively limited.For guarantee task processes smoothly, resource needs to share usually, and namely multiple task uses a resource or several resource with the process of finishing the work jointly.Under resource sharing scenarios, the coordination system must be there is to coordinate various tasks taking resource, avoid occurring conflict in resource access process, thus guarantee correct execution and the process of task.
For the waiting task of shared resource, prior art normal a kind of coordination system adopted in processing procedure is incompatible lock mechanism.First obtain mutual exclusion lock corresponding to resource by the multiple task of resource that needs of this mechanism, then use resource exclusively, obtain after the task of mutual exclusion lock utilizes resource to be finished, remove mutual exclusion lock, so that other tasks fight for the task that mutual exclusion lock performs self.Although this incompatible lock mechanism ensure that " harmony " of the task based on shared resource.But, the resource type related to along with pending task and the increase of quantity, because the dissimilar conservation of resources has respective mutual exclusion lock, the task of process the type then needs multiple mutual exclusion lock, thus the operation of mutual exclusion lock is become quite complicated, extremely easily cause " deadlock ".As can be seen here, existing process reduces the task throughput of system based on the lock mechanism that the task of shared resource adopts, and have impact on the execution efficiency 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 efficiency of the task based on shared resource.
The disposal route of the task based on shared resource that the embodiment of the present application provides comprises:
Receive waiting task;
Waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of waiting task needs, and the resource node that task queue and the resource node determined according to resource relationship between superior and subordinate of described multiclass classification combination set of queues are set has corresponding relation;
Whether exist in task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task, if existed, then take out and meet pre-conditioned waiting task and process.
Preferably, whether exist in task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task and specifically comprise:
Judge whether to exist in the task queue corresponding with the resource node of first rank in multiclass classification combination set of queues to meet pre-conditioned waiting task, if existed, then take out and meet pre-conditioned waiting task and process; Whether if there is no, then judge to exist in the task queue corresponding with other resource node of next stage of first rank to meet pre-conditioned waiting task, if so, then taking-up meets pre-conditioned waiting task and processes.
Further preferably, described method also comprises: set up the mark for reflecting each tasks carrying situation in the task queue that resource node is corresponding, then: whether exist in task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task and specifically comprise:
Read the label information of the task in task queue corresponding to resource node;
Whether the label information according to reading judges to exist in the task queue that resource node is corresponding to meet pre-conditioned waiting task; Meeting the label information revising its correspondence after pre-conditioned waiting task process completes.
Further preferably, described mark comprises that current task process completes mark, the current task process of child node of Current resource node completes mark, resource abdicates mark and/or marks for treatment immediately.
Preferably, after reception waiting task, the waiting task of reception is put into candidate tasks queue, read the waiting task in candidate tasks queue according to preset rules; The task queue that then waiting task is put into the corresponding resource node of multiclass classification combination set of queues by the described mark of resource needed according to waiting task is specially:
This waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of the waiting task needs read from candidate tasks.
Preferably, described taking-up meets pre-conditioned waiting task and carries out processing specifically comprising:
Idle thread is taken out from thread pool;
This idle thread is utilized to perform the waiting task taken out.
The embodiment of the present application additionally provides a kind for the treatment of apparatus of the task based on shared resource.This device comprises: receiving element, first puts into unit, judging unit and processing unit, wherein:
Described receiving element, for receiving waiting task;
Described first puts into unit, waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark for the resource needed according to waiting task, and the resource node that task queue and the resource node determined according to resource relationship between superior and subordinate of described multiclass classification combination set of queues are set has corresponding relation;
Described judging unit, meets pre-conditioned waiting task, if existed, then trigger processing unit for judging whether to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding;
Described processing unit, meets pre-conditioned waiting task process for taking out.
Preferably, described judging unit comprises: the first judgment sub-unit and the second judgment sub-unit, wherein:
Described first judgment sub-unit, meets pre-conditioned waiting task, if existed, then trigger processing unit for judging whether to exist in task queue corresponding with the resource node of first rank in multiclass classification combination set of queues; If there is no, then the second judgment sub-unit is triggered;
Described second judgment sub-unit, meets pre-conditioned waiting task for judging whether to exist in the task queue corresponding with other resource node of the next stage of first rank, if so, then and trigger processing unit.
Further preferably, described device also comprises: indexing unit and updating block, wherein: described indexing unit, for tasks carrying situation each in the task queue that markup resources node is corresponding, described updating block, for meet pre-conditioned waiting task process complete after update mark information, then: described judging unit also comprises reading subelement, for reading the label information of the task in task queue corresponding to resource node, described first judgment sub-unit and/or the second judgment sub-unit, for judging whether to exist in the task queue that resource node is corresponding to meet pre-conditioned waiting task according to the label information read.
Preferably, described device also comprises: second puts into unit, for after reception waiting task, the waiting task of reception is put into candidate tasks queue according to timestamp; Then described first put into unit, for reading the waiting task in candidate tasks queue according to preset rules from candidate tasks queue, this waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of the waiting task needs read from candidate tasks queue.
The mark of the resource that the waiting task of reception needs according to it by the embodiment of the present application is put among the task queue of the corresponding resource node of multiclass classification combination queue, then judge whether to exist in the task queue that each resource node is corresponding to meet pre-conditioned waiting task, if existed, then take out and meet pre-conditioned waiting task and process.Compared with prior art, multiclass classification combination set of queues due to the embodiment of the present application comprises sets corresponding task queue with resource node, this resource node tree determines level and the restricting relation of task queue according to resource relationship between superior and subordinate, thus need not incompatible lock mechanism be taked when processing waiting task, as long as judge that there is in task queue accessible waiting task, this task can be taken out and process.The embodiment of the present application has abandoned traditional incompatible lock mechanism, avoids the series of problems that incompatible lock mechanism brings, and improves the treatment effeciency of the task based on shared resource, improves the task throughput of system.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present application or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, the accompanying drawing that the following describes is only some embodiments recorded in the application, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the process flow figure of the task based on shared resource of the embodiment of the present application one;
Fig. 2 is the process flow figure of the task based on shared resource of the embodiment of the present application two;
The multiclass classification combination set of queues schematic diagram that Fig. 3 is embodiment described in Fig. 2;
Fig. 4 is mark schematic diagram corresponding to the resource node of embodiment described in Fig. 2;
Fig. 5 is the structured flowchart of the treating apparatus of the task based on shared resource of the embodiment of the present application three.
Embodiment
Technical scheme in the application is understood better in order to make those skilled in the art person, 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 is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all should belong to the scope of the application's protection.
Embodiment one
See Fig. 1, the figure shows the process flow diagram of the disposal route of the task based on shared resource.This embodiment comprises:
Step S101: receive waiting task;
Waiting task is the task that the various types of resources needing to utilize computer system to provide perform corresponding operating, this task can show as multiple concrete form, the task, the task of writing data into memory, the task of configuration network etc. of such as calculation task, mounting software program.Because total resources is relatively deficient relative to task total amount, therefore, multiple waiting task needs to share (sharing) one or more resource.That is, individual task may need to call multiple resource and to finish the work process, and multiple task also all may need to call identical resource and to finish the work process.The waiting task of the present embodiment is the task based on shared resource, and this task may need a resource, also may need multiple resource.The waiting task of the disposable reception of the present embodiment can be one, also can be multiple.
Step S102: waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of waiting task needs, the resource node that the task queue in described multiclass classification combination set of queues and the resource node determined according to resource relationship between superior and subordinate are set has corresponding relation;
For meeting various application needs, after producing a waiting task generation, namely need to call relevant resource to complete this task.This task is put into the corresponding task queue of the multiclass classification combination set of queues resource node corresponding to this resource identification by the resource identification of the resource that the present embodiment needs according to process task, so that subsequent step processes.Here " mark of resource " can be presented as resource ID, also can be presented as that other have the mark distinguishing different resource.What deserves to be explained is: resource ID is on the different stage of resource tree, its concrete resource form pointed to may there are differences, such as, when resource (node) tree had both comprised the abstract resource being positioned at upper strata, also comprise be positioned at the end (under) actual resource of layer time, described resource ID may be a resource class on upper strata (also comprising other resource subclass of multiple more next stage or concrete resource under this resource class), also may be an actual resource of lower floor.For example, suppose that the resource tree determined according to resource relationship between superior and subordinate is: 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 the resource ID that waiting task needs according to it is determined is " data center ", then this resource node is actually a resource class, multiple " resource pool " resource is contained under it, if the resource node that the resource ID that waiting task needs according to it is determined is " server ", then this resource node is a concrete actual resource.
Here " multiclass classification combination set of queues " comprises multiple task queue, each task queue is corresponding with the resource node that the resource node that is determined according to resource relationship between superior and subordinate is set, that is, there are mapping relations in the resource node that the task queue in multiclass classification combination set of queues and resource node are set, thus the task queue making multiclass classification combine in set of queues is also provided with " resource relationship between superior and subordinate ", in task queue, each pending task is provided with hierarchical relationship and restricting relation.In actual application, Root Resource node on the corresponding resource node tree of super objective queue in multiclass classification combination set of queues, the task in this task queue can monopolize system resource, also can perform with subordinate's resource concurrence, when exclusive resource, the task in child node will wait pending.
Step S103: judge whether to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding to meet pre-conditioned waiting task, if existed, then perform step S104.
After waiting task is put into corresponding task queue according to resource identification, can judge whether to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding to meet pre-conditioned waiting task." pre-conditioned " can need to carry out difference according to different application and arrange: such as, when needs consider that waiting task enters task queue time order and function, can using the task the earliest of timestamp in task queue as meeting pre-conditioned waiting task; Also such as, when needing the priority level considering waiting task, can using task the highest for task queue medium priority as meeting pre-conditioned waiting task, also such as, when needing to consider the relation between waiting task and his father's task, can by the task without any father's task, or comprise father's task but this father's task task of being finished as meeting pre-conditioned task.After judging to determine satisfying condition of task, the process that task treatment step carries out this task can be proceeded to.
It should be noted that: when each waiting task received is one, this step can perform in aforementioned S102 step and once perform afterwards; When each waiting task received is multiple, this step often can execute in aforementioned S102 step and once namely perform afterwards, also just can perform after multiple waiting task is all put into multiclass classification combination queue by aforementioned S102 step.
Step S104: taking-up meets pre-conditioned waiting task and processes;
Select the waiting task needing to perform immediately from the task queue of multiclass classification combination set of queues after, the process of task can be carried out.In actual application, processing threads can be concentrated on thread pool, after determining the task of needing to perform, an idle thread is taken out from thread pool, this idle thread is utilized to execute the task, idle thread is there is not, then this task of idle thread aftertreatment to appear such as if current in thread pool.Here processing threads is executable application program.
The mark of the resource that the waiting task of reception needs according to it by the present embodiment is put among the task queue of the corresponding resource node of multiclass classification combination queue, then judge whether to exist in the task queue that each resource node is corresponding to meet pre-conditioned waiting task, if existed, then take out the waiting task satisfied condition and process.Compared with prior art, because each task queue of the multiclass classification combination set of queues of the embodiment of the present application is set with the resource node built according to resource relationship between superior and subordinate, there is corresponding relation, make task queue be provided with as resource node tree level and restricting relation, thus need not incompatible lock mechanism be taked when processing waiting task, as long as judge to have in task queue and meet pre-conditioned waiting task, this task can be taken out and process.The present embodiment has abandoned traditional incompatible lock mechanism, avoids the series of problems that incompatible lock mechanism brings, and improves the treatment effeciency of the task based on shared resource, improves the task throughput of system.
Embodiment two
Previous embodiment is mentioned and is searched and meet pre-conditioned waiting task in multiclass classification combination set of queues, although the embodiment of the present application is without the need to limiting the mode of searching multiclass classification combination set of queues and pre-conditioned, also can realize the goal of the invention of the application.But, choose appropriate mode of patrolling and examining the task of task queue in multiclass classification combination set of queues, and set suitable pre-conditioned, will greatly improve the treatment effeciency of waiting task, improve the task throughput of system.The present embodiment is taked to carry out meeting searching of pre-conditioned task according to the hierarchical relationship of resource node tree, and pre-conditioned being set as judges in the mode of zone bit.For the technical scheme of the present embodiment is more clearly described, first the multiclass classification of the present embodiment combination data structure of queue and the setting of marker bit is introduced below, and then describes the technical characteristic of the present embodiment in detail in conjunction with process flow diagram.
See Fig. 3, the figure shows the structure of the multiclass classification combination set of queues of the present embodiment.In figure, entity_id is the pointer of resource node, a resource node Object on the corresponding resource node tree of this pointer, a corresponding task queue of resource node Object.In order to the resource node that the resource accelerating to find waiting task needs in multiclass classification combination queue is corresponding, realize above-mentioned pointer structure by HASH table.After receiving a waiting task, resource identification according to the resource of waiting task needs searches resource node Object corresponding to entity_id in multiclass classification combination queue, and namely the task queue that this resource node Object is corresponding is the task queue that waiting task should be put into.
See Fig. 4, this illustrates mark corresponding to the resource node of the present embodiment.List multiple marker bit in figure: current task process completes marker bit, whether processed for waiting task previous in the task queue that identifying resource node is corresponding; Priority balance factor marker bit, for the weights of markup resources node, this value participates in when task process calculating, and generates task processing priority; Execution flag position immediately, can not need or wait for that the process of his father's node tasks completes for certain task marked in task queue, generally speaking, when resource non shared resources or its discord father node resource contention of waiting task demand, waiting task can concurrence performance, thus improves the tasks carrying concurrency of system; The current task process of the child node of Current resource node completes mark, whether the current task for the child node marking the Current resource node at waiting task place has processed, this zone bit is mainly applicable to need child node to discharge some resources when father node performs some task, reaches exclusive reference object; Resource abdicates marker bit, and the tasks carrying for identifying parent resource node needs the resource using this node, and this node abdicates resource for parent resource node.Needing some is described: according to practical application needs, more zone bit can also be set, for marking the situation of certain aspect, judging whether to exist in task queue to meet pre-conditioned waiting task to facilitate; When arranging zone bit, the value that " pre-conditioned " can be set to zone bit position is "True" (available 1 represents true, and 0 represents false), if be "false" by the value of judgement symbol position, then not think meet pre-conditioned; When arranging zone bit, meeting after pre-conditioned waiting task is disposed, needing the label information upgrading zone bit, to meet the accuracy of information; Aforementioned multiple zone bit can be combined to a tag field, also can independently of one another with " position " for unit plays mark effect; Aforementioned zone bit can the corresponding tag field of task queue, also can configure a tag field for each task in task queue.
The technical scheme of the present embodiment is introduced below in conjunction with accompanying drawing.See Fig. 2, the figure shows the flow process of the disposal route of the task based on shared resource of the embodiment of the present application two.This flow process comprises:
Step S201: receive waiting task;
Step S202: waiting task is put into the task queue that multiclass classification combines the corresponding resource node of set of queues by the mark according to the resource of waiting task needs, the resource node that the task queue in described multiclass classification combination set of queues and the resource node set up according to resource relationship between superior and subordinate are set has corresponding relation;
Step S203: the label information reading the waiting task of task queue corresponding to resource node;
Step S204: judge whether the label information of the waiting task of task queue corresponding with the resource node of first rank in multiclass classification combination set of queues meets pre-conditioned, if so, then performs step S206; If not, then step S205 is performed;
Herein pre-conditioned can be set to that current task process completes that marker bit is "True", to abdicate marker bit be that to complete marker bit be "True" for the current task process of the child node of "false" and/or Current resource node to resource, if meet these marker bits to meet above-mentioned default condition, then think that waiting task corresponding to these marker bits is the waiting tasks needing to process immediately.Similarly, pre-conditioned can also exist other multiple set-up modes, such as, setting current task complete marker bit be "True" and immediately marks for treatment position also for "True".
Step S205: judge whether the label information of the waiting task of the task queue corresponding with other resource node of next stage of first rank meets pre-conditioned, if so, then performs step S206; If not, then step S204 is returned;
Step S206: taking-up flag information meets pre-conditioned waiting task and processes;
Step S207: flag information meet pre-conditioned waiting task process complete after update mark information.
The waiting task of the present embodiment to task queue in multiclass classification combination queue adopts the inspection mode step by step from the downward first nodes of the even higher level of node of resource node, take full advantage of level and restricting relation that resource node tree is task queue foundation, facilitate to search in multiclass classification combination queue whether to exist and meet pre-conditioned waiting task, and then further improve the treatment effeciency of waiting task.And the present embodiment judges whether to meet pre-conditioned by the label information of judgement symbol position, simplify deterministic process, be also conducive to improving the efficiency finding and need waiting task to be processed.
It should be noted that: the step S202 in the present embodiment, S203, S204, S205 can according to the needs of actual conditions in actual application, perform one or many, that is: for step S202, when the waiting task of disposable reception has multiple, after a waiting task being put into the task queue of multiclass classification combination set of queues, step S203 can not be performed immediately, but continue to perform the operation of waiting task being put into task queue, until the waiting task of reception is all put in multiclass classification combination set of queues, then the step of the label information reading task queue is just performed, for step S203, only can read the label information of the task queue (task) of having put into waiting task recently, also can read comprise the task queue of having put into waiting task recently associated task queue (such as, the superior and the subordinate's task queue of this task queue) label information, the label information that in even whole multiclass classification combination set of queues, all task queue (interior task) is corresponding, for step S204, S205, exist in the task queue judging some ranks and meet pre-conditioned waiting task, the waiting task satisfied condition can be performed immediately, also can continue to judge the task queue of other ranks (such as, other task queue of the next stage of this rank), perform in the lump after finding out multiple waiting task satisfied condition, and, preferably, can start to search from the task queue that the root node of resource node tree is corresponding and meet pre-conditioned waiting task, until the task queue that the bottom node of resource node tree is corresponding, the task then these finding out with hierarchical relationship performs in the lump.
Also it should be noted that: the present embodiment is before putting into multiclass classification combination set of queues by the waiting task received, candidate tasks queue can also be set, for depositing the waiting task of reception, then from candidate tasks queue, read according to certain rule the operation that waiting task carries out putting into multiclass classification set of queues, the time order of magnitude that this mode is suitable for receiving waiting task differs larger situation with the time order of magnitude searching corresponding task queue in multiclass classification set of queues, such as, the waiting task quantity of disposable reception is more, and these tasks consequently can not be put into task queue by the huge structure of multiclass classification set of queues in time, a candidate tasks queue is set under this situation and can plays buffer action, be unlikely to generation task excessive or lose, thus balance " reception " (receiving waiting task from native system) and " write " (waiting task of reception is put in the task queue to multiclass classification set of queues) speed.In addition, the task queue that candidate tasks queue can also be applicable to multiclass classification set of queues is set and does not consider the situation such as time order and function or priority level, such as, the zone bit of the task queue of multiclass classification set of queues is only situation about whether completing about the current task process of the child node of Current resource node, then in candidate queue, waiting task can be pressed into according to timestamp (or priority of waiting task), thus take out according to time sequencing (priority of waiting task) operation that waiting task carries out putting into multiclass classification set of queues, a candidate tasks queue is set under this situation and can plays the effect coordinating the process realizing waiting task with multiclass classification set of queues.
Embodiment three
Above-mentioned narrating content is all the descriptions to the application's embodiment of the method, and correspondingly, the embodiment of the present application additionally provides the treating apparatus of the task based on shared resource.See Fig. 5, the figure shows the structural framing of the treating apparatus of the task of the shared resource of the embodiment of the present application three.This device embodiment 500 comprises: receiving element 501, first puts into unit 502, judging unit 503 and processing unit 504, wherein:
Receiving element 501, for receiving waiting task;
First puts into unit 502, waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark for the resource needed according to waiting task, and the resource node that the task queue in described multiclass classification combination set of queues and the resource node determined according to resource relationship between superior and subordinate are set has corresponding relation;
Judging unit 503, meets pre-conditioned waiting task, if existed, then trigger processing unit for judging whether to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding;
Processing unit 504, meets pre-conditioned waiting task process for taking out.
The course of work of the present embodiment is: receiving element 501 is after reception waiting task, and waiting task is put into the task queue that multiclass classification combines the corresponding resource node of set of queues by the mark putting into the resource that unit 502 needs according to waiting task by first; Then, whether judging unit 503 judges to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding to meet pre-conditioned waiting task, if existed, then trigger processing unit, meet pre-conditioned waiting task by processing unit 504 taking-up and process.
The mark of the resource that the waiting task of reception needs according to it by this device embodiment is put among the task queue of the corresponding resource node of multiclass classification combination queue, then judge whether to exist in the task queue that each resource node is corresponding to meet pre-conditioned waiting task, if existed, then take out the waiting task satisfied condition and process.Compared with prior art, because each task queue of the multiclass classification combination set of queues of this device embodiment is set with the resource node built according to resource relationship between superior and subordinate, there is corresponding relation, make task queue be provided with as resource node tree level and restricting relation, thus need not incompatible lock mechanism be taked when processing waiting task, as long as judge to have in task queue and meet pre-conditioned waiting task, this task can be taken out and process.This device embodiment has abandoned traditional incompatible lock mechanism, avoids the series of problems that incompatible lock mechanism brings, and improves the treatment effeciency of the task based on shared resource, improves the task throughput of system.
Judging unit in this device embodiment can take multiple concrete judgment mode to judge, and whether the task queue of multiclass classification combination set of queues has and meets pre-conditioned waiting task, the composition structure that different judgment modes is corresponding different.Such as can select the task queue judged randomly, also can meet the task queue that certain rules selection judges.This device embodiment preferably " from top to bottom " and mode of searching step by step (i.e. 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, first judgment sub-unit 5031 meets pre-conditioned waiting task for judging whether to exist in task queue corresponding with the resource node of first rank in multiclass classification combination set of queues, if existed, then trigger processing unit; If there is no, then the second judgment sub-unit 5032 is triggered; Whether the second judgment sub-unit 5032, can Processing tasks for judging to exist in the task queue corresponding with other resource node of the next stage of first rank, if so, then and trigger processing unit.
This device embodiment is being taked in 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 be used for can Processing tasks process complete after update mark information, then: described judging unit also comprises reading subelement, for reading the label information of task in task queue corresponding to resource node, described first judgment sub-unit and/or the second judgment sub-unit, for judging whether to exist in the task queue that resource node is corresponding to meet pre-conditioned waiting task according to the label information read.
This device embodiment, except above various improvement, can also comprise second and put into unit, for after reception waiting task, the waiting task of reception is put into candidate tasks queue; Then described first put into unit, for reading the waiting task in candidate tasks queue according to preset rules from candidate tasks queue, this waiting task is put into the task queue that multiclass classification combines the corresponding resource node of set of queues by the mark according to the resource of the waiting task needs read from candidate tasks queue.This vibrational power flow at least can have the effect of two aspects: one is receiving the time order of magnitude of waiting task with when the time of searching corresponding task queue in multiclass classification set of queues, the order of magnitude differed larger, play buffer action, be unlikely to generation task excessive or lose, thus balance " receptions " (receiving waiting task from native system) and " write " (waiting task of reception is put in the task queue to multiclass classification set of queues) speed; Two is task queues of multiclass classification set of queues when not considering the situation such as time order and function or priority level, can play the effect coordinating the process realizing waiting task with multiclass classification set of queues.
For convenience of description, various unit is divided into describe respectively with function when describing above device.Certainly, the function of each unit can be realized in same or multiple software and/or hardware when implementing the application.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the mode that the application can add required general hardware platform by software and realizes.Based on such understanding, the technical scheme of the application can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product can be stored in storage medium, as ROM/RAM, magnetic disc, CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform the method described in 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, between each embodiment identical similar part mutually see, what each embodiment stressed is the difference with other embodiments.Especially, for system embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.System embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying creative work, are namely appreciated that and implement.
The application can be used in numerous general or special purpose computing system environment or configuration.Such as: personal computer, server computer, handheld device or portable set, laptop device, multicomputer system, system, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, the distributed computing environment comprising above any system or equipment etc. based on microprocessor.
The application can describe in the general context of computer executable instructions, such as program module.Usually, program module comprises the routine, program, object, assembly, data structure etc. that perform particular task or realize particular abstract data type.Also can put into practice the application in a distributed computing environment, in these distributed computing environment, be executed the task by the remote processing devices be connected by communication network.In a distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium comprising memory device.
The above is only the embodiment of the application; it should be pointed out that for those skilled in the art, under the prerequisite not departing from the application's principle; can also make some improvements and modifications, these improvements and modifications also should be considered as the protection domain of the application.

Claims (8)

1. based on a disposal route for the task of shared resource, it is characterized in that, described method comprises:
Receive waiting task;
Waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of waiting task needs, and the resource node that task queue and the resource node determined according to resource relationship between superior and subordinate of described multiclass classification combination set of queues are set has corresponding relation;
Whether exist in task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task, if existed, then take out and meet pre-conditioned waiting task and process;
Whether exist in described task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task and specifically comprise:
Judge whether to exist in the task queue corresponding with the resource node of first rank in multiclass classification combination set of queues to meet pre-conditioned waiting task, if existed, then take out and meet pre-conditioned waiting task and process; Whether if there is no, then judge to exist in the task queue corresponding with other resource node of next stage of first rank to meet pre-conditioned waiting task, if so, then taking-up meets pre-conditioned waiting task and processes.
2. method according to claim 1, it is characterized in that, described method also comprises: set up the mark for reflecting each tasks carrying situation in the task queue that resource node is corresponding, then: whether exist in task queue corresponding to each resource node judging multiclass classification combination set of queues and meet pre-conditioned waiting task and specifically comprise:
Read the label information of the task in task queue corresponding to resource node;
Whether the label information according to reading judges to exist in the task queue that resource node is corresponding to meet pre-conditioned waiting task; Meet pre-conditioned waiting task process complete after update mark information.
3. method according to claim 2, is characterized in that, described mark comprises that current task process completes mark, the current task process of child node of Current resource node completes mark, resource abdicates mark and/or marks for treatment immediately.
4. according to the method in claims 1 to 3 described in any one, it is characterized in that, after reception waiting task, the waiting task of reception is put into candidate tasks queue, read the waiting task in candidate tasks queue according to preset rules; The task queue that then waiting task is put into multiclass classification combination set of queues respective resources node by the described mark of resource needed according to waiting task is specially:
This waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of the waiting task needs read from candidate tasks queue.
5. according to the method in claims 1 to 3 described in any one, it is characterized in that, described taking-up meets pre-conditioned waiting task and carries out processing specifically comprising:
Idle thread is taken out from thread pool;
This idle thread is utilized to perform the waiting task taken out.
6. based on a treating apparatus for the task of shared resource, it is characterized in that, this device comprises: receiving element, first puts into unit, judging unit and processing unit, wherein:
Described receiving element, for receiving waiting task;
Described first puts into unit, waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark for the resource needed according to waiting task, and the resource node that task queue and the resource node determined according to resource relationship between superior and subordinate of described multiclass classification combination set of queues are set has corresponding relation;
Described judging unit, meets pre-conditioned waiting task, if existed, then trigger processing unit for judging whether to exist in the task queue that each resource node of multiclass classification combination set of queues is corresponding;
Described processing unit, meets pre-conditioned waiting task process for taking out;
Described judging unit comprises: the first judgment sub-unit and the second judgment sub-unit, wherein:
Described first judgment sub-unit, meets pre-conditioned waiting task, if existed, then trigger processing unit for judging whether to exist in task queue corresponding with the resource node of first rank in multiclass classification combination set of queues; If there is no, then the second judgment sub-unit is triggered;
Described second judgment sub-unit, meets pre-conditioned waiting task for judging whether to exist in the task queue corresponding with other resource node of the next stage of first rank, if so, then and trigger processing unit.
7. device according to claim 6, it is characterized in that, this device also comprises: indexing unit and updating block, wherein: described indexing unit, for the implementation status of task each in the task queue that markup resources node is corresponding, described updating block, for meet pre-conditioned waiting task process complete after update mark information, then: described judging unit also comprises reading subelement, for reading the label information of the task in task queue corresponding to resource node, described first judgment sub-unit and/or the second judgment sub-unit, for judging whether to exist in the task queue that resource node is corresponding to meet pre-conditioned waiting task according to the label information read.
8. according to the device in claim 6 to 7 described in any one, it is characterized in that, described device also comprises: second puts into unit, for after reception waiting task, the waiting task of reception is put into candidate tasks queue; Then described first put into unit, for reading the waiting task in candidate tasks queue according to preset rules from candidate tasks queue, this waiting task is put into the task queue that multiclass classification combines set of queues respective resources node by the mark according to the resource of the waiting task needs read from candidate tasks queue.
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 CN102902573A (en) 2013-01-30
CN102902573B true 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)

Families Citing this family (19)

* 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
CN103473129B (en) * 2013-09-18 2017-01-18 深圳前海大数金融服务有限公司 Multi-task queue scheduling system with scalable number of threads and implementation method thereof
CN105893126B (en) 2016-03-29 2019-06-11 华为技术有限公司 A kind of method for scheduling task and device
CN107766129B (en) * 2016-08-17 2021-04-16 北京金山云网络技术有限公司 Task processing method, device and system
CN107967549B (en) * 2016-10-20 2022-02-01 南京途牛科技有限公司 Multi-process task processing device and method
CN106685853B (en) * 2016-11-23 2020-05-12 泰康保险集团股份有限公司 Method and device for processing data
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
CN108829521B (en) * 2018-06-13 2022-05-13 平安科技(深圳)有限公司 Task processing method and device, computer equipment and storage medium
CN109901921B (en) * 2019-02-22 2022-02-11 北京致远互联软件股份有限公司 Task queue execution time prediction method and device and implementation device
CN110046809B (en) * 2019-04-02 2021-11-19 中国工商银行股份有限公司 Job scheduling method and device
CN110659303A (en) * 2019-10-10 2020-01-07 北京优炫软件股份有限公司 Read-write control method and device for database nodes
CN110795222B (en) * 2019-10-25 2022-03-22 北京浪潮数据技术有限公司 Multithreading task scheduling method, device, equipment and readable medium
CN112988407B (en) * 2019-12-16 2024-04-05 浙江宇视科技有限公司 Data processing method and device, electronic equipment and computer readable storage medium
CN113282382B (en) * 2020-02-19 2024-03-19 中科寒武纪科技股份有限公司 Task processing method, device, computer 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

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6988186B2 (en) * 2001-06-28 2006-01-17 International Business Machines Corporation Shared resource queue for simultaneous multithreading processing wherein entries allocated to different threads are capable of being interspersed among each other and a head pointer for one thread is capable of wrapping around its own tail in order to access a free entry
CN100542139C (en) * 2006-12-31 2009-09-16 华为技术有限公司 A kind of resource allocation methods and device based on the task grouping
CN102387173B (en) * 2010-09-01 2015-02-04 中国移动通信集团公司 MapReduce system and method and device for scheduling tasks thereof
US8868748B2 (en) * 2010-10-11 2014-10-21 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

Also Published As

Publication number Publication date
CN102902573A (en) 2013-01-30

Similar Documents

Publication Publication Date Title
CN102902573B (en) Task processing method and device based on shared resources
CN104980454B (en) A kind of resource data sharing method, server and system
US8561072B2 (en) Scheduling collections in a scheduler
CN103858103B (en) For resource management and the method and system of resource allocation
CN103226467A (en) Data parallel processing method and system as well as load balancing scheduler
CN101571810B (en) Method for implementing program, method for verifying program result, devices and system
US9141677B2 (en) Apparatus and method for arranging query
CN102523155B (en) Boost Graph library-based K shortest path searching method and system
KR20110086066A (en) Calculation device, system management device, calculation method, and program
CN110008030B (en) Method, system and equipment for accessing metadata
CN106933857B (en) Method and device for scheduling tasks in data warehouse
CN110266598A (en) A kind of routing information processing method, apparatus, equipment and readable storage medium storing program for executing
TWI776263B (en) Data sharing method that implements data tag to improve data sharing on multi-computing-unit platform
CN109992526A (en) A kind of read-write management method and relevant apparatus
CN105955971B (en) A kind of implementation method and device of key assignments caching
CN112346879B (en) Process management method, device, computer equipment and storage medium
CN114866460A (en) Path planning method based on artificial intelligence and related equipment
CN105659216B (en) The CACHE DIRECTORY processing method and contents controller of multi-core processor system
WO2020019315A1 (en) Computational operation scheduling method employing graphic data, system, computer readable medium, and apparatus
Ding et al. Multi-Q: multiple queries optimization based on MapReduce in cloud
CN112631783A (en) Virtual resource allocation method and device, electronic equipment and storage medium
CN107291371A (en) The implementation method and device of a kind of Read-Write Locks
CN106371805B (en) The dynamic dispatching interconnected registers of processor and the method for dispatching data
CN116187464B (en) Blind quantum computing processing method and device and electronic equipment
CN102779120A (en) Method, system and device for determining field information of station and judging correlation

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

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.

CP02 Change in the address of a patent holder