CN104679484B - A kind of concurrent analysis method and device - Google Patents

A kind of concurrent analysis method and device Download PDF

Info

Publication number
CN104679484B
CN104679484B CN201310617816.4A CN201310617816A CN104679484B CN 104679484 B CN104679484 B CN 104679484B CN 201310617816 A CN201310617816 A CN 201310617816A CN 104679484 B CN104679484 B CN 104679484B
Authority
CN
China
Prior art keywords
node
thread
concurrent
present
termination
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.)
Expired - Fee Related
Application number
CN201310617816.4A
Other languages
Chinese (zh)
Other versions
CN104679484A (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.)
Huawei Technologies Co Ltd
Institute of Computing Technology of CAS
Original Assignee
Huawei Technologies Co Ltd
Institute of Computing Technology of CAS
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 Huawei Technologies Co Ltd, Institute of Computing Technology of CAS filed Critical Huawei Technologies Co Ltd
Priority to CN201310617816.4A priority Critical patent/CN104679484B/en
Publication of CN104679484A publication Critical patent/CN104679484A/en
Application granted granted Critical
Publication of CN104679484B publication Critical patent/CN104679484B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention discloses a kind of concurrent analysis method and device, including:Obtain program control flowchart, wherein, in described program controlling stream graph, the direct precursor node of the start node for the thread that thread creation node is created by the thread creation node, the initial concurrent node set of the start node of each thread in calculation procedure controlling stream graph, the initial concurrent node set of the immediate successor node of each thread creation node, and the immediate successor node of each Thread Termination node initially can not concurrent node set, the concurrent node set of the first node of initialization program controlling stream graph, traveled through downwards since the first node of program control flowchart, in ergodic process, the concurrent node set of each node traversed is calculated according to inheritance rules, the concurrent node set of each node is obtained due to once traveling through, computing is simple and operand is small, realize the purpose for improving concurrent analysis efficiency.

Description

A kind of concurrent analysis method and device
Technical field
The present invention relates to program analysis field, more particularly to a kind of concurrent analysis method and device.
Background technology
It is analysis type common in program analysis that may concurrently analyze, and may be performed parallel in its Main Analysis program Program statement.Optimization of the program statement that may be performed parallel in program to program, detection of concurrence error etc. is analyzed to have It is significant.
At present, it may parser be concurrently the algorithm based on iterative data stream to use most commonly used.The algorithm needs Will be previously according to a set of data-flow equations of some keyword definitions in concurrent program, by the node in program control flowchart to work The form of collection preserves, wherein, a node in program control flowchart corresponds to a program statement in program.In analysis process In, node is taken out from working set one by one, is iterated in input data flow equation, calculates and is possible to the node of taking-up simultaneously The node of hair.
Foundation using data-flow equations and is only turned to so that whether the concurrent node set of node becomes due to the algorithm, iteratively The concurrent node set of each node is calculated, causes great deal of nodes to be accessed repeatedly and calculate, calculates control complexity, operand Greatly.
The content of the invention
In view of this, the main purpose of the embodiment of the present invention is that provide a kind of concurrent analysis method and device carries to realize The purpose of high concurrent analysis efficiency.
In order to solve the above technical problems, the embodiment of the present invention adopts the technical scheme that:
In a first aspect, the embodiments of the invention provide a kind of concurrent analysis method, methods described includes:
Program control flowchart is obtained, wherein, in described program controlling stream graph, thread creation node is the thread creation The direct precursor node of the start node for the thread that node is created;
The initial concurrent node set of the start node of each thread, each thread creation section in calculation procedure controlling stream graph The initial nothing of the immediate successor node of the initial concurrent node set of the immediate successor node of point and each Thread Termination node Method concurrent node set;Wherein, the initial concurrent node set of the start node of each thread includes described for creating In node after the thread creation node of thread where start node, at least one section that can be concurrent with the start node Point;Wherein, the initial concurrent node set of the immediate successor node of the thread creation node includes the thread creation node In node after the start node of the thread created, it is at least one can be with the immediate successor section of the thread creation node The concurrent node of point;Wherein, the immediate successor node of Thread Termination node initially can not concurrent node set comprise at least institute State the whole nodes for the thread that Thread Termination node is terminated;
The concurrent node set of the first node of described program controlling stream graph is initialized, from the head sections of described program controlling stream graph Point starts traversal downwards, in the ergodic process, according to following inheritance rules, calculates the concurrent of each node for traversing Node set:
Wherein, the inheritance principles include:
If the present node traversed is not the immediate successor node of Thread Termination node, the present node Concurrent node set includes the concurrent node set of at least one direct precursor node of the present node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The concurrent node set of front nodal point includes the initial concurrent node set of the present node and at least one direct precursor node Concurrent node union of sets collection;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and The concurrent node set at least one direct precursor node that hair node set is equal to the present node subtracts the present node Initially can not concurrent node set.
In the first possible implementation of first aspect, the initial of start node of each thread is concurrently saved Point set is included in the node after the thread creation node of thread where being used to create the start node, it is all can be with institute State the concurrent node of start node;
The initial concurrent node set of the immediate successor node of the thread creation node includes the thread creation node In node after the start node of the thread created, it is all can be with the immediate successor node of the thread creation node simultaneously The node of hair;
If the present node traversed is not the immediate successor node of Thread Termination node, the present node Concurrent node set includes the concurrent node union of sets collection of all direct precursor nodes of the present node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The initial concurrent node set of the concurrent node set of front nodal point including the present node and all direct precursor nodes and Send out the union of node set;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and The concurrent node union of sets collection for all direct precursor nodes that hair node set includes the present node subtracts the present node Initially can not concurrent node set.
It is described each in second of possible implementation with reference to the first possible implementation of first aspect Only include the thread wound of thread where being used to create the start node in the initial concurrent node set of the start node of thread Build in the node after node, all nodes that can be concurrent with the start node;
Only include the thread in the initial concurrent node set of the immediate successor node of each thread creation node Create in the node after the start node of thread that node is created, it is all can with the thread creation node it is direct after After the concurrent node of node;
If the present node traversed be not the immediate successor node of Thread Termination node, thread creation node it is direct The start node of descendant node and thread, then, the concurrent node set of the present node are equal to all of the present node The concurrent node union of sets collection of direct precursor node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The concurrent node set of front nodal point be equal to initial concurrent node set and the present node of the present node it is all directly The concurrent node union of sets collection of predecessor node;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and It is current that the concurrent node union of sets collection for all direct precursor nodes that hair node set is equal to the present node at least subtracts this Node initially can not concurrent node set.
With reference to the first possible implementation of first aspect, in the third possible implementation, the thread The immediate successor node of terminal node initially can not only be terminated in concurrent node set including the Thread Termination node Whole nodes of thread;
Before the traversal starts, in addition to:
According to the start node of thread initially can not concurrent node set be equal to create the thread thread creation node Node set on the start node of place thread to the reachable path of the thread creation node, calculates the beginning of each thread Node initially can not concurrent node set;
Initialize described program controlling stream graph first node can not concurrent node set;
In the ergodic process, in addition to:Calculate traverse each node can not concurrent node set, wherein:
If the present node traversed is the start node of thread, or the immediate successor section of Thread Termination node Point, then, when the direct precursor node of the present node is only one, the present node can not concurrent node set etc. In the present node direct precursor node can not concurrent node set and the present node initially can not concurrent node collection The union of conjunction, when the present node direct precursor node for it is multiple when, the present node can not concurrent node set Equal to all direct precursor nodes of the present node can not concurrent node intersection of sets collection, with the initial nothing of the present node Method concurrent node union of sets collection;
If the present node traversed is the immediate successor node of the start node and Thread Termination node except thread Node in addition, then, when the direct precursor node of the present node is only one, the present node can not be saved concurrently Point set be equal to the present node direct precursor node can not concurrent node set, when the direct precursor of the present node When node is only multiple, the present node can not concurrent node set be equal to all direct precursor nodes of the present node Can not concurrent node intersection of sets collection.
With reference to the first possible implementation of first aspect, in the 4th kind of possible implementation, the acquisition After program control flowchart, in addition to:
Obtain program control flowchart;
An immediate successor node is increased newly for each thread creation node in described program controlling stream graph is each, after this is direct It is auxiliary establishing node after node, the original immediate successor node of the thread creation node is changed to the thread creation node The immediate successor node of the auxiliary establishing node increased newly in immediate successor node, the line is designated as by the thread creation node Journey creates the direct precursor node of the start node for the thread that node is created;
It is straight for each newly-increased one of each Thread Termination node for terminating another thread in described program controlling stream graph Descendant node is connect, the immediate successor node is auxiliary terminal node, by the original immediate successor node of the Thread Termination node The immediate successor node of the auxiliary terminal node increased newly in the immediate successor node of the Thread Termination node is changed to, by described in The end node for the thread that Thread Termination node is terminated is changed to the straight of the newly-increased immediate successor node of the Thread Termination node Connect predecessor node;
The initial concurrent node collection of the immediate successor node of each thread creation node in the calculation procedure controlling stream graph It is specially each initial concurrent node set of auxiliary establishing node in calculation procedure controlling stream graph to close;
The immediate successor node of each Thread Termination node initially can not concurrently save in the calculation procedure controlling stream graph Point set be specially in calculation procedure controlling stream graph each auxiliary terminal node initially can not concurrent node set.
It is described to calculate in the 5th kind of possible implementation with reference to the 4th kind of possible implementation of first aspect The initial concurrent node set of the start node of each thread includes in program control flowchart:
A corresponding Partial controll set is respectively generated for the start node of each thread, wherein, the Partial controll collection Conjunction includes start node corresponding with the Partial controll set and in the range of whole program control flowchart, all right The first node for the start node control answered, wherein, the first node controlled by corresponding start node refers to from program Controlling stream graph first node starts into the path of first node itself to have to pass through the node of the corresponding start node;
For the start node of each thread, following first concurrent node calculation procedure is performed respectively to calculate each line The initial concurrent node set of the start node of journey, wherein, the first concurrent node calculation procedure includes:Calculate corresponding There is the 3rd node set of reachable path after auxiliary establishing node, with the corresponding auxiliary establishing node, wherein, it is described right The auxiliary establishing node answered is the auxiliary in the immediate successor node of the direct precursor node of the start node of targeted thread Node is created, is subtracted according to the initial concurrent node set of the start node of targeted thread equal to the 3rd node set Partial controll set corresponding to the start node, calculate the initial concurrent node set of the start node of targeted thread.
With reference to the 5th kind of possible implementation of first aspect, in the 6th kind of possible implementation, described is each Start node one Partial controll set of each corresponding generation of thread includes:
For it is each auxiliary terminal node respectively initialization one corresponding to terminate control set, wherein, will auxiliary terminal node, And in the termination for aiding in adding the auxiliary terminal node in thread, by the node that auxiliary terminal node controls where terminal node Control set;
For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd, described first Additional step includes:Judge whether include the end node of thread in targeted termination control set, if it is, judging to be somebody's turn to do The termination control set of auxiliary terminal node corresponding to end node whether non-NULL, if non-NULL, by corresponding to the end node The termination control set of terminal node is aided in add targeted termination control set, wherein, it is auxiliary corresponding to the end node It is the auxiliary end in the immediate successor node for the Thread Termination node of thread where terminating the end node to help terminal node Only node, judges whether targeted termination control set has the end node newly added, will be described new if what is newly added The end node of addition returns to the termination control of auxiliary terminal node corresponding to described judgement end node as object is judged System set whether non-NULL the step of, if without what is newly added, terminate it is described first add step;
A corresponding Partial controll set is respectively initialized for the start node of each thread, each thread is started to save Point, and where the start node in thread all nodes controlled by the start node be added to corresponding to Partial controll collection In conjunction;
For Partial controll set corresponding to the start node of each thread, the second addition step is respectively enterd, described Two addition steps include:The end node for whether including thread in targeted Partial controll set is judged, if it is, judging The termination control set of auxiliary terminal node corresponding to the end node whether non-NULL, it is if non-NULL, the end node is corresponding Termination control set add the targeted Partial controll set, and judge whether targeted Partial controll set has newly The end node of addition, if what is newly added, using the end node of the new addition as object is judged, return to and described sentence The termination control set of auxiliary terminal node corresponding to the end node of breaking whether non-NULL the step of, if without newly adding, knot Shu Suoshu second adds step.
It is described to calculate in the 7th kind of possible implementation with reference to the 4th kind of possible implementation of first aspect The initial concurrent node set of the immediate successor node of each thread creation node includes in program control flowchart:
A corresponding Partial controll set is respectively generated for each auxiliary establishing node, wherein, the Partial controll set Include auxiliary establishing node corresponding with the Partial controll set and in the range of whole program control flowchart, all quilts The section point of corresponding auxiliary establishing node control, wherein, the section point by corresponding auxiliary establishing node control Refer to have to pass through the corresponding auxiliary establishing into the path of section point itself since program control flowchart first node The node of node;
For each auxiliary establishing node, following second concurrent node calculation procedure is performed respectively to calculate each auxiliary The initial concurrent node set of node is created, wherein, the second concurrent node calculation procedure includes:Calculate in corresponding beginning There is the fourth node set of reachable path after node, with the corresponding start node, wherein, the corresponding start node For the start node in the immediate successor node of the direct precursor node of targeted auxiliary establishing node, according to targeted auxiliary The initial concurrent node set for creating node is helped to be subtracted equal to the fourth node set local corresponding to the auxiliary establishing node Control set, calculates the initial concurrent node set of targeted auxiliary establishing node.
With reference to the 7th kind of possible implementation of first aspect, in the 8th kind of possible implementation, described is each Respectively one corresponding Partial controll set of generation includes auxiliary establishing node:
For it is each auxiliary terminal node respectively initialization one corresponding to terminate control set, wherein, will auxiliary terminal node, And in the termination for aiding in adding the auxiliary terminal node in thread, by the node that auxiliary terminal node controls where terminal node Control set;
For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd, described first Additional step includes:Judge whether include the end node of thread in targeted termination control set, if it is, judging to be somebody's turn to do The termination control set of auxiliary terminal node corresponding to end node whether non-NULL, if non-NULL, by corresponding to the end node The termination control set of terminal node is aided in add targeted termination control set, wherein, it is auxiliary corresponding to the end node It is the auxiliary end in the immediate successor node for the Thread Termination node of thread where terminating the end node to help terminal node Only node, judges whether targeted termination control set has the end node newly added, will be described new if what is newly added The end node of addition returns to the termination control of auxiliary terminal node corresponding to described judgement end node as object is judged System set whether non-NULL the step of, if without what is newly added, terminate it is described first add step;
For the respectively one corresponding Partial controll set of initialization of each auxiliary establishing node, by each auxiliary establishing node, And all nodes by the auxiliary establishing node control are added to corresponding part in thread where the auxiliary establishing node In control set;
For Partial controll set corresponding to each auxiliary establishing node, respectively enter described second and add step, it is described Second addition step includes:Judge whether include the end node of thread in targeted Partial controll set, if it is, sentencing Break the end node corresponding to auxiliary terminal node termination control set whether non-NULL, if non-NULL, by the end node pair The termination control set answered adds the targeted Partial controll set, judges whether targeted Partial controll set has newly The end node of addition, if the end node newly added, the end node using the new addition returns as object is judged To the termination control set for judging to aid in terminal node corresponding to the end node whether non-NULL the step of, if without new plus Enter, terminate described second and add step.
With reference to the 4th kind of possible implementation of first aspect, in the 9th kind of possible implementation, in the traversal Before beginning, also by the initial of the node in addition to the immediate successor node of the start node of thread and thread creation node Concurrent node set is initialized as empty set;
It is described that traversal includes downwards since the first node of program control flowchart:
Using the first node of program control flowchart as present node;
Judge in the immediate successor node of present node with the presence or absence of be not calculated also concurrent node set it is direct after After node;
If not and the present node is not the first node of program control flowchart, then present node is updated into described work as Direct precursor node in the direct precursor node of front nodal point, just accessed, and return to the straight of the judgement present node The step of connecing in descendant node with the presence or absence of the immediate successor node for not being calculated concurrent node set also, it is if not and described Present node is the first node of program control flowchart, terminates flow;
If it is, the immediate successor of concurrent node set it is not calculated in the immediate successor node of access present node also Node;
The node that present node is updated to be accessed;
Judge whether to there is a node not to be calculated concurrent node set in the direct precursor node of present node and be somebody's turn to do It is not calculated the back edge that the directed edge between the node and present node of concurrent node set is not circulation;
If it is, present node is updated in the direct precursor node of the present node, be just accessed straight Predecessor node is connect, and returns in the immediate successor node of the judgement present node to whether there is not to be calculated also and concurrently saves The step of immediate successor node of point set;
Otherwise, judge whether present node is auxiliary terminal node;
If present node is auxiliary terminal node, the concurrent node set of the present node is calculated, wherein, institute State present node concurrent node set be equal to the present node direct precursor node concurrent node union of sets collection at least Subtract the present node initially can not concurrent node set, present node is updated to the direct precursor section of the present node Direct precursor node in point, just accessed, and return in the immediate successor node for judging present node and whether deposit Be not calculated the immediate successor node of concurrent node set also the step of;
If present node is not auxiliary terminal node, the concurrent node set of the present node is calculated, wherein, The concurrent node set of the present node is equal to the direct of initial concurrent node set and the present node of the present node The concurrent node union of sets collection of predecessor node, present node is updated in the direct precursor node of the present node, just Just accessed direct precursor node, and return in the immediate successor node of the judgement present node with the presence or absence of also not by The step of calculating the immediate successor node of concurrent node set.
Second aspect, the embodiments of the invention provide a kind of concurrent analytical equipment, described device includes:
Flow graph unit is obtained, for obtaining program control flowchart, wherein, in described program controlling stream graph, thread creation The direct precursor node of the start node for the thread that node is created for the thread creation node;
Initial computation unit, each thread opens in the program control flowchart obtained for calculating the acquisition flow graph unit The initial concurrent node set of beginning node, the initial concurrent node set of the immediate successor node of each thread creation node, with And the immediate successor node of each Thread Termination node initially can not concurrent node set;Wherein, each thread is opened The initial concurrent node set of beginning node is included after the thread creation node of thread where being used to create the start node In node, at least one node that can be concurrent with the start node;Wherein, the immediate successor section of the thread creation node In node after the start node for the thread that the initial concurrent node set of point is created including the thread creation node, extremely A few node that can be concurrent with the immediate successor node of the thread creation node;Wherein, Thread Termination node is direct Descendant node initially can not concurrent node set comprise at least whole nodes of thread that the Thread Termination node is terminated;
Initialization unit, the concurrent node set of the first node for initializing described program controlling stream graph;
Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, According to following inheritance rules, the concurrent node set of each node traversed is calculated, wherein, the inheritance principles include: If the present node traversed is not the immediate successor node of Thread Termination node, the concurrent node of the present node Set includes the concurrent node set of at least one direct precursor node of the present node;If present node is thread creation The immediate successor node of node or the start node of thread, then, the concurrent node set of the present node is including described first The initial concurrent node set for the present node that beginning computing unit is calculated is concurrent with least one direct precursor node The union of node set;If the present node traversed is the immediate successor node of Thread Termination node, it is described to work as prosthomere Concurrent node set of the concurrent node set of point equal at least one direct precursor node of the present node subtracts described first The present node that beginning computing unit is calculated initially can not concurrent node set.
In the first possible implementation of first aspect, the initial computation unit, controlled for calculation procedure The initial concurrent node set of the start node of each thread in flow graph, each thread creation node immediate successor node just The immediate successor node of beginning concurrent node set and each Thread Termination node initially can not concurrent node set, wherein: The initial concurrent node set of the start node of each thread calculated includes being used to create the start node institute online In node after the thread creation node of journey, all nodes that can be concurrent with the start node;What is calculated is each The initial concurrent node set of the immediate successor node of the thread creation node of thread is created including the thread creation node Thread start node after node in, all sections that can be concurrent with the immediate successor node of the thread creation node Point;The immediate successor node of the Thread Termination node calculated initially can not concurrent node set include the Thread Termination Whole nodes in the thread that node is terminated;
The Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, described traversed Cheng Zhong, according to following inheritance rules, calculate the concurrent node set of each node traversed:Wherein, the inheritance principles Including:
If the present node traversed is not the immediate successor node of Thread Termination node, the present node Concurrent node set includes the concurrent node union of sets collection of all direct precursor nodes of the present node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The initial concurrent node set of the concurrent node set of front nodal point including the present node and all direct precursor nodes and Send out the union of node set;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and The concurrent node union of sets collection for all direct precursor nodes that hair node set includes the present node subtracts the present node Initially can not concurrent node set.
It is described initial in second of possible implementation with reference to the first possible implementation of second aspect Computing unit, for the initial concurrent node set of the start node of each thread, each thread in calculation procedure controlling stream graph The immediate successor node of the initial concurrent node set of the immediate successor node of establishment node and each Thread Termination node Initially can not concurrent node set, wherein, in the initial concurrent node set of the start node of each thread calculated only Including in the node after the thread creation node for thread where creating the start node, it is all can be with the beginning The concurrent node of node;In the initial concurrent node set of the immediate successor node of each thread creation node calculated only In node after the start node of the thread created including the thread creation node, it is all can be with the thread creation The concurrent node of the immediate successor node of node;
The Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, described traversed Cheng Zhong, the concurrent node set of each node traversed is calculated, wherein:If the present node traversed is not Thread Termination Immediate successor node, the immediate successor node of thread creation node and the start node of thread of node, then it is, described current The concurrent node set of node is equal to the concurrent node union of sets collection of all direct precursor nodes of the present node;If work as Front nodal point is the immediate successor node of thread creation node or the start node of thread, then, the concurrently section of the present node Point set is equal to initial concurrent node set and the present node for the present node that the initial computation unit is calculated The concurrent node union of sets collection of all direct precursor nodes;If the present node traversed is the direct of Thread Termination node Descendant node, then, the concurrent node set of the present node are equal to the concurrent of all direct precursor nodes of the present node What the union of node set at least subtracted the present node that the initial computation unit is calculated initially can not concurrent node Set.
It is described initial in the third possible implementation with reference to the first possible implementation of second aspect Computing unit, for calculate Thread Termination node immediate successor node initially can not concurrent node set, wherein, it is described The immediate successor node of the Thread Termination node calculated initially can not be in concurrent node set, only including the Thread Termination The whole nodes for the thread that node is terminated;
The initial computation unit, be additionally operable to according to the start node of thread initially can not concurrent node set be equal to wound Set of node where building the thread creation node of the thread on the start node to the reachable path of the thread creation node of thread Close, calculate each thread start node initially can not concurrent node set;
The initialization unit, be additionally operable to initialize described program controlling stream graph first node can not concurrent node collection Close;
The Traversal Unit, be additionally operable to calculate traverse each node can not concurrent node set, wherein:If time The present node gone through is the start node of thread, or the immediate successor node of Thread Termination node, then, when described current When the direct precursor node of node is only one, the present node can not concurrent node set be equal to the present node it is straight Connect predecessor node can not concurrent node set and the initial computation unit present node that is calculated initially can not Concurrent node union of sets collection, when the present node direct precursor node for it is multiple when, the present node can not be simultaneously Hair node set can not concurrent node intersection of sets collection and the initial meter equal to all direct precursor nodes of the present node That calculates the present node that is calculated of unit initially can not concurrent node union of sets collection;If the present node traversed is to remove Node beyond the start node of thread and the immediate successor node of Thread Termination node is then, straight when the present node When to connect predecessor node be only one, the present node can not concurrent node set be equal to the direct precursor section of the present node Point can not concurrent node set, when the present node direct precursor node for it is multiple when, the present node can not be simultaneously Hair node set can not concurrent node intersection of sets collection equal to all direct precursor nodes of the present node.
With reference to the first possible implementation of second aspect, in the 4th kind of possible implementation, the acquisition Flow graph unit includes obtaining flow graph subelement, auxiliary establishing node increase subelement, auxiliary terminal node increase subelement;
Wherein, the acquisition flow graph subelement, for obtaining the controlling stream graph of each thread;
The auxiliary establishing node increases subelement, for each thread wound in the controlling stream graph for each thread Each newly-increased immediate successor node of node is built, the immediate successor node is auxiliary establishing node, by the thread creation node Original immediate successor node is changed to the auxiliary establishing node increased newly in the immediate successor node of the thread creation node Immediate successor node, the thread creation node is designated as the thread that the thread creation node is created start node it is direct Predecessor node;
The auxiliary terminal node increase subelement, for each for tying in the controlling stream graph for each thread The Thread Termination node of another thread of beam is each to increase an immediate successor node newly, and the immediate successor node is auxiliary terminal node, The original immediate successor node of the Thread Termination node is changed to what is increased newly in the immediate successor node of the Thread Termination node The immediate successor node of the auxiliary terminal node, the end node for the thread that the Thread Termination node is terminated are changed to this The direct precursor node of the newly-increased immediate successor node of Thread Termination node.
With reference to the 4th kind of possible implementation of second aspect, in the 5th kind of possible implementation, the initial meter Calculating unit includes First partial computation subunit, the first concurrent subelement;
Wherein, First partial computation subunit, for local corresponding to the start node for each thread respectively generation one Control set, wherein, the Partial controll set includes start node corresponding with the Partial controll set and whole In the range of program control flowchart, all first nodes controlled by corresponding start node, wherein, it is described to start to save by corresponding The first node of point control refers to have to pass through institute into the path of first node itself since program control flowchart first node The node of start node corresponding to stating;
The first concurrent subelement, for the start node for each thread, following first is performed respectively simultaneously Node calculation procedure is sent out to calculate the initial concurrent node set of the start node of each thread, wherein, described first is concurrent Node calculation procedure includes:Calculating has reachable after corresponding auxiliary establishing node, with the corresponding auxiliary establishing node 3rd node set in path, wherein, the corresponding auxiliary establishing node is the direct of the start node of targeted thread Auxiliary establishing node in the immediate successor node of predecessor node, initial according to the start node of targeted thread are concurrently saved Point set is equal to the 3rd node set and subtracts office corresponding to the start node of the First partial computation subunit generation Portion's control set, calculates the initial concurrent node set of the start node of targeted thread.
With reference to the 5th kind of possible implementation of second aspect, in the 6th kind of possible implementation, the first game Portion's computation subunit includes the first initial termination subelement, the first addition subelement, the first initial local subelement, and second adds Subelement;
Wherein, the described first initial termination subelement, for for corresponding to each auxiliary terminal node respectively initialization one Control set is terminated, wherein, by auxiliary terminal node and aiding in where terminal node in thread, by auxiliary terminal node The node of control adds the termination control set of the auxiliary terminal node;
Described first adds subelement, for being terminated for each auxiliary obtained from the described first initial termination subelement Control set is terminated corresponding to node, respectively enters the first addition step, the first addition step includes:Judge targeted Whether include the end node of thread, if it is, judging auxiliary terminal node corresponding to the end node if terminating in control set Point termination control set whether non-NULL, if non-NULL, will corresponding to the end node aid in terminal node termination domination set Close and add targeted termination control set, wherein, auxiliary terminal node is for terminating the knot corresponding to the end node Auxiliary terminal node in the immediate successor node of the Thread Termination node of thread where Shu Jiedian, judges targeted termination control Whether system set has the end node newly added, if what is newly added, using the end node of the new addition as judgement pair As, return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, such as Fruit terminates described first and adds step without what is newly added;
The first initial local subelement, for local corresponding to the start node for each thread respectively initialization one Control set, is controlled by the start node of each thread, and all in thread where the start node by the start node Node be added to corresponding in Partial controll set;
Described second adds subelement;For opening for each thread for being obtained from the first initial local subelement Partial controll set corresponding to beginning node, respectively enters the second addition step, and the second addition step includes:Judge targeted Partial controll set in whether include the end node of thread, if it is, judge it is described first addition subelement calculate The termination control set of auxiliary terminal node corresponding to the end node that arrives whether non-NULL, if non-NULL, by the end node It is corresponding to terminate the control set addition targeted Partial controll set, and whether judge targeted Partial controll set There is the end node newly added, if what is newly added, using the end node of the new addition as object is judged, return to institute State judge auxiliary terminal node corresponding to the end node termination control set whether non-NULL the step of, if added without new , terminate described second and add step.
With reference to the 4th kind of possible implementation of second aspect, in the 7th kind of possible implementation, the initial meter Calculating unit includes the second local computation subunit, the second concurrent subelement;
Wherein, the described second local computation subunit, for respectively generating office corresponding to one for each auxiliary establishing node Portion control set, wherein, the Partial controll set include auxiliary establishing node corresponding with the Partial controll set and In the range of whole program control flowchart, all section points by corresponding auxiliary establishing node control, wherein, it is described right The section point for the auxiliary establishing node control answered refers to since program control flowchart first node to the road of section point itself The node of the corresponding auxiliary establishing node is had to pass through in footpath;
The second concurrent subelement, for for each auxiliary establishing node, it is concurrent to perform following second respectively Node calculation procedure to calculate the initial concurrent node set of each auxiliary establishing node, wherein, second concurrent node Calculation procedure includes:Calculate has Section four of reachable path after corresponding start node, with the corresponding start node Point set, wherein, the corresponding start node is the immediate successor of the direct precursor node of targeted auxiliary establishing node Start node in node, the fourth node collection is equal to according to the initial concurrent node set of targeted auxiliary establishing node Partial controll set corresponding to subtracting the auxiliary establishing node of the described second local computation subunit generation is closed, calculates institute's pin To auxiliary establishing node initial concurrent node set.
With reference to the 7th kind of possible implementation of second aspect, in the 8th kind of possible implementation, the second game Portion's computation subunit includes the second initial termination subelement, the 3rd addition subelement, the second initial local subelement, and the 4th adds Subelement;
Wherein, the described second initial termination subelement, for for corresponding to each auxiliary terminal node respectively initialization one Control set is terminated, wherein, by auxiliary terminal node and aiding in where terminal node in thread, by auxiliary terminal node The node of control adds the termination control set of the auxiliary terminal node;
Described 3rd adds subelement, for being terminated for each auxiliary obtained from the described second initial termination subelement Control set is terminated corresponding to node, respectively enters the first addition step, the first addition step includes:Judge targeted Whether include the end node of thread, if it is, judging auxiliary terminal node corresponding to the end node if terminating in control set Point termination control set whether non-NULL, if non-NULL, will corresponding to the end node aid in terminal node termination domination set Close and add targeted termination control set, wherein, auxiliary terminal node is for terminating the knot corresponding to the end node Auxiliary terminal node in the immediate successor node of the Thread Termination node of thread where Shu Jiedian, judges targeted termination control Whether system set has the end node newly added, if what is newly added, using the end node of the new addition as judgement pair As, return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, such as Fruit terminates described first and adds step without what is newly added;
The second initial local subelement, for respectively initializing a corresponding local controlled for each auxiliary establishing node System set, by each auxiliary establishing node, and where the auxiliary establishing node in thread it is all by the auxiliary establishing node The node of control is added in corresponding Partial controll set;
Described 4th adds subelement, for each auxiliary establishing for being obtained from the second initial local subelement Partial controll set corresponding to node, respectively enter described second and add step, the second addition step includes:Judge institute's pin To Partial controll set in whether include the end node of thread, if it is, judge it is described 3rd add subelement calculate The termination control set of auxiliary terminal node corresponding to the obtained end node whether non-NULL, if non-NULL, this is terminated to save Control set is terminated corresponding to point and adds the targeted Partial controll set, and judges that targeted Partial controll set is It is no to have the end node newly added, if what is newly added, using the end node of the new addition as object is judged, return to The termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, if added without new , terminate described second and add step.
With reference to the 4th kind of possible implementation of second aspect, in the 9th kind of possible implementation, the initialization Unit, it is additionally operable to before the traversal starts, by except the immediate successor of the start node of thread and thread creation node The initial concurrent node set of node outside node is initialized as empty set;
The Traversal Unit includes first node and sets subelement, the first judgment sub-unit, first return to subelement, terminate son Unit, access subelement, node updates subelement, the second judgment sub-unit, second return subelement, the 3rd judgment sub-unit, First traversal computation subunit, the second traversal computation subunit;
Wherein, the first node sets subelement, for using the first node of program control flowchart as present node;
First judgment sub-unit, with the presence or absence of not calculated also in the immediate successor node for judging present node Go out the immediate successor node of concurrent node set;
Described first returns to subelement, is judged as NO for first judgment sub-unit and the present node is not journey During the first node of sequence controlling stream graph, using the direct precursor node of the present node as present node, described in retriggered One judgment sub-unit;
The end subelement, it is judged as NO for first judgment sub-unit and the present node is programme-control During the first node of flow graph, terminate flow;
The access subelement, when being judged as YES for first judgment sub-unit, access present node it is direct after After the immediate successor node for not being calculated concurrent node set in node also;
The node updates subelement, in the access unit accessed node, present node to be updated to Accessed node;
Second judgment sub-unit, for after node updates subelement renewal, judging the direct of present node Whether have that a node is not calculated concurrent node set and this is not calculated concurrent node set in predecessor node Directed edge between node and present node is not the back edge of circulation;
Described second returns to subelement, and when being judged as YES for second judgment sub-unit, present node is updated to Direct precursor node in the direct precursor node of the present node, just accessed, and the first judgement described in retriggered Subelement;
3rd judgment sub-unit, when being judged as NO for second judgment sub-unit, whether judge present node To aid in terminal node;
The first traversal computation subunit, when being judged as YES for the 3rd judgment sub-unit, calculate described current The concurrent node set of node, wherein, the concurrent node set of the present node is equal to the direct precursor section of the present node What the concurrent node union of sets collection of point at least subtracted the present node initially can not concurrent node set;
The second traversal computation subunit, when being judged as NO for the 3rd judgment sub-unit, calculate described current The concurrent node set of node, wherein, the concurrent node set of the present node is equal to the initial of the present node and concurrently saved Point set and the concurrent node union of sets collection of the direct precursor node of the present node.
It can be seen that the present invention has the advantages that:
Due to the line that in the program control flowchart acquired in the present invention, thread creation node is created by thread creation node The direct precursor node of the start node of journey, therefore, each single thread have been spliced to form complete program control flowchart, to connect Getting off, which only need to once travel through the concurrent node set that can calculate each node, is made that preparation, due in program control flowchart In, the immediate successor node of thread start node and thread creation node can produce new concurrently section due to the establishment of thread Point, the immediate successor node of Thread Termination node can be produced due to the termination of thread it is new can not concurrent node, except above-mentioned line Beyond journey start node, the immediate successor node of thread creation node, Thread Termination node, other nodes can pass through succession The concurrent node union of sets collection of its direct precursor node obtains the concurrent node set of the node, therefore, the embodiment of the present invention The initial concurrent node set of the start node of each thread in program control flowchart, wherein has been calculated first, it is described each The initial concurrent node set of the start node of thread includes the thread creation section of thread where being used to create the start node In node after point, at least one node that can be concurrent with the start node, each thread creation node has been calculated Immediate successor node initial concurrent node set, wherein, the immediate successor node of the thread creation node it is initial simultaneously Hair node set is included in the node after the start node of thread that the thread creation node is created, it is at least one can The concurrent node with the immediate successor node of the thread creation node, and calculated the direct of each Thread Termination node Descendant node initially can not concurrent node set, wherein, the immediate successor node of Thread Termination node initially can not be concurrent Node set comprises at least the whole nodes for the thread that the Thread Termination node is terminated, so as in initialization described program control After the concurrent node set of the first node of flow graph processed, it can be traveled through downwards since the first node of described program controlling stream graph, In the ergodic process, the concurrent node set of each node traversed is calculated based on inheritance rules, it is seen then that due to this hair Bright embodiment can once travel through the concurrent node set for calculating each node in program control flowchart, and computing is simple and transports Calculation amount is small, realizes the purpose for improving concurrent analysis efficiency.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing There is the required accompanying drawing used in technology description to be briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be with Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is a kind of one of schematic flow sheet of concurrent analysis method provided in an embodiment of the present invention;
Fig. 2-1 is a kind of one of program control flowchart schematic diagram that the embodiment of the present invention may relate to;
Fig. 2-2 is the two of a kind of program control flowchart schematic diagram that the embodiment of the present invention may relate to;
Fig. 3 is the two of the schematic flow sheet of a kind of concurrent analysis method provided in an embodiment of the present invention;
Fig. 4 is the three of the schematic flow sheet of a kind of concurrent analysis method provided in an embodiment of the present invention;
Fig. 5 is the four of the schematic flow sheet of a kind of concurrent analysis method provided in an embodiment of the present invention;
Fig. 6 is a kind of one of structural representation of concurrent analytical equipment provided in an embodiment of the present invention;
Fig. 7 is the two of the structural representation of a kind of concurrent analytical equipment provided in an embodiment of the present invention;
Fig. 8 is the three of the structural representation of a kind of concurrent analytical equipment provided in an embodiment of the present invention;
Fig. 9 is the four of the structural representation of a kind of concurrent analytical equipment provided in an embodiment of the present invention.
Embodiment
To enable the above-mentioned purpose of the embodiment of the present invention, feature and advantage more obvious understandable, below in conjunction with the accompanying drawings and Embodiment is described in further detail to the embodiment of the present invention.
Before the embodiment of the present invention is discussed in detail, in order that method provided in an embodiment of the present invention readily appreciates, under Face first illustrates to the basic conception involved by the embodiment of the present invention:
Program control flowchart:It is the abstraction of a process or program, is digraph, each sentence in program is right Node that should be in figure, if a program includes multiple threads, can include multiple threads in program control flowchart Controlling stream graph;
Thread creation node:Be program a thread in, for creating the node of another thread;
The start node of thread:Be program a thread in first program sentence corresponding to node;
Thread Termination node:Be program a thread in, in a manner of various grammatical forms or function call Remove to terminate the node of the thread during another is carrying out;
The end node of thread:Be program a thread in last program statement corresponding to node;
Controlled node:In program control flowchart, if reaching some node x process from the start node of flow graph In must pass through node p, then we claim node p control node x, and node x is the node controlled by node p.
It should be noted that necessarily having the start node and end node of a thread in a thread, may have May be without the thread for another thread in creating the thread creation node of another thread and being carrying out for termination Terminal node.
In order to realize the purpose for improving concurrent analysis efficiency, the embodiment of the present invention proposes once traversal and calculates program The scheme of the concurrent node of each node in controlling stream graph.The scheme the principle on which of the embodiment of the present invention is:Thread starts The immediate successor node of node and thread creation node can produce new concurrent node, Thread Termination due to the establishment of thread The immediate successor node of node can be produced due to the termination of thread it is new can not concurrent node, except above-mentioned thread start node, Beyond the immediate successor node of thread creation node, the immediate successor node of Thread Termination node, other nodes can pass through The concurrent node union of sets collection for inheriting its direct precursor node obtains the concurrent node set of the node.
A kind of concurrent analysis method provided in an embodiment of the present invention based on above-mentioned principle is described in detail below:
Referring to Fig. 1, a kind of one of schematic flow sheet of concurrent analysis method provided in an embodiment of the present invention is shown.Such as figure Shown, the embodiment can include:
S110, program control flowchart is obtained, wherein, in described program controlling stream graph, thread creation node is the line Journey creates the direct precursor node of the start node for the thread that node is created;
It should be noted that because the embodiment of the present invention is needed in ergodic process once from top to bottom by inheriting directly The concurrent node of predecessor node is connect to calculate the concurrent node set of each node traversed, therefore, such as Fig. 2-1 or Fig. 2-2 Shown, in the program control flowchart acquired in the embodiment of the present invention, thread creation node 210 should be the thread creation node and be created The direct precursor node of the start node 270 for the thread built, so as to which each independent thread in program is spliced into complete journey Sequence controlling stream graph, the principle based on above-mentioned succession calculates traversal during the traversal since program first node from top to bottom The concurrent node set of each node arrived.
The initial concurrent node set of the start node of each thread in S120, calculation procedure controlling stream graph, wherein, it is described The initial concurrent node set of the start node of each thread includes the thread wound of thread where being used to create the start node Build in the node after node, at least one node that can be concurrent with the start node,
It should be noted that according to this embodiment of the invention, the initial concurrent node of the start node of each thread Set can include being used to create in the node after the thread creation node of start node place thread, one or more Individual, even all nodes that can be concurrent with the start node can be according to implementing to need to change, in the present invention not Limited.
The initial concurrent node collection of the immediate successor node of each thread creation node in S121, calculation procedure controlling stream graph Close, wherein, the concurrent node set of the immediate successor node of the thread creation node is created including the thread creation node In node after the start node for the thread built, it is at least one can be with the immediate successor node of the thread creation node simultaneously The node of hair;
It should be noted that according to this embodiment of the invention, the immediate successor node of each thread creation node Initial concurrent node set can be included in the node after the start node for the thread that the thread creation node is created, and one Individual or multiple, even all nodes that can be concurrent with the immediate successor node of the thread creation node can be according to reality Applying needs to change, and in the present invention and is not limited.
The immediate successor node of each Thread Termination node initially can not concurrently save in S122, calculation procedure controlling stream graph Point set, wherein, the immediate successor node of the Thread Termination node initially can not concurrent node set comprise at least it is described The whole nodes for the thread that Thread Termination node is terminated;
It should be noted that according to this embodiment of the invention, the immediate successor node of each Thread Termination node Initially can not concurrent node set can only include whole nodes in the thread that be terminated of the Thread Termination node, or Person, all nodes that can not be concurrent with the immediate successor node of the Thread Termination node can be included, can be according to implementation need Change, in the present invention and be not limited.
It should be noted that in embodiments of the present invention, the above-mentioned initial concurrent node collection for calculating the start node Close, the initial concurrent node set of the immediate successor node of thread creation node, the immediate successor node of Thread Termination node Initially can not the specific implementation of concurrent node set can be based on the existing mode of prior art, can also be based on will be under Implementation disclosed in the embodiment of the present invention of face, in the present invention and it is not limited.But no matter using which kind of mode, institute State thread where being applied to create the start node in the initial concurrent node set of start node thread creation node it In node afterwards, at least one node that can be concurrent with the start node, the immediate successor section of the thread creation node The node after the start node for the thread that the thread creation node is created should be included in the initial concurrent node set of point In, at least one node that can be concurrent with the immediate successor node of the thread creation node, so as in the mistake once traveled through Cheng Zhong, it can enable to directly obtain due to concurrent node caused by thread creation by inheriting after node thereafter, it is simple fast Accurate concurrent node set is calculated fastly.Wherein, the immediate successor node of the Thread Termination node initially can not be simultaneously Hair node set comprises at least the whole nodes for the thread that the Thread Termination node is terminated.For example, wherein, the thread is whole Only the immediate successor node of node initially can not concurrent node set can include iting the institute in whole program control flowchart Have can not concurrent node, can also only include whole nodes of thread that the Thread Termination node be terminated.Only including institute In the implementation of whole nodes for stating the thread that Thread Termination node is terminated, succession can be passed through during traversal Its direct precursor node can not concurrent node set, to the immediate successor node of the Thread Termination node can not concurrent node Set supplemented, supplement completely can not concurrent node set can be used for the Thread Termination node is calculated in step S170 Immediate successor node concurrent node set.
S130, initialize described program controlling stream graph first node concurrent node set;
In embodiments of the present invention, the concurrent node set of the first node of the initialization described program controlling stream graph can be with Empty set specifically is initialized as, concurrent node known to the first node can also be added to the first node according to needs are implemented In concurrent node set, in the present invention and it is not limited.
S140, traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, according to following Inheritance rules, the concurrent node set of each node traversed is calculated, wherein:
If S140.1, the present node traversed are not the immediate successor nodes of Thread Termination node, it is described current The concurrent node set of node includes the concurrent node union of sets collection of at least one direct precursor node of the present node;
For example, if the present node traversed were not the immediate successor node of Thread Termination node, it is described to work as prosthomere The concurrent node set of point can include one or more of the present node, the concurrently section of even all direct precursor nodes The union of point set.
If S140.2, the present node traversed are immediate successor node or the beginning of thread of thread creation node Node, then, the concurrent node set of the present node include the initial concurrent node set and at least one of the present node The concurrent node union of sets collection of individual direct precursor node;
For example, if present node were the immediate successor node of thread creation node or the start node of thread, institute Initial concurrent node set and the one or more of the present node can be included by stating the concurrent node set of present node, very To the concurrent node union of sets collection for being all direct precursor nodes;
If S140.3, the present node traversed are the immediate successor nodes of Thread Termination node, it is described to work as prosthomere It is current that concurrent node set of the concurrent node set of point equal at least one direct precursor node of the present node subtracts this Node initially can not concurrent node set.
For example, if the present node traversed were the immediate successor node of Thread Termination node, the present node Concurrent node set include the present node one or more, the concurrent node set of even all direct precursor nodes Union subtract the present node initially can not concurrent node set.
It can be seen that using method provided in an embodiment of the present invention, due in acquired program control flowchart, thread creation section The direct precursor node of the start node for the thread that point is created by thread creation node, each single thread has been spliced to form complete Whole program control flowchart, the concurrent node set that can calculate each node for following once traversal are made that preparation; The embodiment of the present invention has calculated the initial concurrent node set of the start node of each thread in program control flowchart, every first The initial concurrent node set of the immediate successor node of individual thread creation node and the immediate successor of each Thread Termination node Node initially can not concurrent node set, wherein, the initial concurrent node set of the start node includes being used to create In node after the thread creation node of thread where the start node, it is at least one can be concurrent with the start node Node, the initial concurrent node set of the immediate successor node of the thread creation node includes the thread creation node institute In node after the start node of the thread of establishment, it is at least one can be with the immediate successor node of the thread creation node Concurrent node, the immediate successor node of the Thread Termination node initially can not concurrent node set to include the thread whole At least one node for the thread that only node is terminated, it is thus possible to initialize the first node of described program controlling stream graph After concurrent node set, it is possible to traveled through downwards since the first node of described program controlling stream graph, in the ergodic process In, according to inheritance rules, calculate the concurrent node set of each node traversed, it is seen then that the embodiment of the present invention can be with one Secondary traversal calculates the concurrent node set of each node in program control flowchart, and computing is simple and operand is small, realizes Improve the purpose of concurrent analysis efficiency.
In a kind of possible implementation of the embodiment of the present invention, in order to not omit any concurrent node, such as:
The initial concurrent node set of the start node of each thread can include being used to create the start node In node after the thread creation node of place thread, all nodes that can be concurrent with the start node;
The initial concurrent node set of the immediate successor node of the thread creation node can include the thread creation In node after the start node for the thread that node is created, it is all can be with the immediate successor section of the thread creation node The concurrent node of point;
The immediate successor node of the Thread Termination node initially can not concurrent node set can include the thread Whole nodes in the thread that terminal node is terminated;
If the present node traversed is not the immediate successor node of Thread Termination node, the present node Concurrent node set can include the concurrent node union of sets collection of all direct precursor nodes of the present node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The concurrent node set of front nodal point can include the initial concurrent node set of the present node and all direct precursor nodes Concurrent node union of sets collection;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and It is current that the concurrent node union of sets collection for all direct precursor nodes that hair node set can include the present node subtracts this Node initially can not concurrent node set.
In the implementation, due to by it is all can not be inherited, the start node of thread it is initial concurrent Node, the initial concurrent node of the immediate successor node of thread creation node, and the immediate successor node of Thread Termination node Initially can not concurrent node, all calculated before traversal, therefore, all concurrent nodes can be in the mistake of traversal Obtained in journey by inheriting its direct precursor node, any concurrent node will not be omitted, the degree of accuracy is very high.
In the implementation, there can also be following two possible implementations:
One kind is, if only including using in the initial concurrent node set of the start node of each thread calculated , can be concurrent with the start node in the node after the thread creation node of thread where creating the start node Node;And only include in the initial concurrent node set of the immediate successor node of each thread creation node calculated , can be straight with the thread creation node in node after the start node for the thread that the thread creation node is created Connect the concurrent node of descendant node;
Then, if the present node traversed is not the immediate successor node of Thread Termination node, thread creation node The start node of immediate successor node and thread, then, the concurrent node set of the present node are equal to the present node The concurrent node union of sets collection of all direct precursor nodes;If present node is the immediate successor node of thread creation node Or the start node of thread, then, the concurrent node set of the present node is equal to the initial of the present node and concurrently saved Point set and the concurrent node union of sets collection of all direct precursor nodes of the present node;If the present node traversed It is the immediate successor node of Thread Termination node, then, the concurrent node set of the present node is equal to the institute of the present node What the concurrent node union of sets collection for having direct precursor node at least subtracted the present node initially can not concurrent node set.
In the implementation, the initial concurrent node set of the start node due to only calculating thread, thread creation The part that should at least include in the initial concurrent node set of the immediate successor node of node, subsequently passes through during traversal The concurrent node set for inheriting its direct precursor node is supplemented, and amount of calculation is small, and efficiency is higher.
Another kind is, if present node is the immediate successor node or start node of thread creation node, and currently The initial concurrent node set of node has included the present node all concurrent nodes in program control flowchart;Then, such as The present node that fruit traverses be not the immediate successor node of Thread Termination node, thread creation node immediate successor node, And the start node of thread, then, the concurrent node set of the present node is equal to all direct precursors of the present node The concurrent node union of sets collection of node;If present node is the immediate successor node of thread creation node or opening for thread Beginning node, then, the concurrent node set of the present node are equal to the initial concurrent node set of the present node;If time The present node gone through is the immediate successor node of Thread Termination node, then, the concurrent node set of the present node is equal to The concurrent node union of sets collection of all direct precursor nodes of the present node at least subtracts initially can not for the present node Concurrent node set.
It should be noted that in embodiments of the present invention, the initial nothing of the immediate successor node of the Thread Termination node The set of method concurrent node includes at least one node in the thread that the Thread Termination node is terminated, therefore, the thread The immediate successor node of terminal node initially can not concurrent node set can include whole program control flowchart in the range of institute Have with the immediate successor node of the Thread Termination node can not be concurrent node set, can also only include the Thread Termination section Whole nodes of the terminated thread of point, or other embodiment, in the present invention and are not limited.Below, to described The immediate successor node of Thread Termination node initially can not concurrent node set only terminated including the Thread Termination node The embodiment of whole nodes of thread describe in detail:
The Thread Termination node immediate successor node initially can not concurrent node set only include the thread In the embodiment of the whole nodes for the thread that terminal node is terminated, a kind of optional mode is passed through during traversal Inherit its direct precursor node can not concurrent node set supplemented.Specifically, for example, with reference to Fig. 3, the present invention is shown The two of the schematic flow sheet for a kind of concurrent analysis method that embodiment provides, as shown in figure 3, can be based on above-mentioned as shown in Figure 1 Embodiment, increase following steps:
Step S123, according to the start node of thread initially can not concurrent node set be equal to create the thread thread Node set where creating node on the start node to the reachable path of the thread creation node of thread, calculates each line The start node of journey initially can not concurrent node set;
Step S124, initialize described program controlling stream graph first node can not concurrent node set;
Step S141, in the ergodic process, calculate each node for traversing can not concurrent node set, its In,
If the present node traversed is the start node of thread, or the immediate successor section of Thread Termination node Point, then, when the direct precursor node of the present node is only one, the present node can not concurrent node set etc. In the present node direct precursor node can not concurrent node set and the present node initially can not concurrent node collection The union of conjunction, when the present node direct precursor node for it is multiple when, the present node can not concurrent node set Equal to all direct precursor nodes of the present node can not concurrent node intersection of sets collection, with the initial nothing of the present node Method concurrent node union of sets collection;
If the present node traversed is the immediate successor node of the start node and Thread Termination node except thread Node in addition, then, when the direct precursor node of the present node is only one, the present node can not be saved concurrently Point set be equal to the present node direct precursor node can not concurrent node set, when the direct precursor of the present node When node is only multiple, the present node can not concurrent node set be equal to all direct precursor nodes of the present node Can not concurrent node intersection of sets collection.
It should be noted that if present node is the immediate successor node of Thread Termination node, present node is calculated Can not concurrent node set the step of must before concurrent node set is calculated so that it is that present node is calculated and Necessarily eliminated due to can not concurrent node caused by Thread Termination in hair node set.For straight except Thread Termination node Connect the node beyond descendant node, calculate can not the order of concurrent node set and calculating concurrent node set can exchange, no Influence the result of calculating concurrent node set.In addition, calculate initial concurrent node set, initially can not concurrent node set or Initialize the concurrent node set of first node and also can not must comply between each step of concurrent node set Sequentially, any exchange can be carried out.But the traversal of the embodiment of the present invention, must be traversal from top to bottom, so that The concurrent node set of one node or can not concurrent node set be able to concurrent node set in its direct precursor node Calculated in the case of having calculated.
It can be seen that the embodiment of the present invention shown in application drawing 3, because the embodiment is considered for the direct of Thread Termination node For the start node of descendant node and thread, it can not be in concurrent node it is a part of can by inherit its it is direct before Drive node can not concurrent node set obtain, so, for the immediate successor node of Thread Termination node, the thread The immediate successor node of terminal node initially can not only include Thread Termination node institute eventually in concurrent node set Whole nodes of thread only, for the start node of thread, can be according to the start node of thread initially can not be simultaneously Send out node set be equal to create the thread thread creation node where thread start node to the thread creation node can Up to the node set on path, calculate each thread start node initially can not concurrent node set, and then traveling through During, then to its can not concurrent node supplement, with calculate it is all in the range of whole program control flowchart can not Concurrent node compares, and reduces amount of calculation to a certain extent, improves efficiency.Moreover, each section is calculated in ergodic process Point can not concurrent node set when, it is also contemplated that if the direct precursor node of present node has multiple, because program is real Border, which once performs, typically only carries out one of them possible branch, can't perform whole, take the direct precursor section of present node Point can not concurrent node intersection of sets collection add to present node can not can ensure what is obtained in concurrent node set It is current its can not concurrent node set reach minimal set, the node one for being possible to concurrent, which is established a capital, will be retained in its concurrent node collection In conjunction, to the relevant treatment of node that may be concurrent after being advantageous to, concurrent node will not be omitted.
Furthermore, it is contemplated that in program control flowchart, the immediate successor node of a thread creation node may be it is multiple, one The immediate successor node of individual Thread Termination node may also be multiple, in order to reduce amount of calculation, improve efficiency, the embodiment of the present invention In a kind of possible implementation, an auxiliary establishing section is inserted between a thread creation node directly descendant node Point, an auxiliary terminal node is inserted between a Thread Termination node directly descendant node, thread is directed to reduce Create the amount of calculation of the immediate successor node of node and the immediate successor node for Thread Termination node.Specifically, can be with The three of a kind of schematic flow sheet of concurrent analysis method provided in an embodiment of the present invention shown in Figure 4, as illustrated, the implementation Example can include:
S410.1, the controlling stream graph for obtaining each thread;
For example, the controlling stream graph of two threads as shown in Fig. 2-1 can be obtained, wherein, node 210 is thread creation section Point, node 220-230 are the original immediate successor node of the thread creation node, and node 240 is Thread Termination node, node 250-260 is the original immediate successor node of the Thread Termination node;
S410.2, for each thread controlling stream graph in each thread creation node it is each increase newly an immediate successor Node, the immediate successor node are auxiliary establishing node, and the original immediate successor node of the thread creation node is changed into this The immediate successor node of the auxiliary establishing node increased newly in the immediate successor node of thread creation node, the thread is created Build the direct precursor node that node is designated as the start node for the thread that the thread creation node is created;
For example, as shown in Fig. 2-2, thread creation node 210 has increased an immediate successor node, i.e. auxiliary establishing node newly 211, the original immediate successor node of the thread creation node 210 has been changed to the immediate successor node of auxiliary establishing node 211;
S410.3, for each Thread Termination node for being used to terminate another thread in the controlling stream graph of each thread Each to increase an immediate successor node newly, the immediate successor node is auxiliary terminal node, and the Thread Termination node is original Immediate successor node be changed in the immediate successor node of the Thread Termination node increase newly the auxiliary terminal node it is direct after After node, the end node of the thread that the Thread Termination node is terminated is changed to the newly-increased direct of the Thread Termination node The direct precursor node of descendant node.
For example, as shown in Fig. 2-2, Thread Termination node 240 has increased an immediate successor node newly, that is, aids in terminal node 241, the original immediate successor node of the Thread Termination node 240 has been changed to aid in the immediate successor node of terminal node 241, example Such as, the end node for the thread that Thread Termination node is terminated can also be designated as to the direct precursor section of the Thread Termination node Point, i.e. created in program control flowchart from the end node of thread to the immediate successor section for the terminal node for terminating the thread Point, that is, aid in the directed edge between terminal node.
The initial concurrent node set of the start node of each thread in S420, calculation procedure controlling stream graph;
It should be noted that in embodiments of the present invention, calculate the specific reality of the initial concurrent node set of start node Existing mode is unlimited.A kind of possible implementation is given below, for example, can include:
A corresponding Partial controll set is respectively generated for the start node of each thread, wherein, the Partial controll collection Conjunction includes start node corresponding with the Partial controll set and in the range of whole program control flowchart, all right The first node for the start node control answered, wherein, the first node controlled by corresponding start node refers to from program Controlling stream graph first node starts into the path of first node itself to have to pass through the specific node of the corresponding start node;
For example, as shown in Fig. 2-2, the Partial controll collection of thread start node 270 be combined into BT, F1, FT, AET, ET, M4, M5}
For the start node of each thread, following first concurrent node calculation procedure is performed respectively to calculate each line The initial concurrent node set of the start node of journey, wherein, the first concurrent node calculation procedure includes:Calculate corresponding There is the 3rd node set of reachable path after auxiliary establishing node, with the corresponding auxiliary establishing node, wherein, it is described right The auxiliary establishing node answered is the auxiliary in the immediate successor node of the direct precursor node of the start node of targeted thread Node is created, is subtracted according to the initial concurrent node set of the start node of targeted thread equal to the 3rd node set Partial controll set corresponding to the start node, calculate the initial concurrent node set of the start node of targeted thread.
For example, as shown in Fig. 2-2, auxiliary establishing node corresponding with start node 270 has the 3rd set of node of reachable path { ACT, M1, M2, ET, AET, M4, M5 } is combined into, then the initial concurrent node collection of start node 270 is combined into { ACT, M1, M2 }.
It should be noted that wherein, the specific generating mode of Partial controll set corresponding to the start node is unlimited, In a kind of possible implementation of the embodiment of the present invention, can precompute each start node where it in thread by it The set of the node of control, i.e., each start node is corresponding in thread where it respectively to terminate control set, further according to line The termination control set of the auxiliary terminal node formed between journey and thread due to termination relation is started the control of node control Relation, the termination control set for aiding in terminal node is delivered in the termination control set of start node, and then may finally Obtain complete Partial controll set corresponding to each start node, due in the implementation, for start node and The calculating of termination control set of the terminal node in single thread is aided in, therefore, can be carried out respectively serial or parallel Calculate, then be delivered in the Partial controll set of start node, can reach and put forward efficient purpose, specifically, for example, described It can include for start node one Partial controll set of each corresponding generation of each thread:
For it is each auxiliary terminal node respectively initialization one corresponding to terminate control set, wherein, will auxiliary terminal node, And in the termination for aiding in adding the auxiliary terminal node in thread, by the node that auxiliary terminal node controls where terminal node Control set;
For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd, described first Additional step includes:Judge whether include the end node of thread in targeted termination control set, if it is, judging to be somebody's turn to do The termination control set of auxiliary terminal node corresponding to end node whether non-NULL, if non-NULL, by corresponding to the end node The termination control set of terminal node is aided in add targeted termination control set, wherein, it is auxiliary corresponding to the end node It is the auxiliary end in the immediate successor node for the Thread Termination node of thread where terminating the end node to help terminal node Only node, judges whether targeted termination control set has the end node newly added, will be described new if what is newly added The end node of addition returns to the termination control of auxiliary terminal node corresponding to described judgement end node as object is judged System set whether non-NULL the step of, if without what is newly added, terminate it is described first add step;
A corresponding Partial controll set is respectively initialized for the start node of each thread, each thread is started to save Point, and where the start node in thread all nodes controlled by the start node be added to corresponding to Partial controll collection In conjunction;
For Partial controll set corresponding to the start node of each thread, the second addition step is respectively enterd, described Two addition steps include:The end node for whether including thread in targeted Partial controll set is judged, if it is, judging The termination control set of auxiliary terminal node corresponding to the end node whether non-NULL, it is if non-NULL, the end node is corresponding Termination control set add the targeted Partial controll set, and judge whether targeted Partial controll set has newly The end node of addition, if what is newly added, using the end node of the new addition as object is judged, return to and described sentence The termination control set of auxiliary terminal node corresponding to the end node of breaking whether non-NULL the step of, if without newly adding, knot Shu Suoshu second adds step.
The initial concurrent node set of each auxiliary establishing node in S421, calculation procedure controlling stream graph;
It should be noted that in embodiments of the present invention, each auxiliary establishing node is first in calculation procedure controlling stream graph The beginning specific implementation of concurrent node set is unlimited.A kind of possible implementation is given below:With above-mentioned opening for thread Beginning node calculates the principle of initial concurrent node set similarly, each auxiliary establishing node in the calculation procedure controlling stream graph Initial concurrent node set can include:
A corresponding Partial controll set is respectively generated for each auxiliary establishing node, wherein, the Partial controll set Include auxiliary establishing node corresponding with the Partial controll set and in the range of whole program control flowchart, all quilts The section point of corresponding auxiliary establishing node control, wherein, the section point by corresponding auxiliary establishing node control Refer to have to pass through the corresponding auxiliary establishing into the path of section point itself since program control flowchart first node The node of node;
For example, as shown in Fig. 2-2, the Partial controll collection of auxiliary establishing node 211 be combined into ACT, M1, M2, ET, AET, M4, M5}
For each auxiliary establishing node, following second concurrent node calculation procedure is performed respectively to calculate each auxiliary The initial concurrent node set of node is created, wherein, the second concurrent node calculation procedure includes:Calculate in corresponding beginning There is the fourth node set of reachable path after node, with the corresponding start node, wherein, the corresponding start node For the start node in the immediate successor node of the direct precursor node of targeted auxiliary establishing node, according to targeted auxiliary The initial concurrent node set for creating node is helped to be subtracted equal to the fourth node set local corresponding to the auxiliary establishing node Control set, calculates the initial concurrent node set of targeted auxiliary establishing node.
For example, as shown in Fig. 2-2, start node 270 corresponding with auxiliary establishing node 211 has Section four of reachable path Point set is combined into { BT, F1, FT }, then the initial concurrent node collection of auxiliary establishing node 211 is combined into { BT, F1, FT }.
Wherein, the specific generating mode of Partial controll set is unlimited corresponding to the auxiliary establishing node, of the invention real Apply in a kind of possible implementation of example, identical principle is calculated based on the Partial controll set with above-mentioned start node, specifically Ground, such as:
Can be to terminate control set corresponding to each each initialization one of auxiliary terminal node, wherein, it will aid in terminating Node and aiding in adding the auxiliary terminal node in thread, by the node that auxiliary terminal node controls where terminal node Termination control set;
For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd;
For the respectively one corresponding Partial controll set of initialization of each auxiliary establishing node, by each auxiliary establishing node, And all nodes by the auxiliary establishing node control are added to corresponding part in thread where the auxiliary establishing node In control set;
For Partial controll set corresponding to each auxiliary establishing node, respectively enter described second and add step.
Wherein, the specific implementation of the first addition step and the second addition step may refer to foregoing description, It will not be repeated here.
Each auxiliary terminal node initially can not concurrent node set in S422, calculation procedure controlling stream graph;
S430, initialize described program controlling stream graph first node concurrent node set;
S440, traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, calculate traversal The concurrent node set of each node arrived, wherein:
If S440.1, the present node traversed are not auxiliary terminal nodes, the concurrent node of the present node Concurrent node union of sets collection of the set including at least all direct precursor nodes of the present node;
If S440.2, the present node traversed are the start nodes of auxiliary establishing node or thread, it is described to work as The concurrent node set of front nodal point comprises at least the initial concurrent node set of the present node;
If S440.3, the present node traversed are auxiliary terminal nodes, the concurrent node collection of the present node The concurrent node union of sets collection for closing all direct precursor nodes equal to the present node at least subtracts the first of the present node Beginning can not concurrent node set.
It can be seen that method provided in an embodiment of the present invention shown in application drawing 4, because increase auxiliary establishing node and auxiliary are whole Only node, for a thread creation node, can by originally may be directed to the thread creation node it is multiple directly after Calculating after node turns to calculating for an auxiliary establishing node, can be by original for a Thread Termination node The calculating of this multiple immediate successor node that may be directed to Thread Termination node turns to the calculating for an auxiliary terminal node, So as to reduce amount of calculation, efficiency is improved.
In the embodiment of the present invention in another possible implementation, increase auxiliary establishing with reference to the embodiments of the present invention Node, the implementation for aiding in terminal node, it is proposed that the following specific implementation traveled through from top to bottom.For example, with reference to Fig. 5, show the five of a kind of schematic flow sheet of concurrent analysis method provided in an embodiment of the present invention.As illustrated, the implementation Example can include:
S510, the controlling stream graph for obtaining each thread;
S511, for each thread controlling stream graph in each thread creation node it is each increase newly an immediate successor section Point, the immediate successor node are auxiliary establishing node, and the original immediate successor node of the thread creation node is changed into the line Journey creates the immediate successor node of the auxiliary establishing node increased newly in the immediate successor node of node, by the thread creation Node is designated as the direct precursor node of the start node for the thread that the thread creation node is created;
S512, the Thread Termination node for being used to terminate another thread for each in the controlling stream graph of each thread are each Increase an immediate successor node newly, the immediate successor node is auxiliary terminal node, and the Thread Termination node is original straight Connect the immediate successor that descendant node is changed to the auxiliary terminal node newly-increased in the immediate successor node of the Thread Termination node Node, the end node of the thread that the Thread Termination node is terminated be changed to the Thread Termination node it is newly-increased it is direct after After the direct precursor node of node;
The initial concurrent node set of the start node of each thread, each thread in S520, calculation procedure controlling stream graph The immediate successor node of the initial concurrent node set of the immediate successor node of establishment node and each Thread Termination node Initially can not concurrent node set, wherein, the concurrent node set of the start node of each thread, which comprises at least, to be used to create In node after the thread creation node of thread where building the start node, section that can be concurrent with the start node Point, wherein, the concurrent node set of the immediate successor node of the thread creation node comprises at least the thread creation node , can be concurrent with the immediate successor node of the thread creation node in node after the start node of the thread created Node, wherein, the immediate successor node of Thread Termination node initially can not concurrent node set to comprise at least the thread whole The whole nodes for the thread that only node is terminated;
S530, initialize described program controlling stream graph first node concurrent node set, will start to save except thread The initial concurrent node set of node outside the immediate successor node of point and thread creation node is initialized as empty set;
S540, using the first node of program control flowchart as present node;
S541, judge in the immediate successor node of present node with the presence or absence of not being calculated the straight of concurrent node set also Connect descendant node;
Present node, then be updated to by S542, if not and the present node is not the first node of program control flowchart Direct precursor node in the direct precursor node of the present node, just accessed, and return to the judgement and work as prosthomere The step of in the immediate successor node of point with the presence or absence of the immediate successor node for not being calculated concurrent node set also;
S543, if not and the present node is the first node of program control flowchart, terminates flow;
S544, if it is, access present node immediate successor node in be also calculated the direct of concurrent node set Descendant node;
S545, the node for being updated to be accessed by present node;
S546, judge whether there is a node not to be calculated concurrent node collection in the direct precursor node of present node Close and the directed edge not being calculated between the node and present node of concurrent node set is not the back edge circulated;
S547, if it is, present node is updated in the direct precursor node of the present node, has just been accessed Direct precursor node, and return in the immediate successor node of the judgement present node with the presence or absence of not being calculated also simultaneously The step of sending out the immediate successor node of node set;
S548, otherwise, judge whether present node is auxiliary terminal node;
If S549, present node are auxiliary terminal nodes, the concurrent node set of the present node, which is equal to, to be deserved What the concurrent node union of sets collection of the direct precursor node of front nodal point at least subtracted the present node initially can not concurrent node Set;
If S550, present node are not auxiliary terminal nodes, the concurrent node set of the present node is equal to should The initial concurrent node set of present node and the concurrent node union of sets collection of the direct precursor node of the present node;
S560, present node is updated in the direct precursor node of the present node, it is just accessed it is direct before Node is driven, and returns in the immediate successor node of the judgement present node whether there is and is not calculated concurrent node collection also The step of immediate successor node of conjunction.
The embodiment of the present invention shown in application drawing 5, due to entering in its ergodic process in the concurrent node set to present node Before row calculates, whether the direct precursor node of present node has been judged not by calculating concurrent node set, it may therefore be assured that Traversal from top to bottom, ensure node can not node set before the computation, its all direct precursor can be obtained The concurrent node set calculated of node, will not omit concurrent node.
Corresponding with the method that the embodiments of the present invention provide, the embodiment of the present invention additionally provides one kind and concurrently analyzed Device.Referring to Fig. 6, a kind of one of structural representation of concurrent analytical equipment is shown, as illustrated, the device can include:
Flow graph unit 610 is obtained, can be used for obtaining program control flowchart, wherein, in described program controlling stream graph, line Journey creates the direct precursor node of the start node for the thread that node is created by the thread creation node;
Initial computation unit 620, it can be used for calculating in the program control flowchart that the acquisition flow graph unit obtains each The initial concurrent node set of the start node of thread, the initial concurrent node of the immediate successor node of each thread creation node The immediate successor node of set and each Thread Termination node initially can not concurrent node set;Wherein, each line The initial concurrent node set of the start node of journey includes the thread creation node of thread where being used to create the start node In node afterwards, at least one node that can be concurrent with the start node;Wherein, the thread creation node is direct The initial concurrent node set of descendant node includes the section after the start node for the thread that the thread creation node is created In point, at least one node that can be concurrent with the immediate successor node of the thread creation node;Wherein, Thread Termination node Immediate successor node initially can not concurrent node set comprise at least the complete of the thread that is terminated of the Thread Termination node Portion's node;
Initialization unit 630, it can be used for the concurrent node set for initializing the first node of described program controlling stream graph;
Traversal Unit 640, it can be used for traveling through downwards since the first node of described program controlling stream graph, in the traversal During, according to following inheritance rules, the concurrent node set of each node traversed is calculated, wherein, it is described to inherit original Then include:If the present node traversed is not the immediate successor node of Thread Termination node, the present node and Sending out node set includes the concurrent node set of at least one direct precursor node of the present node;If present node is line Journey creates the immediate successor node of node or the start node of thread, then, the concurrent node set of the present node includes The initial concurrent node set for the present node that the initial computation unit is calculated and at least one direct precursor node Concurrent node union of sets collection;If the present node traversed is the immediate successor node of Thread Termination node, it is described The concurrent node set that the concurrent node set of present node is equal at least one direct precursor node of the present node subtracts The present node that the initial computation unit is calculated initially can not concurrent node set.
Using device provided in an embodiment of the present invention, due to obtaining in the program control flowchart acquired in flow graph unit 610, The direct precursor node of the start node for the thread that thread creation node is created by thread creation node, each single thread are spelled Connect and form complete program control flowchart, next only need to once to travel through the concurrent node collection that can calculate each node Conjunction is made that preparation;Initial computation unit 620 calculated first the start node of each thread in program control flowchart just Beginning concurrent node set, each thread creation node immediate successor node initial concurrent node set and each thread The immediate successor node of terminal node initially can not concurrent node set, it is thus possible to initialization unit 630 initialize institute After the concurrent node set for stating the first node of program control flowchart, the can of Traversal Unit 640 is from described program controlling stream graph First node start to travel through downwards, in the ergodic process, calculated according to inheritance rules traverse each node and Node set is sent out, therefore, the embodiment of the present invention, which can be traveled through once, calculates the concurrent of each node in program control flowchart Node set, computing is simple and operand is small, realizes the purpose for improving concurrent analysis efficiency.
In a kind of possible implementation of the embodiment of the present invention, the initial computation unit 620, it can be used for calculating journey The initial concurrent node set of the start node of each thread, the immediate successor section of each thread creation node in sequence controlling stream graph The immediate successor node of the initial concurrent node set of point and each Thread Termination node initially can not concurrent node collection Close, wherein:The initial concurrent node set of the start node of each thread calculated includes being used to create described to start to save In node after the thread creation node of thread where point, all nodes that can be concurrent with the start node;Calculated The initial concurrent node set of the immediate successor node of the thread creation node of each thread gone out includes the thread creation section In node after the start node of the created thread of point, it is all can be with the immediate successor node of the thread creation node Concurrent node;The immediate successor node of the Thread Termination node calculated initially can not concurrent node set include it is described Whole nodes in the thread that Thread Termination node is terminated;
The Traversal Unit 640, it can be used for traveling through downwards since the first node of described program controlling stream graph, described In ergodic process, according to following inheritance rules, the concurrent node set of each node traversed is calculated:Wherein, it is described after Holding principle includes:
If the present node traversed is not the immediate successor node of Thread Termination node, the present node Concurrent node set includes the concurrent node union of sets collection of all direct precursor nodes of the present node;
If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The initial concurrent node set of the concurrent node set of front nodal point including the present node and all direct precursor nodes and Send out the union of node set;
If the present node traversed is the immediate successor node of Thread Termination node, the present node and The concurrent node union of sets collection for all direct precursor nodes that hair node set includes the present node subtracts the present node Initially can not concurrent node set.
In the implementation, due to by it is all can not be inherited, the start node of thread it is initial concurrent Node, the initial concurrent node of the immediate successor node of thread creation node, and the immediate successor node of Thread Termination node Initially can not concurrent node, all calculated before traversal, therefore, all concurrent nodes can be in the mistake of traversal Obtained in journey by inheriting its direct precursor node, any concurrent node will not be omitted, the degree of accuracy is very high.
For example, in the implementation, above-mentioned Traversal Unit 640 can have following two possible implementations:
One kind is, if only including using in the initial concurrent node set of the start node of each thread calculated , can be concurrent with the start node in the node after the thread creation node of thread where creating the start node Node;And only include in the initial concurrent node set of the immediate successor node of each thread creation node calculated , can be straight with the thread creation node in node after the start node for the thread that the thread creation node is created Connect the concurrent node of descendant node;
Then, the Traversal Unit 640 can be used for traveling through downwards since the first node of described program controlling stream graph, in institute State in ergodic process, calculate the concurrent node set of each node traversed, wherein:If the present node traversed is not Immediate successor node, the immediate successor node of thread creation node and the start node of thread of Thread Termination node, then, The concurrent node set of the present node is equal to the concurrent node union of sets of all direct precursor nodes of the present node Collection;If present node is the immediate successor node of thread creation node or the start node of thread, the present node Concurrent node set be equal to the initial concurrent node set of the present node that the initial computation unit is calculated with should The concurrent node union of sets collection of all direct precursor nodes of present node;If the present node traversed is Thread Termination The immediate successor node of node, then, the concurrent node set of the present node are equal to all direct precursors of the present node The concurrent node union of sets collection of node at least subtracts the initial nothing for the present node that the initial computation unit is calculated Method concurrent node set.
In the implementation, concurrently saved because initial computation unit 620 only calculates the initial of the start node of thread Point set, thread creation node immediate successor node initial concurrent node set in the part that should at least include, subsequently exist Concurrent node set during traversal by inheriting its direct precursor node is supplemented, and amount of calculation is small, and efficiency is higher.
Another kind is, if present node is the immediate successor node or start node of thread creation node, and currently The initial concurrent node set of node has included the present node all concurrent nodes in program control flowchart;
Then, the Traversal Unit 640 is used to travel through downwards since the first node of described program controlling stream graph, at described time During going through, the concurrent node set of each node traversed is calculated, wherein:If the present node traversed is not thread Immediate successor node, the immediate successor node of thread creation node and the start node of thread of terminal node, then it is, described The concurrent node set of present node is equal to the concurrent node union of sets collection of all direct precursor nodes of the present node;Such as Fruit present node is the immediate successor node of thread creation node or the start node of thread, then, the present node and Hair node set is equal to the initial concurrent node set for the present node that the initial computation unit is calculated;If traversal To present node be Thread Termination node immediate successor node, then, the concurrent node set of the present node is equal to should The concurrent node union of sets collection of all direct precursor nodes of present node at least subtracts the initial computation unit and calculated The present node arrived initially can not concurrent node set.
It should be noted that in embodiments of the present invention, the initial nothing of the immediate successor node of the Thread Termination node The set of method concurrent node includes at least one node in the thread that the Thread Termination node is terminated, therefore, the thread The immediate successor node of terminal node initially can not concurrent node set can include whole program control flowchart in the range of institute Have with the immediate successor node of the Thread Termination node can not be concurrent node set, can also only include the Thread Termination section Whole nodes of the terminated thread of point, or other embodiment, in the present invention and are not limited.Below, to described The immediate successor node of Thread Termination node initially can not concurrent node set only terminated including the Thread Termination node The embodiment of whole nodes of thread describe in detail:
The Thread Termination node immediate successor node initially can not concurrent node set only include the thread In the embodiment of the whole nodes for the thread that terminal node is terminated, a kind of optional mode is passed through during traversal Inherit its direct precursor node can not concurrent node set supplemented.Specifically, for example, wherein:
The initial computation unit 620, it can be used for the initial nothing of immediate successor node for calculating Thread Termination node Method concurrent node set, wherein, the immediate successor node of the Thread Termination node calculated initially can not concurrent node In set, whole nodes of the thread only terminated including the Thread Termination node;
In addition, the initial computation unit 620, initially can not concurrently save according to the start node of thread can be also used for The start node of thread is to the reachable road of the thread creation node where point set is equal to the thread creation node for creating the thread Node set on footpath, calculate each thread start node initially can not concurrent node set;
The initialization unit 630, can be also used for initialize described program controlling stream graph first node can not be concurrent Node set;
The Traversal Unit 640, can be also used for calculate traverse each node can not concurrent node set, its In:If the present node traversed is the start node of thread, or the immediate successor node of Thread Termination node, then, When the direct precursor node of the present node is only one, the present node can not concurrent node set be equal to deserve The direct precursor node of front nodal point can not the present node that is calculated of concurrent node set and the initial computation unit Initially can not concurrent node union of sets collection, when the present node direct precursor node for it is multiple when, it is described to work as prosthomere Point can not concurrent node set be equal to all direct precursor nodes of the present node can not concurrent node intersection of sets collection, with The present node that the initial computation unit is calculated initially can not concurrent node union of sets collection;If traverse Present node is the node in addition to the start node of thread and the immediate successor node of Thread Termination node, then, when described When the direct precursor node of present node is only one, the present node can not concurrent node set be equal to the present node Direct precursor node can not concurrent node set, when the direct precursor node of the present node is only multiple, deserve Front nodal point can not concurrent node set be equal to the present node all direct precursor nodes can not concurrent node set Occur simultaneously.
It should be noted that if present node is the immediate successor node of Thread Termination node, present node is calculated Can not concurrent node set the step of must before concurrent node set is calculated so that it is that present node is calculated and Necessarily eliminated due to can not concurrent node caused by Thread Termination in hair node set.For straight except Thread Termination node Connect the node beyond descendant node, calculate can not the order of concurrent node set and calculating concurrent node set can exchange, no Influence the result of calculating concurrent node set.In addition, calculate initial concurrent node set, initially can not concurrent node set or Initialize the concurrent node set of first node and also can not must comply between each step of concurrent node set Sequentially, any exchange can be carried out.Moreover, the traversal of the embodiment of the present invention, it should it is traversal from top to bottom, so that The concurrent node set of one node or can not concurrent node set be able to concurrent node set in its direct precursor node Calculated in the case of having calculated.
It can be seen that the embodiment of the present invention shown in application drawing 7, described for the immediate successor node of Thread Termination node The immediate successor node of Thread Termination node initially can not only include the Thread Termination node in concurrent node set Whole nodes of the thread terminated, can be according to the initial nothing of the start node of thread for the start node of thread The start node of thread is to the thread creation node where the set of method concurrent node is equal to the thread creation node for creating the thread Reachable path on node set, calculate each thread start node initially can not concurrent node set, Jin Er During traversal, then to its can not concurrent node supplement, it is all in the range of whole program control flowchart with calculating Can not concurrent node compare, reduce amount of calculation to a certain extent, improve efficiency.Moreover, calculated in ergodic process every Individual node can not concurrent node set when, it is also contemplated that if the direct precursor node of present node has multiple, due to journey Sequence actually once performs and typically only carries out one of them possible branch, can't perform whole, take present node it is direct before Drive node can not concurrent node intersection of sets collection add to can not ensureing to be obtained in concurrent node set for present node It is current its can not concurrent node set reach minimal set, the node one for being possible to concurrent is established a capital and will be retained in it and concurrently save In point set, to the relevant treatment of node that may be concurrent after being advantageous to, concurrent node will not be omitted.
Furthermore, it is contemplated that in program control flowchart, the immediate successor node of a thread creation node may be it is multiple, one The immediate successor node of individual Thread Termination node may also be multiple, in order to reduce amount of calculation, improve efficiency, the embodiment of the present invention In a kind of possible implementation, an auxiliary establishing section is inserted between a thread creation node directly descendant node Point, an auxiliary terminal node is inserted between a Thread Termination node directly descendant node, thread is directed to reduce Create the amount of calculation of the immediate successor node of node and the immediate successor node for Thread Termination node.Specifically, example Such as, based on above-mentioned embodiment illustrated in fig. 6, a kind of structure of concurrent analytical equipment provided in an embodiment of the present invention as shown in Figure 7 The three of schematic diagram:The acquisition flow graph unit 610 can include obtaining flow graph subelement 710a, and auxiliary establishing node increase is single First 710b, auxiliary terminal node increase subelement 710c;
Wherein, the acquisition flow graph subelement 710a, can be used for the controlling stream graph for obtaining each thread;
The auxiliary establishing node increases subelement 710b, can be used for every in the controlling stream graph for each thread Individual thread creation node is each to increase an immediate successor node newly, and the immediate successor node is auxiliary establishing node, by the thread Create the auxiliary wound that the original immediate successor node of node is changed to increase newly in the immediate successor node of the thread creation node The immediate successor node of node is built, the thread creation node is designated as into thread that the thread creation node created starts to save The direct precursor node of point;
The auxiliary terminal node increase subelement 710c, can be used for every in the controlling stream graph for each thread The individual each newly-increased immediate successor node of Thread Termination node for being used to terminate another thread, the immediate successor node are whole for auxiliary Only node, the original immediate successor node of the Thread Termination node is changed in the immediate successor node of the Thread Termination node The immediate successor node of the newly-increased auxiliary terminal node, the end node for the thread that the Thread Termination node is terminated It is changed to the direct precursor node of the newly-increased immediate successor node of the Thread Termination node.
Correspondingly, the initial computation unit 620, it can be used for each thread in calculation procedure controlling stream graph and start to save The initial concurrent node set of point, the initial concurrent node set of each auxiliary establishing node, meter in calculation procedure controlling stream graph Each auxiliary terminal node initially can not concurrent node set in calculation program control flowchart;The Traversal Unit 640, Ke Yiyong Traveled through downwards in the first node since described program controlling stream graph, in the ergodic process, calculate each section traversed The concurrent node set of point, wherein:If the present node traversed is not auxiliary terminal node, the present node Concurrent node set comprises at least the concurrent node union of sets collection of all direct precursor nodes of the present node;If traversal To present node be auxiliary establishing node or thread start node, then, the concurrent node collection of the present node is bonded to Include the initial concurrent node set for the present node that the initial computation unit is calculated less;If what is traversed is current Node is auxiliary terminal node, then, the concurrent node set of the present node is equal to all direct precursors of the present node The concurrent node union of sets collection of node at least subtracts the initial nothing for the present node that the initial computation unit is calculated Method concurrent node set.
It can be seen that method provided in an embodiment of the present invention shown in application drawing 7, because increase auxiliary establishing node and auxiliary are whole Only node, for a thread creation node, can by originally may be directed to the thread creation node it is multiple directly after Calculating after node turns to calculating for an auxiliary establishing node, can be by original for a Thread Termination node The calculating of this multiple immediate successor node that may be directed to Thread Termination node turns to the calculating for an auxiliary terminal node, So as to reduce amount of calculation, efficiency is improved.
It should be noted that in the embodiment of the present invention as shown in Figure 7, the initial concurrent node collection of start node is calculated The specific implementation of conjunction is unlimited.A kind of possible implementation is given below, for example, as shown in figure 8, the initial calculation list Member 620 can include First partial computation subunit 820a, the first concurrent subelement 820b;
Wherein, First partial computation subunit 820a, it is right for each generation one of start node of each thread to can be used for The Partial controll set answered, wherein, the Partial controll set include start node corresponding with the Partial controll set, with And in the range of whole program control flowchart, all first nodes controlled by corresponding start node, wherein, it is described to be corresponded to The first node of start node control refer to must into the path of first node itself since program control flowchart first node Must be by the node of the corresponding start node;
The first concurrent subelement 820b, can be used for the start node for each thread, perform respectively with The first concurrent node calculation procedure is descended to calculate the initial concurrent node set of the start node of each thread, wherein, it is described First concurrent node calculation procedure includes:Calculate after corresponding auxiliary establishing node, with the corresponding auxiliary establishing section Point has the 3rd node set of reachable path, wherein, the corresponding auxiliary establishing node starts to save for targeted thread Auxiliary establishing node in the immediate successor node of the direct precursor node of point, according to the first of the start node of targeted thread Beginning concurrent node set is equal to the start node that the 3rd node set subtracts the First partial computation subunit generation Corresponding Partial controll set, calculate the initial concurrent node set of the start node of targeted thread.
It should be noted that wherein, the specific generating mode of Partial controll set corresponding to the start node is unlimited, In a kind of possible implementation of the embodiment of the present invention, can precompute each start node where it in thread by it The set of the node of control, i.e., each start node is corresponding in thread where it respectively to terminate control set, further according to line The termination control set of the auxiliary terminal node formed between journey and thread due to termination relation is started the control of node control Relation, the termination control set for aiding in terminal node is delivered in the termination control set of start node, and then may finally Obtain complete Partial controll set corresponding to each start node, due in the implementation, for start node and The calculating of termination control set of the terminal node in single thread is aided in, therefore, can be carried out respectively serial or parallel Calculate, then be delivered in the Partial controll set of start node, can reach and put forward efficient purpose, specifically, for example, described First partial computation subunit 820a can include first it is initial terminate subelement 820a.1, first add subelement 820a.2, First initial local subelement 820a.3, second adds subelement 820a.4;
Wherein, the described first initial termination subelement 820a.1, can be used for respectively initializing for each auxiliary terminal node Control set is terminated corresponding to one, wherein, will auxiliary terminal node and aid in where terminal node in thread, it is auxiliary The node for helping terminal node to control adds the termination control set of the auxiliary terminal node;
Described first adds subelement 820a.2, can be used for every for being obtained from the described first initial termination subelement Control set is terminated corresponding to individual auxiliary terminal node, respectively enters the first addition step, the first addition step includes:Sentence Whether include the end node of thread in disconnected targeted termination control set, if it is, judging corresponding to the end node Aid in terminal node termination control set whether non-NULL, if non-NULL, terminal node will be aided in corresponding to the end node Terminate control set and add targeted termination control set, and judge whether targeted termination control set has what is newly added End node, if what is newly added, using the end node of the new addition as object is judged, return to described judgement knot The termination control set of auxiliary terminal node corresponding to Shu Jiedian whether non-NULL the step of, if without what is newly added, terminate described First adds step;
The first initial local subelement 820a.3, it can be used for respectively initializing one for the start node of each thread Corresponding Partial controll set, opened by the start node of each thread, and all in thread where the start node by this The node of beginning node control is added in corresponding Partial controll set;
Described second adds subelement 820a.4, can be used for every for being obtained from the first initial local subelement Partial controll set corresponding to the start node of individual thread, respectively enters the second addition step, and the second addition step includes: Judge whether include the end node of thread in targeted Partial controll set, if it is, judging that described first adds son The termination control set of auxiliary terminal node corresponding to the end node that unit is calculated whether non-NULL, will if non-NULL Control set is terminated corresponding to the end node and adds the targeted Partial controll set, and judges targeted local controlled Whether system set has the end node newly added, if what is newly added, using the end node of the new addition as judgement pair As, return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, such as Fruit terminates described second and adds step without what is newly added.
It should be noted that in embodiments of the present invention, each auxiliary establishing node is first in calculation procedure controlling stream graph The beginning specific implementation of concurrent node set is unlimited.A kind of possible implementation is given below:With above-mentioned opening for thread Beginning node calculates the principle of initial concurrent node set similarly, and the initial computation unit 620 can include the second local meter Operator unit 820c, the second concurrent subelement 820d;
Wherein, the described second local computation subunit 820c, can be used for for the respectively generation one of each auxiliary establishing node Corresponding Partial controll set, wherein, the Partial controll set includes auxiliary establishing corresponding with the Partial controll set Node and in the range of whole program control flowchart, all section points by corresponding auxiliary establishing node control, its In, the section point by corresponding auxiliary establishing node control refers to since program control flowchart first node to the second section The node of the corresponding auxiliary establishing node is had to pass through in the point path of itself;
It the second concurrent subelement 820d, can be used for being directed to each auxiliary establishing node, perform respectively following Second concurrent node calculation procedure to calculate the initial concurrent node set of each auxiliary establishing node, wherein, described second Concurrent node calculation procedure includes:Calculating has reachable path after corresponding start node, with the corresponding start node Fourth node set, wherein, it is described corresponding to start node for targeted auxiliary establishing node direct precursor node Start node in immediate successor node, it is equal to described the according to the initial concurrent node set of targeted auxiliary establishing node Four node sets subtract Partial controll set corresponding to the auxiliary establishing node of the described second local computation subunit generation, meter Calculate the initial concurrent node set of targeted auxiliary establishing node.
Wherein, the specific generating mode of Partial controll set is unlimited corresponding to the auxiliary establishing node, of the invention real Apply in a kind of possible implementation of example, identical principle is calculated based on the Partial controll set with above-mentioned start node, specifically Ground, such as:The second local computation subunit 820c can include the second initial termination subelement 820c.1, the 3rd addition Unit 820c.2, the second initial local subelement 820c.3, the 4th adds subelement 820c.4;
Wherein, the described second initial termination subelement 820c.1, can be used for respectively initializing for each auxiliary terminal node Control set is terminated corresponding to one, wherein, will auxiliary terminal node and aid in where terminal node in thread, it is auxiliary The node for helping terminal node to control adds the termination control set of the auxiliary terminal node;
Described 3rd adds subelement 820c.2, can be used for every for being obtained from the described second initial termination subelement Control set is terminated corresponding to individual auxiliary terminal node, respectively enters the first addition step, the first addition step includes:Sentence Whether include the end node of thread in disconnected targeted termination control set, if it is, judging corresponding to the end node Aid in terminal node termination control set whether non-NULL, if non-NULL, terminal node will be aided in corresponding to the end node Terminate control set and add targeted termination control set, and judge whether targeted termination control set has what is newly added End node, if what is newly added, using the end node of the new addition as object is judged, return to described judgement knot The termination control set of auxiliary terminal node corresponding to Shu Jiedian whether non-NULL the step of, if without what is newly added, terminate described First adds step;
The second initial local subelement 820c.3, can be used for for each auxiliary establishing node respectively initialization one it is right The Partial controll set answered, by each auxiliary establishing node, and where the auxiliary establishing node in thread it is all auxiliary by this The node for creating node control is helped to be added in corresponding Partial controll set;
Described 4th adds subelement 820c.4, can be used for every for being obtained from the second initial local subelement Partial controll set corresponding to individual auxiliary establishing node, respectively enter described second and add step, described second adds step bag Include:Judge whether include the end node of thread in targeted Partial controll set, if it is, judging that the described 3rd adds The termination control set of auxiliary terminal node corresponding to the end node that subelement is calculated whether non-NULL, if non-NULL, Control set will be terminated corresponding to the end node and adds the targeted Partial controll set, and judges targeted part Whether control set has the end node newly added, if what is newly added, using the end node of the new addition as judgement Object, return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, If without what is newly added, terminate described second and add step.
In the embodiment of the present invention in another possible implementation, increase auxiliary establishing with reference to the embodiments of the present invention Node, the implementation for aiding in terminal node, it is proposed that the following specific implementation traveled through from top to bottom.For example, it is based on Above-mentioned embodiment illustrated in fig. 7, referring to Fig. 9, show a kind of structural representation of concurrent analytical equipment provided in an embodiment of the present invention The four of figure.As illustrated, in the embodiment, obtaining flow graph unit 610 can include obtaining flow graph subelement 710a, auxiliary establishing Node increases subelement 710b, auxiliary terminal node increase subelement 710c;In detail reference can be made to Jie of above-mentioned embodiment illustrated in fig. 7 Continue, will not be repeated here.
The initial computation unit 620, it can be also used for before the traversal starts, by except the start node of thread And the initial concurrent node set of the node outside the immediate successor node of thread creation node is initialized as empty set;
The Traversal Unit 640 can include first node and set subelement 940a, the first judgment sub-unit 940b, first to return Subelement 940c is returned, terminates subelement 940d, access subelement 940e, node updates subelement 940f, the second judgment sub-unit 940g, second return to subelement 940h, the 3rd judgment sub-unit 940i, the first traversal computation subunit 940j, the second traversal meter Operator unit 940k;
Wherein, the first node sets subelement 940a, can be used for using the first node of program control flowchart as current Node;
The first judgment sub-unit 940b, it can be used for judging in the immediate successor node of present node with the presence or absence of also The immediate successor node of concurrent node set is not calculated;
Described first returns to subelement 940c, can be used for first judgment sub-unit and is judged as NO and described works as prosthomere When point is not the first node of program control flowchart, present node is updated in the direct precursor node of the present node, just Just accessed direct precursor node, and the first judgment sub-unit 940b described in retriggered;
The end subelement 940d, can be used for that first judgment sub-unit is judged as NO and the present node is During the first node of program control flowchart, terminate flow;
The access subelement 940e, when can be used for first judgment sub-unit and being judged as YES, access present node Immediate successor node in be not calculated the immediate successor node of concurrent node set also;
The node updates subelement 940f, it can be used for the immediate successor section that present node is accessed in the access unit When not being calculated the immediate successor node of concurrent node set in point also, section that present node is updated to be accessed Point;
The second judgment sub-unit 940g, it can be used for after the node updates subelement updates, prosthomere is worked as in judgement Whether have that a node is not calculated concurrent node set and this is not calculated and concurrently saved in the direct precursor node of point Directed edge between the node and present node of point set is not the back edge of circulation;
Described second returns to subelement 940h, when can be used for second judgment sub-unit and being judged as YES, will work as prosthomere Point is updated in the direct precursor node of the present node, just accessed direct precursor node, and described in retriggered First judgment sub-unit 940b;
The 3rd judgment sub-unit 940i, when can be used for second judgment sub-unit and being judged as NO, judge current Whether node is auxiliary terminal node;
The first traversal computation subunit 940j, when can be used for the 3rd judgment sub-unit and being judged as YES, then, and meter The concurrent node set of the present node is calculated, wherein, the concurrent node set of the present node is equal to the present node The concurrent node union of sets collection of direct precursor node at least subtract the present node initially can not concurrent node set, ought Front nodal point is updated in the direct precursor node of the present node, just accessed direct precursor node, and retriggered The first judgment sub-unit 940b;
The second traversal computation subunit 940k, when can be used for the 3rd judgment sub-unit and being judged as NO, then, and meter The concurrent node set of the present node is calculated, wherein, the concurrent node set of the present node is equal to the present node Initial concurrent node set and the concurrent node union of sets collection of the direct precursor node of the present node, present node is updated For the direct precursor node in the direct precursor node of the present node, just accessed, and first sentence described in retriggered Disconnected subelement 940b.
The embodiment of the present invention shown in application drawing 9, due to entering in its ergodic process in the concurrent node set to present node Before row calculates, whether the direct precursor node of present node has been judged not by calculating concurrent node set, it may therefore be assured that Traversal from top to bottom, ensure node can not node set before the computation, its all direct precursor can be obtained The concurrent node set calculated of node, will not omit concurrent node.
Further, the embodiment of the present invention also provides a kind of hardware composition of terminal.
At least one network interface or other communication interfaces, memory, and at least one communication bus, for realizing this Connection communication between a little devices.Processor is used to perform the executable module stored in memory, such as computer program.Deposit Reservoir may include high-speed random access memory(RAM:Random Access Memory), it is also possible to also including non-unstable Memory(non-volatile memory), a for example, at least magnetic disk storage.
In some embodiments, programmed instruction is stored in memory, programmed instruction can be executed by processor, its In, programmed instruction is used to perform the method described in the embodiment of the present invention, such as:It can include:
Program control flowchart is obtained, wherein, in described program controlling stream graph, thread creation node is the thread creation section The direct precursor node of the start node of the created thread of point;
The initial concurrent node set of the start node of each thread, each thread creation section in calculation procedure controlling stream graph The initial nothing of the immediate successor node of the initial concurrent node set of the immediate successor node of point and each Thread Termination node Method concurrent node set, wherein, the initial concurrent node set of the start node of each thread is including described for creating In node after the thread creation node of thread where start node, at least one section that can be concurrent with the start node Point, wherein, the initial concurrent node set of the immediate successor node of the thread creation node includes the thread creation node In node after the start node of the thread created, it is at least one can be with the immediate successor section of the thread creation node The concurrent node of point, wherein, the immediate successor node of Thread Termination node initially can not concurrent node set include the line At least one node in the thread that journey terminal node is terminated;
The concurrent node set of the first node of described program controlling stream graph is initialized, from the head sections of described program controlling stream graph Point starts traversal downwards, in the ergodic process, according to following inheritance rules, calculates the concurrent of each node for traversing Node set:
Wherein, the inheritance principles include:If the present node traversed is not the immediate successor of Thread Termination node Node, then, the concurrent node set of the present node include the concurrent of at least one direct precursor node of the present node Node set;If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as The concurrent node set of front nodal point includes the initial concurrent node set of the present node and at least one direct precursor node Concurrent node union of sets collection;If the present node traversed is the immediate successor node of Thread Termination node, it is described The concurrent node set that the concurrent node set of present node is equal at least one direct precursor node of the present node subtracts The present node initially can not concurrent node set
It is understood that the method for the embodiment of the present invention that described program instruction performs can include each reality described herein Other implementations of the method described in example and the method based on the embodiment of the present invention are applied, are repeated no more here.
As seen through the above description of the embodiments, those skilled in the art can be understood that above-mentioned implementation All or part of step in example method can add the mode of required general hardware platform to realize by software.Based on such Understand, the part that technical scheme substantially contributes to prior art in other words can be in the form of software product Embody, the computer software product can be stored in storage medium, such as ROM/RAM, magnetic disc, CD, including some Instruct to cause a computer equipment(Can be the network services such as personal computer, server, or WMG Equipment, etc.)Perform the method described in some parts of each embodiment of the present invention or embodiment.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment it Between identical similar part mutually referring to what each embodiment stressed is the difference with other embodiment. For device embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, correlation Place illustrates referring to the part of embodiment of the method.Device embodiment described above is only schematical, wherein conduct The unit that separating component illustrates can be or may not be it is physically separate, can be as the part that unit is shown or Person may not be physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can root Factually border needs to select some or all of module therein realize the purpose of this embodiment scheme.Ordinary skill Personnel are without creative efforts, you can to understand and implement.
Moreover, herein, such as first and second or the like relational terms are used merely to an entity or behaviour Make with another entity or operation make a distinction, and not necessarily require or imply these entities or operate between exist it is any this Kind actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to nonexcludability Include so that process, method, article or equipment including a series of elements not only include those key elements, but also Including the other element being not expressly set out, or also include for this process, method, article or equipment intrinsic want Element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that wanted including described Other identical element also be present in the process of element, method, article or equipment.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent substitution and improvements made within the spirit and principles in the present invention etc., are all contained in protection scope of the present invention It is interior.

Claims (20)

  1. A kind of 1. concurrent analysis method, it is characterised in that including:
    Program control flowchart is obtained, wherein, in described program controlling stream graph, thread creation node is the thread creation node The direct precursor node of the start node of the thread created;
    Calculate the initial concurrent node set of the start node of each thread in described program controlling stream graph, each thread wound Build the initial concurrent node set of the immediate successor node of node and the immediate successor node of each Thread Termination node just Beginning can not concurrent node set;Wherein, the initial concurrent node set of the start node of each thread includes being used to create In node after the thread creation node of thread where the start node, it is at least one can be concurrent with the start node Node;Wherein, the initial concurrent node set of the immediate successor node of the thread creation node includes the thread creation In node after the start node for the thread that node is created, it is at least one can with the thread creation node it is direct after After the concurrent node of node;Wherein, the immediate successor node of the Thread Termination node initially can not concurrent node collection be bonded to Include the whole nodes for the thread that the Thread Termination node is terminated less;
    The concurrent node set of the first node of described program controlling stream graph is initialized, is opened from the first node of described program controlling stream graph Begin traversal downwards, in the ergodic process, according to following inheritance rules, calculates the concurrent node of each node traversed Set:
    Wherein, the inheritance rules include:
    If the present node traversed is not the immediate successor node of Thread Termination node, the present node it is concurrent Node set includes the concurrent node set of at least one direct precursor node of the present node;If present node is thread The immediate successor node of node or the start node of thread are created, then, the concurrent node set of the present node includes institute State the initial concurrent node set of present node and the concurrent node union of sets collection of at least one direct precursor node;If time The present node gone through is the immediate successor node of Thread Termination node, then, the concurrent node set of the present node is equal to The concurrent node set of at least one direct precursor node of the present node subtracts initially can not concurrently saving for the present node Point set.
  2. 2. according to the method for claim 1, it is characterised in that the initial concurrent node of the start node of each thread Set is included in the node after the thread creation node of thread where being used to create the start node, it is all can with it is described The concurrent node of start node;
    The initial concurrent node set of the immediate successor node of the thread creation node is created including the thread creation node In node after the start node for the thread built, it is all can be concurrent with the immediate successor node of the thread creation node Node;
    If the present node traversed is not the immediate successor node of Thread Termination node, the present node it is concurrent Node set includes the concurrent node union of sets collection of all direct precursor nodes of the present node;
    If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as prosthomere The concurrent node set of point includes the initial concurrent node set of the present node and the concurrently section of all direct precursor nodes The union of point set;
    If the present node traversed is the immediate successor node of Thread Termination node, the concurrently section of the present node The concurrent node union of sets collection that point set includes all direct precursor nodes of the present node subtracts the first of the present node Beginning can not concurrent node set.
  3. 3. according to the method for claim 2, it is characterised in that the initial concurrent node of the start node of each thread Only include in set in the node after the thread creation node of thread where being used to create the start node, it is all can be with The concurrent node of the start node;
    Only include the thread creation in the initial concurrent node set of the immediate successor node of each thread creation node In node after the start node for the thread that node is created, it is all can be with the immediate successor section of the thread creation node The concurrent node of point;
    If the present node traversed is not the immediate successor node of Thread Termination node, the immediate successor of thread creation node The start node of node and thread, then, the concurrent node set of the present node are equal to all direct of the present node The concurrent node union of sets collection of predecessor node;
    If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as prosthomere The concurrent node set of point is equal to the initial concurrent node set of the present node and all direct precursors of the present node The concurrent node union of sets collection of node;
    If the present node traversed is the immediate successor node of Thread Termination node, the concurrently section of the present node The concurrent node union of sets collection that point set is equal to all direct precursor nodes of the present node at least subtracts the present node Initially can not concurrent node set.
  4. 4. according to the method for claim 2, it is characterised in that the immediate successor node of the Thread Termination node it is initial Can not be in concurrent node set, whole nodes of the thread only terminated including the Thread Termination node;
    Before the traversal starts, in addition to:
    According to the start node of thread initially can not concurrent node set be equal to create the thread thread creation node where Node set on the start node of thread to the reachable path of the thread creation node, calculate the start node of each thread Initially can not concurrent node set;
    Initialize described program controlling stream graph first node can not concurrent node set;
    In the ergodic process, in addition to:Calculate traverse each node can not concurrent node set, wherein:
    If the present node traversed is the start node of thread, or the immediate successor node of Thread Termination node, then, When the direct precursor node of the present node is only one, the present node can not concurrent node set be equal to deserve The direct precursor node of front nodal point can not concurrent node set and the present node initially can not concurrent node union of sets Collection, when the present node direct precursor node for it is multiple when, the present node can not concurrent node set be equal to should All direct precursor nodes of present node can not concurrent node intersection of sets collection, with the present node initially can not be concurrent The union of node set;
    If the present node traversed is in addition to the start node of thread and the immediate successor node of Thread Termination node Node, then, and when the direct precursor node of the present node is only one, the present node can not concurrent node collection Close equal to the present node direct precursor node can not concurrent node set, when the direct precursor node of the present node When only multiple, the present node can not concurrent node set be equal to the present node all direct precursor nodes can not Concurrent node intersection of sets collection.
  5. 5. according to the method for claim 2, it is characterised in that after the acquisition program control flowchart, in addition to:
    Obtain program control flowchart;
    An immediate successor node, the immediate successor section are increased newly for each thread creation node in described program controlling stream graph is each Point is auxiliary establishing node, and the original immediate successor node of the thread creation node is changed into the direct of the thread creation node The immediate successor node of the auxiliary establishing node increased newly in descendant node, the thread creation node is designated as thread wound Build the direct precursor node of the start node for the thread that node is created;
    After one being increased newly for each Thread Termination node for terminating another thread in described program controlling stream graph is each directly After node, the immediate successor node is auxiliary terminal node, and the original immediate successor node of the Thread Termination node is changed to The immediate successor node of the auxiliary terminal node increased newly in the immediate successor node of the Thread Termination node, by the thread The end node for the thread that terminal node is terminated be changed to the newly-increased immediate successor node of the Thread Termination node it is direct before Drive node;
    The initial concurrent node set tool of the immediate successor node of each thread creation node in the calculation procedure controlling stream graph Body is the initial concurrent node set of each auxiliary establishing node in calculation procedure controlling stream graph;
    The immediate successor node of each Thread Termination node initially can not concurrent node collection in the calculation procedure controlling stream graph Each auxiliary terminal node initially can not concurrent node set in conjunction specially calculation procedure controlling stream graph.
  6. 6. according to the method for claim 5, it is characterised in that described to calculate opening for each thread in program control flowchart The initial concurrent node set of beginning node includes:
    A corresponding Partial controll set is respectively generated for the start node of each thread, wherein, in the Partial controll set It is all corresponding including start node corresponding with the Partial controll set and in the range of whole program control flowchart The first node of start node control, wherein, the first node controlled by corresponding start node refers to from programme-control Flow graph first node starts into the path of first node itself to have to pass through the node of the corresponding start node;
    For the start node of each thread, following first concurrent node calculation procedure is performed respectively to calculate each thread The initial concurrent node set of start node, wherein, the first concurrent node calculation procedure includes:Calculate in corresponding auxiliary There is the 3rd node set of reachable path after establishment node, with the corresponding auxiliary establishing node, wherein, it is described corresponding Auxiliary establishing node is the auxiliary establishing in the immediate successor node of the direct precursor node of the start node of targeted thread Node, this is subtracted equal to the 3rd node set according to the initial concurrent node set of the start node of targeted thread and opened Partial controll set corresponding to beginning node, calculate the initial concurrent node set of the start node of targeted thread.
  7. 7. according to the method for claim 6, it is characterised in that the start node for each thread respectively generates an office Portion's control set includes:
    For it is each auxiliary terminal node respectively initialization one corresponding to terminate control set, wherein, will auxiliary terminal node and Controlled in the termination for aiding in adding the auxiliary terminal node where terminal node in thread, by the node that auxiliary terminal node controls Set;
    For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd, described first adds Step includes:Judge whether include the end node of thread in targeted termination control set, if it is, judging that this terminates The termination control set of auxiliary terminal node corresponding to node whether non-NULL, will auxiliary corresponding to the end node if non-NULL The termination control set of terminal node adds targeted termination control set, wherein, auxiliary corresponding to the end node is eventually Only node is the auxiliary terminal node in the immediate successor node for the Thread Termination node of thread where terminating the end node Point, judges whether targeted termination control set has the end node newly added, if what is newly added, by the new addition End node as judging object, return to the termination domination set that terminal node is aided in corresponding to described judgement end node Close whether non-NULL the step of, if without what is newly added, terminate it is described first add step;
    A corresponding Partial controll set is respectively initialized for the start node of each thread, by the start node of each thread, And where the start node in thread all nodes controlled by the start node be added to corresponding to Partial controll set In;
    For Partial controll set corresponding to the start node of each thread, the second addition step is respectively enterd, described second chases after Step is added to include:Judge whether include the end node of thread in targeted Partial controll set, if it is, judging the knot The termination control set of auxiliary terminal node corresponding to Shu Jiedian whether non-NULL, will be corresponding to the end node eventually if non-NULL Only control set adds the targeted Partial controll set, and judges whether targeted Partial controll set has new addition End node, if what is newly added, using the end node of the new addition as object is judged, return to the judgement should The termination control set of auxiliary terminal node corresponding to end node whether non-NULL the step of, if without what is newly added, terminate institute State the second addition step.
  8. 8. according to the method for claim 5, it is characterised in that described to calculate each thread creation in program control flowchart The initial concurrent node set of the immediate successor node of node includes:
    A corresponding Partial controll set is respectively generated for each auxiliary establishing node, wherein, wrapped in the Partial controll set Include auxiliary establishing node corresponding with the Partial controll set and in the range of whole program control flowchart, it is all to be corresponded to Auxiliary establishing node control section point, wherein, the section point by corresponding auxiliary establishing node control refers to The corresponding auxiliary establishing node is had to pass through into the path of section point itself since program control flowchart first node Node;
    For each auxiliary establishing node, following second concurrent node calculation procedure is performed respectively to calculate each auxiliary establishing The initial concurrent node set of node, wherein, the second concurrent node calculation procedure includes:Calculate in corresponding start node Afterwards, there is the fourth node set of reachable path with the corresponding start node, wherein, the corresponding start node is institute For auxiliary establishing node direct precursor node immediate successor node in start node, created according to targeted auxiliary The initial concurrent node set for building node subtracts Partial controll corresponding to the auxiliary establishing node equal to the fourth node set Set, calculates the initial concurrent node set of targeted auxiliary establishing node.
  9. 9. according to the method for claim 8, it is characterised in that described respectively to generate a correspondence for each auxiliary establishing node Partial controll set include:
    For it is each auxiliary terminal node respectively initialization one corresponding to terminate control set, wherein, will auxiliary terminal node and Controlled in the termination for aiding in adding the auxiliary terminal node where terminal node in thread, by the node that auxiliary terminal node controls Set;
    For terminating control set corresponding to each auxiliary terminal node, the first addition step is respectively enterd, described first adds Step includes:Judge whether include the end node of thread in targeted termination control set, if it is, judging that this terminates The termination control set of auxiliary terminal node corresponding to node whether non-NULL, will auxiliary corresponding to the end node if non-NULL The termination control set of terminal node adds targeted termination control set, wherein, auxiliary corresponding to the end node is eventually Only node is the auxiliary terminal node in the immediate successor node for the Thread Termination node of thread where terminating the end node Point, judges whether targeted termination control set has the end node newly added, if what is newly added, by the new addition End node as judging object, return to the termination domination set that terminal node is aided in corresponding to described judgement end node Close whether non-NULL the step of, if without what is newly added, terminate it is described first add step;
    A corresponding Partial controll set is respectively initialized for each auxiliary establishing node, by each auxiliary establishing node, and All nodes by the auxiliary establishing node control are added to corresponding Partial controll in thread where the auxiliary establishing node In set;
    For Partial controll set corresponding to each auxiliary establishing node, the second addition step is respectively enterd, described second adds Step includes:Judge whether include the end node of thread in targeted Partial controll set, if it is, judging that this terminates The termination control set of auxiliary terminal node corresponding to node whether non-NULL, will termination corresponding to the end node if non-NULL Control set adds the targeted Partial controll set, judges whether targeted Partial controll set has the knot newly added Shu Jiedian, if the end node newly added, using the end node of the new addition as object is judged, return to and described sentence The termination control set of auxiliary terminal node corresponding to the end node of breaking whether non-NULL the step of, if without newly adding, knot Shu Suoshu second adds step.
  10. 10. according to the method for claim 5, it is characterised in that before the traversal starts, also by opening except thread The initial concurrent node set of node outside the immediate successor node of beginning node and thread creation node is initialized as empty set;
    It is described that traversal includes downwards since the first node of program control flowchart:
    Using the first node of program control flowchart as present node;
    Judge in the immediate successor node of present node with the presence or absence of the immediate successor section for not being calculated concurrent node set also Point;
    If not and the present node is not the first node of program control flowchart, then is updated to present node described work as prosthomere Direct precursor node in the direct precursor node of point, just accessed, and return to the judgement present node it is direct after It is if not and described current after whether there is the immediate successor node for not being calculated concurrent node set also in node the step of Node is the first node of program control flowchart, terminates flow;
    If it is, the immediate successor section of concurrent node set it is not calculated in the immediate successor node of access present node also Point;
    The node that present node is updated to be accessed;
    Judge whether to there is a node not to be calculated concurrent node set in the direct precursor node of present node and do not counted Calculate the back edge that the directed edge between the node and present node of concurrent node set is not circulation;
    If it is, present node is updated in the direct precursor node of the present node, it is just accessed it is direct before Node is driven, and returns in the immediate successor node of the judgement present node whether there is and is not calculated concurrent node collection also The step of immediate successor node of conjunction;
    Otherwise, judge whether present node is auxiliary terminal node;
    If present node is auxiliary terminal node, the concurrent node set of the present node is calculated, wherein, it is described to work as The concurrent node union of sets collection that the concurrent node set of front nodal point is equal to the direct precursor node of the present node at least subtracts The present node initially can not concurrent node set, present node is updated to the direct precursor node of the present node In, just accessed direct precursor node, and return in the immediate successor node of the judgement present node and whether there is Not the step of not being calculated the immediate successor node of concurrent node set also;
    If present node is not auxiliary terminal node, the concurrent node set of the present node is calculated, wherein, it is described The concurrent node set of present node is equal to the initial concurrent node set of the present node and the direct precursor of the present node The concurrent node union of sets collection of node, present node is updated in the direct precursor node of the present node, just by The direct precursor node of access, and return in the immediate successor node of the judgement present node whether there is and do not calculated also The step of going out the immediate successor node of concurrent node set.
  11. A kind of 11. concurrent analytical equipment, it is characterised in that including:
    Flow graph unit is obtained, for obtaining program control flowchart, wherein, in described program controlling stream graph, thread creation node The direct precursor node of the start node of the thread created by the thread creation node;
    Initial computation unit, each thread starts to save in the program control flowchart obtained for calculating the acquisition flow graph unit The initial concurrent node set of point, the initial concurrent node set of the immediate successor node of each thread creation node and every The immediate successor node of individual Thread Termination node initially can not concurrent node set;Wherein, each thread starts to save The initial concurrent node set of point includes the node after the thread creation node of thread where being used to create the start node In, at least one node that can be concurrent with the start node;Wherein, the immediate successor node of the thread creation node In node after the start node for the thread that initial concurrent node set is created including the thread creation node, at least one Individual node that can be concurrent with the immediate successor node of the thread creation node;Wherein, the Thread Termination node is direct Descendant node initially can not concurrent node set comprise at least whole nodes of thread that the Thread Termination node is terminated;
    Initialization unit, the concurrent node set of the first node for initializing described program controlling stream graph;
    Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, according to Following inheritance rules, calculate the concurrent node set of each node traversed;Wherein, the inheritance principles include:If The present node traversed is not the immediate successor node of Thread Termination node, then, and the concurrent node set of the present node The concurrent node set of at least one direct precursor node including the present node;If present node is thread creation node Immediate successor node or thread start node, then, the concurrent node set of the present node includes the initial meter Calculate the initial concurrent node set for the present node that unit is calculated and the concurrent node of at least one direct precursor node Union of sets collection;If the present node traversed is the immediate successor node of Thread Termination node, the present node The concurrent node set that concurrent node set is equal at least one direct precursor node of the present node subtracts the initial meter That calculates the present node that is calculated of unit initially can not concurrent node set.
  12. 12. device according to claim 11, it is characterised in that the initial computation unit, controlled for calculation procedure The initial concurrent node set of the start node of each thread in flow graph, each thread creation node immediate successor node just The immediate successor node of beginning concurrent node set and each Thread Termination node initially can not concurrent node set, wherein: The initial concurrent node set of the start node of each thread calculated includes being used to create the start node institute online In node after the thread creation node of journey, all nodes that can be concurrent with the start node;What is calculated is each The initial concurrent node set of the immediate successor node of the thread creation node of thread is created including the thread creation node Thread start node after node in, all sections that can be concurrent with the immediate successor node of the thread creation node Point;The immediate successor node of the Thread Termination node calculated initially can not concurrent node set include the Thread Termination Whole nodes in the thread that node is terminated;
    The Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, According to following inheritance rules, the concurrent node set of each node traversed is calculated:Wherein, the inheritance principles include:
    If the present node traversed is not the immediate successor node of Thread Termination node, the present node it is concurrent Node set includes the concurrent node union of sets collection of all direct precursor nodes of the present node;
    If present node is the immediate successor node of thread creation node or the start node of thread, it is described to work as prosthomere The concurrent node set of point includes the initial concurrent node set of the present node and the concurrently section of all direct precursor nodes The union of point set;
    If the present node traversed is the immediate successor node of Thread Termination node, the concurrently section of the present node The concurrent node union of sets collection that point set includes all direct precursor nodes of the present node subtracts the first of the present node Beginning can not concurrent node set.
  13. 13. device according to claim 12, it is characterised in that the initial computation unit, controlled for calculation procedure The initial concurrent node set of the start node of each thread in flow graph, each thread creation node immediate successor node just The immediate successor node of beginning concurrent node set and each Thread Termination node initially can not concurrent node set, wherein, Only include being used to create the start node institute in the initial concurrent node set of the start node of each thread calculated In the node after the thread creation node of thread, all nodes that can be concurrent with the start node;Calculated Only created in the initial concurrent node set of the immediate successor node of each thread creation node including the thread creation node In node after the start node for the thread built, it is all can be concurrent with the immediate successor node of the thread creation node Node;
    The Traversal Unit, for being traveled through downwards since the first node of described program controlling stream graph, in the ergodic process, The concurrent node set of each node traversed is calculated, wherein:If the present node traversed is not Thread Termination node Immediate successor node, the immediate successor node of thread creation node and the start node of thread, then, and the present node Concurrent node set be equal to the present node all direct precursor nodes concurrent node union of sets collection;If work as prosthomere Point is the immediate successor node of thread creation node or the start node of thread, then, the concurrent node collection of the present node Close and be equal to the initial concurrent node set for the present node that the initial computation unit is calculated and owning for the present node The concurrent node union of sets collection of direct precursor node;If the present node traversed is the immediate successor of Thread Termination node Node, then, the concurrent node set of the present node are equal to the concurrent node of all direct precursor nodes of the present node What union of sets collection at least subtracted the present node that the initial computation unit is calculated initially can not concurrent node set.
  14. 14. device according to claim 12, it is characterised in that the initial computation unit, for calculating thread end Only the immediate successor node of node initially can not concurrent node set, wherein, the Thread Termination node calculated it is straight Connect descendant node initially can not be in concurrent node set, whole sections of the thread only terminated including the Thread Termination node Point;
    The initial computation unit, be additionally operable to according to the start node of thread initially can not concurrent node set be equal to that create should Node set where the thread creation node of thread on the start node to the reachable path of the thread creation node of thread, meter Calculate the start node of each thread initially can not concurrent node set;
    The initialization unit, be additionally operable to initialize described program controlling stream graph first node can not concurrent node set;
    The Traversal Unit, be additionally operable to calculate traverse each node can not concurrent node set, wherein:If traverse Present node be thread start node, or the immediate successor node of Thread Termination node, then, when the present node Direct precursor node when being only one, the present node can not concurrent node set be equal to the present node it is direct before Drive node can not the present node that is calculated with the initial computation unit of concurrent node set initially can not be concurrent The union of node set, when the direct precursor node of the present node is multiple, the present node can not be saved concurrently Point set can not concurrent node intersection of sets collection and the initial calculation list equal to all direct precursor nodes of the present node The present node that member is calculated initially can not concurrent node union of sets collection;If the present node traversed is to remove thread Start node and Thread Termination node immediate successor node beyond node, then, and when the present node it is direct before Node is driven when being only one, the present node can not concurrent node set be equal to the direct precursor node of the present node Can not concurrent node set, when the present node direct precursor node for it is multiple when, the present node can not be saved concurrently Point set can not concurrent node intersection of sets collection equal to all direct precursor nodes of the present node.
  15. 15. according to the device described in any one of claim 12, it is characterised in that the acquisition flow graph unit includes obtaining flow graph Subelement, auxiliary establishing node increase subelement, auxiliary terminal node increase subelement;
    Wherein, the acquisition flow graph subelement, for obtaining the controlling stream graph of each thread;
    The auxiliary establishing node increases subelement, for each thread creation section in the controlling stream graph for each thread Point is each to increase an immediate successor node newly, and the immediate successor node is auxiliary establishing node, and the thread creation node is original Immediate successor node be changed in the immediate successor node of the thread creation node increase newly the auxiliary establishing node it is direct Descendant node, the thread creation node is designated as to the direct precursor of the start node for the thread that the thread creation node is created Node;
    The auxiliary terminal node increase subelement, for each another for terminating in the controlling stream graph for each thread The Thread Termination node of one thread is each to increase an immediate successor node newly, and the immediate successor node is auxiliary terminal node, by institute State the original immediate successor node of Thread Termination node be changed in the immediate successor node of the Thread Termination node increase newly it is described The immediate successor node of terminal node is aided in, the end node for the thread that the Thread Termination node is terminated is changed to the thread The direct precursor node of the newly-increased immediate successor node of terminal node.
  16. 16. device according to claim 15, it is characterised in that the initial computation unit includes First partial and calculates son Unit, the first concurrent subelement;
    Wherein, First partial computation subunit, a corresponding Partial controll is respectively generated for the start node for each thread Set, wherein, the Partial controll set includes start node corresponding with the Partial controll set and in whole program In the range of controlling stream graph, all first nodes controlled by corresponding start node, wherein, it is described by corresponding start node control It is described right that the first node of system refers to have to pass through into the path of first node itself since program control flowchart first node The node for the start node answered;
    The first concurrent subelement, for the start node for each thread, following first is performed respectively and is concurrently saved Calculation procedure is put to calculate the initial concurrent node set of the start node of each thread, wherein, first concurrent node Calculation procedure includes:Calculating has reachable path after corresponding auxiliary establishing node, with the corresponding auxiliary establishing node The 3rd node set, wherein, it is described corresponding to auxiliary establishing node for the start node of targeted thread direct precursor Auxiliary establishing node in the immediate successor node of node, according to the initial concurrent node collection of the start node of targeted thread Close and subtract local controlled corresponding to the start node of the First partial computation subunit generation equal to the 3rd node set System set, calculates the initial concurrent node set of the start node of targeted thread.
  17. 17. device according to claim 16, it is characterised in that it is initial that the First partial computation subunit includes first Subelement, the first addition subelement, the first initial local subelement are terminated, second adds subelement;
    Wherein, the described first initial termination subelement, for respectively initializing termination corresponding to one for each auxiliary terminal node Control set, wherein, by auxiliary terminal node and aiding in controlling in thread, by auxiliary terminal node where terminal node Node add the auxiliary terminal node termination control set;
    Described first adds subelement, for each auxiliary terminal node for being obtained from the described first initial termination subelement It is corresponding to terminate control set, the first addition step is respectively enterd, the first addition step includes:Judge targeted termination Whether include the end node of thread in control set, if it is, judging auxiliary terminal node corresponding to the end node Terminate control set whether non-NULL, if non-NULL, by corresponding to the end node aid in terminal node termination control set plus Enter targeted termination control set, wherein, auxiliary terminal node is to terminate to save for terminating this corresponding to the end node Auxiliary terminal node in the immediate successor node of the Thread Termination node of thread where point, judges targeted termination domination set Whether have the end node that newly adds, if what is newly added, using the end node of the new addition as object is judged, return if closing Return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, if without new Add, terminate described first and add step;
    The first initial local subelement, a corresponding Partial controll is respectively initialized for the start node for each thread Set, by the start node of each thread, and in all sections controlled by the start node in thread where the start node Point is added in corresponding Partial controll set;
    Described second adds subelement;Saved for each thread for being obtained since the first initial local subelement Partial controll set corresponding to point, respectively enters the second addition step, and the second addition step includes:Judge targeted office Whether include the end node of thread in portion's control set, if it is, judging what the first addition subelement was calculated The termination control set of auxiliary terminal node corresponding to the end node whether non-NULL, it is if non-NULL, the end node is corresponding Termination control set add the targeted Partial controll set, and judge whether targeted Partial controll set has newly The end node of addition, if what is newly added, using the end node of the new addition as object is judged, return to and described sentence The termination control set of auxiliary terminal node corresponding to the end node of breaking whether non-NULL the step of, if without newly adding, knot Shu Suoshu second adds step.
  18. 18. device according to claim 15, it is characterised in that the initial computation unit includes the second local calculation Unit, the second concurrent subelement;
    Wherein, the described second local computation subunit, for respectively generating a corresponding local controlled for each auxiliary establishing node System set, wherein, the Partial controll set includes auxiliary establishing node corresponding with the Partial controll set and whole In the range of individual program control flowchart, all section points by corresponding auxiliary establishing node control, wherein, it is described corresponding The section point of auxiliary establishing node control refers to since program control flowchart first node into the path of section point itself Have to pass through the node of the corresponding auxiliary establishing node;
    The second concurrent subelement, for for each auxiliary establishing node, performing following second concurrent node respectively Calculation procedure to calculate the initial concurrent node set of each auxiliary establishing node, wherein, second concurrent node calculates Step includes:Calculate has the fourth node collection of reachable path after corresponding start node, with the corresponding start node Close, wherein, the corresponding start node is the immediate successor node of the direct precursor node of targeted auxiliary establishing node In start node, subtracted according to the initial concurrent node set of targeted auxiliary establishing node equal to the fourth node set Partial controll set corresponding to removing the auxiliary establishing node of the described second local computation subunit generation, is calculated targeted The initial concurrent node set of auxiliary establishing node.
  19. 19. device according to claim 18, it is characterised in that it is initial that the second local computation subunit includes second Subelement, the 3rd addition subelement, the second initial local subelement are terminated, the 4th adds subelement;
    Wherein, the described second initial termination subelement, for respectively initializing termination corresponding to one for each auxiliary terminal node Control set, wherein, by auxiliary terminal node and aiding in controlling in thread, by auxiliary terminal node where terminal node Node add the auxiliary terminal node termination control set;
    Described 3rd adds subelement, for each auxiliary terminal node for being obtained from the described second initial termination subelement It is corresponding to terminate control set, the first addition step is respectively enterd, the first addition step includes:Judge targeted termination Whether include the end node of thread in control set, if it is, judging auxiliary terminal node corresponding to the end node Terminate control set whether non-NULL, if non-NULL, by corresponding to the end node aid in terminal node termination control set plus Enter targeted termination control set, wherein, auxiliary terminal node is to terminate to save for terminating this corresponding to the end node Auxiliary terminal node in the immediate successor node of the Thread Termination node of thread where point, judges targeted termination domination set Whether have the end node that newly adds, if what is newly added, using the end node of the new addition as object is judged, return if closing Return to the termination control set for judging auxiliary terminal node corresponding to the end node whether non-NULL the step of, if without new Add, terminate described first and add step;
    The second initial local subelement, for respectively initializing a corresponding Partial controll collection for each auxiliary establishing node Close, by each auxiliary establishing node, and where the auxiliary establishing node in thread it is all by the auxiliary establishing node control Node be added to corresponding in Partial controll set;
    Described 4th adds subelement, for each auxiliary establishing node for being obtained from the second initial local subelement Corresponding Partial controll set, respectively enters the second addition step, and the second addition step includes:Judge targeted part Control set in whether include the end node of thread, if it is, judge it is described 3rd add subelement be calculated this The termination control set of auxiliary terminal node corresponding to end node whether non-NULL, if non-NULL, by corresponding to the end node Termination control set adds the targeted Partial controll set, and judges whether targeted Partial controll set has new add The end node entered, if what is newly added, using the end node of the new addition as object is judged, return to the judgement The termination control set of auxiliary terminal node corresponding to the end node whether non-NULL the step of, if without what is newly added, terminate Described second adds step.
  20. 20. device according to claim 15, it is characterised in that the initialization unit, be additionally operable to open in the traversal Before beginning, by the initial concurrent of the node in addition to the immediate successor node of the start node of thread and thread creation node Node set is initialized as empty set;
    The Traversal Unit includes first node and sets subelement, the first judgment sub-unit, the first return subelement, end single Member, access subelement, node updates subelement, the second judgment sub-unit, second return to subelement, the 3rd judgment sub-unit, the One traversal computation subunit, the second traversal computation subunit;
    Wherein, the first node sets subelement, for using the first node of program control flowchart as present node;
    First judgment sub-unit, with the presence or absence of not being calculated also simultaneously in the immediate successor node for judging present node Send out the immediate successor node of node set;
    Described first returns to subelement, is judged as NO for first judgment sub-unit and the present node is not program control During the first node of flow graph processed, using the direct precursor node of the present node as present node, first sentences described in retriggered Disconnected subelement;
    The end subelement, it is judged as NO for first judgment sub-unit and the present node is program control flowchart First node when, terminate flow;
    The access subelement, when being judged as YES for first judgment sub-unit, access the immediate successor section of present node It is not calculated the immediate successor node of concurrent node set in point also;
    The node updates subelement, in the access unit accessed node, present node being updated to be interviewed The node asked;
    Second judgment sub-unit, for after node updates subelement renewal, judging the direct precursor of present node Whether there is a node not to be calculated concurrent node set in node and be not calculated the node of concurrent node set with working as Directed edge between front nodal point is not the back edge of circulation;
    Described second returns to subelement, when being judged as YES for second judgment sub-unit, present node is updated to described Direct precursor node in the direct precursor node of present node, just accessed, and the first judgement is single described in retriggered Member;
    3rd judgment sub-unit, when being judged as NO for second judgment sub-unit, judge present node whether supplemented by Help terminal node;
    The first traversal computation subunit, when being judged as YES for the 3rd judgment sub-unit, calculates the present node Concurrent node set, wherein, the concurrent node set of the present node is equal to the direct precursor node of the present node What concurrent node union of sets collection at least subtracted the present node initially can not concurrent node set;
    The second traversal computation subunit, when being judged as NO for the 3rd judgment sub-unit, calculates the present node Concurrent node set, wherein, the concurrent node set of the present node is equal to the initial concurrent node collection of the present node Close the concurrent node union of sets collection with the direct precursor node of the present node.
CN201310617816.4A 2013-11-27 2013-11-27 A kind of concurrent analysis method and device Expired - Fee Related CN104679484B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310617816.4A CN104679484B (en) 2013-11-27 2013-11-27 A kind of concurrent analysis method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310617816.4A CN104679484B (en) 2013-11-27 2013-11-27 A kind of concurrent analysis method and device

Publications (2)

Publication Number Publication Date
CN104679484A CN104679484A (en) 2015-06-03
CN104679484B true CN104679484B (en) 2018-02-06

Family

ID=53314606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310617816.4A Expired - Fee Related CN104679484B (en) 2013-11-27 2013-11-27 A kind of concurrent analysis method and device

Country Status (1)

Country Link
CN (1) CN104679484B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105930105B (en) * 2016-05-20 2018-11-20 中国农业银行股份有限公司 A kind of nodal test method and device of parallel gateway
WO2018120233A1 (en) * 2016-12-30 2018-07-05 华为技术有限公司 Transaction processing method and apparatus
CN106919368B (en) * 2017-01-12 2019-01-29 北京中科睿芯科技有限公司 Accelerated method, acceleration system, device and the chip in a kind of streamed data stream graph key path

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937396A (en) * 2010-09-30 2011-01-05 中国科学院软件研究所 Detecting method of unsafe variable use in software program
CN102073589A (en) * 2010-12-29 2011-05-25 北京邮电大学 Code static analysis-based data race detecting method and system thereof

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120290883A1 (en) * 2010-11-11 2012-11-15 Nec Laboratories America, Inc. Computer Implemented Method for Precise May-Happen-in-Parallel Analysis with Applications to Dataflow Analysis of Concurrent Programs
US9141359B2 (en) * 2010-12-13 2015-09-22 Hewlett-Packard Development Company, L.P. Procedural concurrency graph generator

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937396A (en) * 2010-09-30 2011-01-05 中国科学院软件研究所 Detecting method of unsafe variable use in software program
CN102073589A (en) * 2010-12-29 2011-05-25 北京邮电大学 Code static analysis-based data race detecting method and system thereof

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
An efficient algorithm for computing MHP information for concurrent Java programs;Gleb Naumovich et al.;《Proceeding ESEC/FSE7 Proceedings of the 7th European software》;19990910;第338-354页 *
Can We Make It Faster? Efficient May-Happen-in-Parallel Analysis Revisited;Congming Chen et al.;《2012 13th International Conference on Parallel and Distributed Computing, Applications and Technologies》;20121216;第59-64页 *
Making it practical and effective: fast and precise mayhappeninparallel;Congming Chen et al.;《Proceeding PACT "12 Proceedings of the 21st international conference on Parallel architectures and compilation techniques》;20120923;第469-470页 *

Also Published As

Publication number Publication date
CN104679484A (en) 2015-06-03

Similar Documents

Publication Publication Date Title
CN104679484B (en) A kind of concurrent analysis method and device
Dietterich An overview of MAXQ hierarchical reinforcement learning
Lauriere Numerical methods for mean field games and mean field type control
Jong et al. The utility of temporal abstraction in reinforcement learning.
Hauschildt et al. Petri net algorithms in the theory of matrix grammars
CN109598184B (en) Method and device for processing multi-segmentation tasks
US5999178A (en) Selection, type matching and manipulation of resource objects by a computer program
Mankowitz et al. Time regularized interrupting options
WO2018032927A1 (en) Human-computer interactive system constraint-oriented interactive control model solving method and system
CN114261400B (en) Automatic driving decision method, device, equipment and storage medium
CN112580728B (en) Dynamic link prediction model robustness enhancement method based on reinforcement learning
Popp et al. Automatic generation of the behavior of a user interface from a high-level discourse model
Mann et al. Time-regularized interrupting options (TRIO)
CN112297012B (en) Robot reinforcement learning method based on self-adaptive model
De Peuter et al. Zero-shot assistance in sequential decision problems
Camilli et al. Approximation of optimal control problems with state constraints: estimates and applications
Beneš et al. Dual-priced modal transition systems with time durations
CN107180133A (en) A kind of method and device of CPS modelings
CN110533189B (en) Machine learning system
CN104866299B (en) For the method and system of the focus management in software application
Adamski et al. Hierarchical Petri nets for digital controller design
Drath Description of hybrid systems by modified petri nets
CN109493301A (en) Map image processing method and device and robot
Nayak et al. Forgetting and knowledge update
Sezer Dynamic importance sampling for queueing networks

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180206

Termination date: 20201127