CN106257425B - A kind of Java concurrent program path method for decomposing based on con current control flow graph - Google Patents
A kind of Java concurrent program path method for decomposing based on con current control flow graph Download PDFInfo
- Publication number
- CN106257425B CN106257425B CN201610577045.4A CN201610577045A CN106257425B CN 106257425 B CN106257425 B CN 106257425B CN 201610577045 A CN201610577045 A CN 201610577045A CN 106257425 B CN106257425 B CN 106257425B
- Authority
- CN
- China
- Prior art keywords
- thread
- control flow
- current control
- flow graph
- path
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a kind of Java concurrent program path method for decomposing based on con current control flow graph, by controlling the connection (creation and all kinds of synchronized relations including thread) of flow relation and cross-thread in the thread in analysis Java source code, Java con current control flow graph is constructed;Implement concurrent path on Java con current control flow graph and dissect algorithm, and pitching pile is carried out to Java source code according to arithmetic result, so that the path that the source code after pitching pile can generate concurrent program in the process of implementation dissects result.
Description
Technical field
The invention belongs to dynamic routine analysis fields, are related to a kind of Java concurrent program path based on con current control flow graph
Method for decomposing.
Background technique
Dynamic routine analysis is the analytical technology executed based on program, so the execution information of collection procedure is dynamic analysis
The indispensable a part of method.For the execution information of efficient collecting path, the prior art generallys use path code
Each path is mapped to one or a set of integer by mode, with quickly judge currently performed path whether with executed
Certain paths is identical, easily carries out executing the cumulative of number.Correspondingly, executing it in program for the coding of realizing route
Before, it first has to carry out pitching pile to program, on the basis of the controlling stream graph (CFG, control flow graph) of analysis program,
Value Operations sentence and relevant logic control, the probe collection etc. of one or more probe variables are inserted into the relevant position of program
Sentence.In this way after program is finished each time, collected path code calculated result just uniquely determines the secondary execution
Path.
For single-threading program, on the basis of its control flow analysis, existing technology can be by every executable path
It is encoded to a unique nonnegative integer or a string of unique integer sets;In order to realize this kind of path code, insert in a program
The sentence needs of stake are executed with the execution of target program, and final path code is calculated when being finished.
For concurrent program, the difficulty that traditional method for decomposing is difficult to carry out mainly has two: concurrent program increases thread
Creation, termination and interaction mechanism, cause control flow structure and execute space being all very different with single-threading program;Concurrently
Alternately mixing executes for each thread in program, leads to the computing statement of probe variable it can also happen that out-of-order situation, it is difficult to locate
Reason.
In actual Java software, concurrent mechanism using relatively broad, the complex relationship between multiple threads can be led
Its controlling stream graph is caused to execute confusion, it is therefore, indispensable for the practical anatomy scheme of concurrent program.
Summary of the invention
Technical problem: the present invention, which provides the calculating of its middle probe of one kind and path code mode, can guarantee in concurrent program often
The coding of the execution route of a thread has uniqueness, achieve the effect that be capable of Precise collection concurrent program execution information based on
The Java concurrent program path method for decomposing of con current control flow graph.
Technical solution: the Java concurrent program path method for decomposing of the invention based on con current control flow graph, including it is as follows
Step:
Step 1) from obtained in Java concurrent program source code inside each thread control flow structure and thread between and
Hair relationship;
On the basis of control flow structure of the step 2) first inside each thread, according to the concurrency relation between thread
Type does following processing to different concurrent elements respectively, and final building obtains con current control flow graph:
A) for thread creation relationship, increase from thread creation node to the control stream side for being created thread entry node;
B) for the thread synchronization relationship of " notice-obstruction ", synchronously control sentence is identified, according to every synchronously control sentence
Meaning, delete the controlling stream graph structure to disappear due to synchronous inside thread, increase the control occurred between thread by synchronization
Flow graph structures so that in con current control flow graph Correct thread every sentence execution precedence;
C) for the thread synchronization relationship of FutureGet mechanism, increase notice node to the control stream side for being notified node,
And it is notified all out sides of the node inside thread;
Step 3) is implemented to dissect algorithm in the con current control flow graph that the step 2 obtains, and required probe sentence is inserted
Stake is into former concurrent program, and for the concurrent program after guaranteeing pitching pile under arbitrary executive condition, the execution track of per thread is equal
It is identified by unique path code;
Step 4) executes the program after pitching pile, in program process, calculates path by the probe sentence of institute's pitching pile
Simultaneously statistical path frequency is encoded, as final anatomy result.
Further, in the method for the present invention, required probe sentence uses multiple probe variables in step 3), in pitching pile to original
The unique probe variable of per thread is dynamically distributed during concurrent program according to Java Thread Id.
Further, in the method for the present invention, the required probe sentence in step 3 dissects method according to complete trails and is calculated.
The invention proposes a kind of Java concurrent program path method for decomposing based on con current control flow graph, is mainly being closed
And on the basis of multiple thread internal control flow graphs, by analyzing concurrent correlative code, corresponding control stream side is deleted in increase,
To construct con current control flow graph, and then implementation path method for decomposing on the basis of con current control flow graph.
The utility model has the advantages that compared with prior art, the present invention having the advantage that
(1) existing path dissects technology and fails to construct the control flow relation between thread, also lacks in concurrent program
The parsability of per thread.The present invention is due to increasing the processing to the cross-thread creation information such as relationship and synchronized relation, structure
Con current control flow graph has been built, the synchronous shape of difference that per thread implementation procedure neutralizes other threads can be distinguished in the process of implementation
State ensure that accurate dissect simultaneously so that encoded routing information can include creation, execution and the termination of per thread
Send out the ability of java applet.
(2) existing path dissects technology and generallys use single argument as probe variable, leads to the probe language of multiple threads
Sentence is executed and is interacted, it is difficult to be distinguished.The Thread Id mechanism of Java language is utilized in the method for the present invention, for per thread according to
Its Thread Id dynamically distributes a distinctive probe variable and carries out coding calculating, the path in implementation procedure between each thread
Encoding operation is independent of each other, and is capable of handling the multiple threads being performed simultaneously in concurrent program.Even by same section of code establishing
Different threads therefore also can clearly be distinguished in parsing process due to its Thread Id difference, it is corresponding to obtain per thread
Dissect result.
Detailed description of the invention
Fig. 1 is architecture of the invention.
Fig. 2 is the processing schematic in con current control flow graph construction to thread creation relationship.
Fig. 3 is the processing schematic in con current control flow graph construction to thread " notice-obstruction " synchronized relation.
Fig. 4 is the processing schematic in con current control flow graph construction to thread " FutureGet " synchronized relation.
Fig. 5 is the corresponding single thread controlling stream graph of example procedure.
Fig. 6 is the con current control flow graph generated for Fig. 5.
Specific embodiment
Below with reference to embodiment and Figure of description, the present invention is further illustrated.
Probe in technology calculates and path code is two inseparable parts, the coding in path and the probe of pitching pile
Sentence is corresponding, and probe sentence is calculated in target program implementation procedure by the probe sentence of institute's pitching pile.Accurately
Path code requires the coding of either path to have uniqueness, correspondingly, probe sentence performed on different paths also must
Different variable-values must be calculated.
The basis of the method for the present invention is the building of con current control flow graph, and this Figure illustrates the control flow relations inside thread
Synchronization execution relationship between thread;Implement corresponding probe pile pitching method on Concurrent Control Flow graph model, this method is protected
The uniqueness of concurrent execution route coding has been demonstrate,proved, and concise can be achieved.
One, architecture
Fig. 1 gives the architecture of this method.Illustrating for several major parts is given below.
The analysis of 1 Concurrent Control Flow
The function of the part is to hold from synchronizing between control flow relation and the thread obtained in source code inside thread
The relevant informations such as row relationship, to be applied to probe pile pitching method.The control stream information needed in the present invention mainly includes single
The control flow relation between the call relation and thread between controlling stream graph, method inside method.
A) for thread creation relationship, if there is the A in A thread controlling stream graphxNode creates thread B, thread B's
Ingress node is B1, then increasing control stream side (A in con current control flow graphx, B1), as shown in Figure 2: figure left side be thread A and
For the controlling stream graph and A of thread B to the creation relationship description of B, right side is the con current control flow graph accordingly generated.
B) for the thread synchronization relationship of " notice-obstruction ", con current control flow graph is corrected by identification synchronously control sentence.
Notice node is divided into 4 classes in " notice-obstruction ": (1) being inherited from notify, notifyAll of Object base class;(2)
Countdown mechanism deletes sentence;(3) signal, signalAll of conditional-variable;(4) it is realized by Phaser class
Arrive notifies sentence.Obstruction node corresponding with notice node is respectively wait, await, await, awaitAdvance.?
In con current control flow graph, the control of notice sentence node corresponding with obstruction sentence to the obstruction sentence subsequent execution node is constructed
System stream side, while the control stream side of obstruction sentence and its subsequent execution node is deleted in the control flow structure inside thread, such as
(same Fig. 2 of meaning in figure) shown in Fig. 3.
C) for the thread synchronization relationship of FutureGet mechanism, if there is the A in A thread controlling stream graphxNode calls
The Egress node of the get () or join () method of thread B, thread B are By, then increasing control in con current control flow graph
Flow side (By, Ax), and leave out the A in A thread controlling stream graphxNode goes out side, (same Fig. 2 of meaning in figure) as shown in Figure 4.
2 concurrent paths dissect algorithm
In the control stream of single process, probe calculation is required to distinguish different paths.Traditional single thread
Path dissects algorithm calculation are as follows: how input control flow graph carries out pitching pile by the structure decision of analysis and Control flow graph.Institute
The sentence of pitching pile defines the probe variable r of integer type, program the relevant action statement of different location pitching pile r (i.e.
Probe includes the assignment, cumulative and tired the operation such as multiply to r), change the value of r as program executes, it is opposite with path code
It answers.
On this basis, it includes two parts that concurrent path of the invention, which dissects algorithm improvement:
A) improvement of controlling stream graph.It is different from legacy paths and dissects algorithm using single thread controlling stream graph as input, this hair
It is bright that con current control flow graph is generated by previous step, and then implement traditional single thread path on con current control flow graph and dissect
Algorithm guarantees that the anatomy of single thread can be correctly completed.
B) improvement of mode is inserted.Being different from legacy paths anatomy algorithm uses unitary variant as probe variable, this hair
The bright probe variable used is the variable ri of one group of integer type, the line that may be executed for each of con current control flow graph
Journey uses a variable as its probe variable, avoids executing out the interference for calculating probe in concurrent mechanism, guarantee not
It is non-interference with path code performed by thread.
Specific calculation is: all probe variables are realized by the variable array of an integer type;Per thread wound
When building, according to the probe variable ri of this thread of thread number i application, and ri is initialized;In thread implementation procedure, per thread
Probe sentence numbered and distinguish by current thread, will not interact, and then guarantee that the path of entire concurrent program dissects energy
Enough correct implementation.
3 execution and path code
Controlling stream graph limited for static path, the path code mode that the present invention uses is: executing in target program
Before, all static loop free paths are enumerated, and establish the one-to-one relationship table that each path is encoded with it;It is executing every time
Bi Shi tables look-up according to collected coding it can be learnt that performed path.
In the case where having Do statement, recursive call or circulation thread to rely on, static path number is unlimited, Wu Famei
It lifts.In this way before target program execution, the one-to-one correspondence table in path code and path can not be listed.In order to from path code
Statistical result obtains corresponding path implementing result, needs to obtain coding using the method for the path backtracking in existing anatomy field
Corresponding path.
In code after pitching pile, probe sentence constantly calculates the path of each thread with the implementation procedure of concurrent program
Coding, in Thread Termination and program determination, the probe variable number used is performed number of threads, and each probe becomes
The value of amount is the coding of per thread execution route.
Two, method flow
This method calculates the spy for needing the pitching pile in program source code by the analysis to target program control flow structure
Then needle is encoded by the execution of target program with collecting path, obtain last implementing result.Specific steps are as follows:
Step 1) constructs Concurrent Control Flow from the control structure obtained inside each thread between thread in program source code
Figure;
Step 2) implements concurrent path for con current control flow graph and dissects algorithm, calculates corresponding probe and pitching pile to program
Among source code;
Step 3) executes the program after pitching pile, and collects corresponding path code and its frequency;
Step 4) is recalled on con current control flow graph by the information being collected into, and converts path for path code, with
Obtain the implementing result of concurrent path.
Embodiment:
For the convenience of description, the source code of target concurrent program is as follows it is assumed that there is application example simplified as follows:
The code function are as follows: producer Producer and consumer Comsumer are concurrently executed, Producer to
Data are pressed into the stack of Container, Consumer takes out data from the stack of Container, if stack is full, Producer
Thread waits, if stack is empty, Consumer thread is waited.
Control flow structure in the single thread of the program in method between method is as shown in Figure 5.
Con current control flow graph building method according to the invention does following amendment (referring to Fig. 6) on the basis of Fig. 5:
1. analyzing thread creation relationship, increase thread creation side: 4 → 28,5 → -39;
2. thread " notice-obstruction " relationship of analysis, it is known that notify that node is 16 and 22 in program, the corresponding node that blocks is
20 and 13, and the descendant node for blocking node is 21 and 14.Therefore increase side 16 → 21,22 → 14, deletion side 13 → 14,21 →
22。
(per thread uses self ID application, uses unique probe the probe of pitching pile as follows on con current control flow graph
Variable ri):
12 → 14:ri=ri*2;
22 → 14:ri=ri*2+1;
19 → 21:ri=ri*2;
16 → 21:ri=ri*2+1;
4 → 28:ri=ri*2;
31 → 28:ri=ri*2+1;
30 → 31:ri=ri*2;
16 → 31:ri=ri*2+1;
5 → 39:ri=ri*2;
42 → 39:ri=ri*2+1;
41 → 42:ri=ri*2;
23 → 42:ri=ri*2+1。
Assuming that there is following implementation procedure:
It has successively been run in implementation procedure such as the probe (value of the probe variable after calculating is in bracket) on following:
Producer:(r2=0) 4 → 28 (r2=0), 12 → 14 (r2=0), 16 → 31 (r2=1), 31 → 28 (r2=3),
22→14(r2=7), 16 → 31 (r2=15)
Consumer:(r3=0) 5 → 39 (r3=0), 19 → 21 (r3=0), 23 → 42 (r3=1), 42 → 39 (r3=3),
19→21(r3=6), 23 → 42 (r3=13)
Corresponding path code: Producer thread is that 15, Consumer thread is 13.
If another secondary implementation procedure are as follows:
Following probe has so successively been run in implementation procedure:
Producer:(r2=0) 4 → 28 (r2=0), 12 → 14 (r2=0), 16 → 31 (r2=1), 31 → 28 (r2=3),
22→14(r2=7), 16 → 31 (r2=15)
Consumer:(r3=0) 5 → 39 (r3=0), 19 → 21 (r3=0), 23 → 42 (r3=1), 42 → 39 (r3=3),
16→21(r3=7), 23 → 42 (r3=15)
Corresponding path code: Producer thread is that 15, Consumer thread is 15.
Above-described embodiment is only the preferred embodiment of the present invention, it should be pointed out that: for the ordinary skill of the art
For personnel, without departing from the principle of the present invention, several improvement and equivalent replacement can also be made, these are to the present invention
Claim improve with the technical solution after equivalent replacement, each fall within protection scope of the present invention.
Claims (3)
1. a kind of Java concurrent program path method for decomposing based on con current control flow graph, which is characterized in that this method includes such as
Lower step:
Step 1) from obtained in Java concurrent program source code inside each thread control flow structure and thread between concurrently pass
System;
On the basis of control flow structure of the step 2 first inside each thread, according to the concurrency relation class between thread
Type does following processing to different concurrent elements respectively, and final building obtains con current control flow graph:
A) for thread creation relationship, increase from thread creation node to the control stream side for being created thread entry node;
B) for the thread synchronization relationship of " notice-obstruction ", synchronously control sentence is identified, according to containing for every synchronously control sentence
Justice deletes the controlling stream graph structure to disappear inside thread because synchronous, increases the controlling stream graph occurred between thread because synchronous
Structure so that in con current control flow graph Correct thread every sentence execution precedence;
C) for the thread synchronization relationship of FutureGet mechanism, then increase notice node in con current control flow graph to being notified
The control stream side of node, and leave out all sides out for being notified node inside thread;
Step 3) is implemented to dissect algorithm in the con current control flow graph that the step 2 obtains, and required probe sentence pitching pile is arrived
In former concurrent program, the concurrent program after guaranteeing pitching pile is under arbitrary executive condition, and the execution track of per thread is by only
One path code mark;
Step 4) executes the program after pitching pile, in program process, calculates path code by the probe sentence of institute's pitching pile
And statistical path frequency, as final anatomy result.
2. the Java concurrent program path method for decomposing according to claim 1 based on con current control flow graph, characterized in that
In the step 3) required probe sentence use multiple probe variables, pitching pile to original concurrent program during according to Java line
Journey ID dynamically distributes the unique probe variable of per thread.
3. the Java concurrent program path method for decomposing according to claim 1 or 2 based on con current control flow graph, feature
It is that the required probe sentence in the step 3) dissects method according to complete trails and is calculated.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610577045.4A CN106257425B (en) | 2016-07-20 | 2016-07-20 | A kind of Java concurrent program path method for decomposing based on con current control flow graph |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610577045.4A CN106257425B (en) | 2016-07-20 | 2016-07-20 | A kind of Java concurrent program path method for decomposing based on con current control flow graph |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106257425A CN106257425A (en) | 2016-12-28 |
CN106257425B true CN106257425B (en) | 2019-04-09 |
Family
ID=57714172
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610577045.4A Active CN106257425B (en) | 2016-07-20 | 2016-07-20 | A kind of Java concurrent program path method for decomposing based on con current control flow graph |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106257425B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108182144B (en) * | 2017-12-14 | 2020-12-11 | 东南大学 | Concurrent program parsing method based on sequential pattern mining |
CN108170434A (en) * | 2017-12-26 | 2018-06-15 | 首都师范大学 | The parallel acquisition methods and device in dangerous path |
CN109189483A (en) * | 2018-08-02 | 2019-01-11 | 优视科技新加坡有限公司 | Regulation method, apparatus, equipment/terminal/server and the storage medium of task execution |
CN116710894A (en) * | 2021-02-27 | 2023-09-05 | 华为技术有限公司 | Encoding and decoding method and device for function calling context |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101364185A (en) * | 2008-09-02 | 2009-02-11 | 中国科学院软件研究所 | Thread pool size self-adapting regulating method and concurrency control method applying server |
CN101702176A (en) * | 2009-11-25 | 2010-05-05 | 南开大学 | XML data concurrency control method based on local path lock |
CN102110052A (en) * | 2011-03-03 | 2011-06-29 | 华中科技大学 | Parallel acceleration method for dynamic analysis of program behavior |
CN103197920A (en) * | 2013-03-25 | 2013-07-10 | 华为技术有限公司 | Concurrency control method, control nodes and system |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150067283A1 (en) * | 2013-08-27 | 2015-03-05 | International Business Machines Corporation | Image Deduplication of Guest Virtual Machines |
-
2016
- 2016-07-20 CN CN201610577045.4A patent/CN106257425B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101364185A (en) * | 2008-09-02 | 2009-02-11 | 中国科学院软件研究所 | Thread pool size self-adapting regulating method and concurrency control method applying server |
CN101702176A (en) * | 2009-11-25 | 2010-05-05 | 南开大学 | XML data concurrency control method based on local path lock |
CN102110052A (en) * | 2011-03-03 | 2011-06-29 | 华中科技大学 | Parallel acceleration method for dynamic analysis of program behavior |
CN103197920A (en) * | 2013-03-25 | 2013-07-10 | 华为技术有限公司 | Concurrency control method, control nodes and system |
Non-Patent Citations (3)
Title |
---|
"Java并发程序动态分析技术研究";王越等;《南京大学学报(自然科学)》;20051031;第41卷;全文 |
"对Java并发程序进行模型检测";周志远等;《计算机工程与设计》;20090228;第30卷(第2期);全文 |
"飞行控制软件测试中插桩技术的优化方法";郭君红等;《计算机工程》;20100228;第36卷(第4期);全文 |
Also Published As
Publication number | Publication date |
---|---|
CN106257425A (en) | 2016-12-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106257425B (en) | A kind of Java concurrent program path method for decomposing based on con current control flow graph | |
Liu et al. | Transition cover-based design of Petri net controllers for automated manufacturing systems | |
Palamidessi | Comparing the expressive power of the synchronous and asynchronous-calculi | |
CN105144104B (en) | Method for executing tasks in critical real-time system | |
Hu et al. | Liveness and ratio-enforcing supervision of automated manufacturing systems using Petri nets | |
Como et al. | Scaling limits for continuous opinion dynamics systems | |
CN103744643A (en) | Method and device for structuring a plurality of nodes parallel under multithreaded program | |
US20110225570A1 (en) | Program flow route constructor | |
Malaguti et al. | Models and heuristic algorithms for a weighted vertex coloring problem | |
Freund et al. | How to obtain computational completeness in P systems with one catalyst | |
CN104978272A (en) | Program scheduling method for data race detection | |
Siyoum et al. | Automated extraction of scenario sequences from disciplined dataflow networks | |
Amadio et al. | Resource control for synchronous cooperative threads | |
Laveaux et al. | Decomposing monolithic processes in a process algebra with multi-actions | |
Crafa | Behavioural types for actor systems | |
Larbi et al. | Modeling the scheduling problem of identical parallel machines with load balancing by time petri nets | |
Martin et al. | A tool for proving deadlock freedom | |
Kao et al. | Competitive design and analysis for machine-minimizing job scheduling problem | |
Orchard et al. | Using session types as an effect system | |
Svendsen et al. | Joins: A case study in modular specification of a concurrent reentrant higher-order library | |
Chen et al. | Resource-oriented Petri net-based approach to deadlock prevention of AMSs | |
Zibaeenejad et al. | Weak invariant simulation and its application to analysis of parameterized networks | |
Versari et al. | On the expressive power of global and local priority in process calculi | |
Schlachter et al. | Optimal Label Splitting for Embedding an LTS into an arbitrary Petri Net Reachability Graph is NP-complete | |
Gouda et al. | Priority networks of communicating finite state machines |
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 |