CN105786703B9 - A kind of deadlock self-repairing method obtained in advance based on lock - Google Patents

A kind of deadlock self-repairing method obtained in advance based on lock Download PDF

Info

Publication number
CN105786703B9
CN105786703B9 CN201610069697.7A CN201610069697A CN105786703B9 CN 105786703 B9 CN105786703 B9 CN 105786703B9 CN 201610069697 A CN201610069697 A CN 201610069697A CN 105786703 B9 CN105786703 B9 CN 105786703B9
Authority
CN
China
Prior art keywords
lock
deadlock
acquisition
thread
locking
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610069697.7A
Other languages
Chinese (zh)
Other versions
CN105786703B (en
CN105786703A (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.)
Institute of Software of CAS
Original Assignee
Institute of Software 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 Institute of Software of CAS filed Critical Institute of Software of CAS
Priority to CN201610069697.7A priority Critical patent/CN105786703B9/en
Publication of CN105786703A publication Critical patent/CN105786703A/en
Publication of CN105786703B publication Critical patent/CN105786703B/en
Application granted granted Critical
Publication of CN105786703B9 publication Critical patent/CN105786703B9/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention relates to a kind of deadlock self-repairing method obtained in advance based on lock, belong to software test field and software reliability field, step includes:Control flow chart first in the synchronization module and synchronization module of extraction procedure, calculates the set of the operation in synchronization module to other locks;Then suitable candidate threads are selected to perform deadlock reparation operation:If be related in the thread of deadlock, there are a thread, and there is no the operation to other locks between the operation of two of which acquisition lock, then, lock is directly performed to the thread, and acquisition operates in advance, carries out deadlock reparation;Otherwise, the control of context-aware conditions is added on the basis of performing lock and obtaining operation in advance, carries out deadlock reparation.The present invention removes the deadlock in repair procedure in the case where not introducing new lock.In theory it can be proved that the present invention will not introduce new deadlock, new deadlock is not introduced during 20 deadlocks are successfully repaired, and serious performance will not be caused to reduce problem.

Description

A kind of deadlock self-repairing method obtained in advance based on lock
Technical field
The invention belongs to software testing technology field and software reliability field, and more particularly to deadlock is repaired automatically in multithread programs Method.
Background technology
With widely using for multi-core CPU, it is certain concomitantly to handle that more and more softwares have used multithreading Task.But multithread programs need each thread synchronously to complete some task well in the process of running.When When synchronous appearance between these threads is wrong, the generation of concurrent defect is may result in, deadlock (Deadlock) is exactly most A kind of basic concurrent defect.
Deadlock is commonly divided into resource deadlock (resource deadlock) and communication deadlock (communication deadlock) Two major classes, communication deadlock are often as the Buffer competition sent and received to information and produce;Resource deadlock, i.e., two A or more than two threads are when concurrently performing, since the resource for each needing to ask is by other lines in them Cheng Zhanyou, causes mutually to wait, the state that can not be continued to run with.Present invention is generally directed to the reparation of resource deadlock.Mainstream Deadlock recovery technique, mostly transported by the new lock of static or dynamic insertion to serialize the thread in concurrence error OK, so as to repair deadlock (these repair modes are referred to as GA).Although such repair mode is very simple, During reparation, new deadlock is easily introduced;And the side of deadlock is repaired in this serialization using between thread Formula, it is most likely that reduce performance and efficiency that program performs.Grail (FSE 2014) is also by adding one in outer layer It is new to lock to carry out deadlock reparation, unlike, the new lock of Grail additions is not static state, but with deadlock occurs Object lock is related.Grail reduces the performance issue repaired and brought to a certain extent, but can still introduce new deadlock. Therefore, by static state or dynamically, in outer layer addition, newly lock is not optimal deadlock restorative procedure.
The content of the invention
The technology of the present invention solves the problems, such as:A kind of deadlock obtained in advance based on lock is overcome the deficiencies of the prior art and provide to repair automatically Method (automatic reparation of the present invention for resource deadlock), is not introducing new deadlock (including resource deadlock and communication deadlock) On the premise of, all deadlocks are successfully repaired, and test and show, automatic repair of the invention will not be caused under serious performance Drop problem.
The technology of the present invention solution:A kind of deadlock self-repairing method DFixer obtained in advance based on lock, by extracting deadlock The synchronization module and control flow of relevant thread, calculate in each synchronization module to the operational set of other locks, select suitable time Route selection journey, performs lock and obtains operation in advance, in the case where avoiding adding new lock, successfully repairs all deadlocks, and avoid drawing Enter new deadlock (resource deadlock and communication deadlock), comprise the following steps:
(1) a deadlock D in preset sequence P and P, for the per thread in deadlock D, is searched for using DFS Automatically extract deadlock D occur when D in each thread function call information, the information include D in per thread be as What reaches deadlock point;The function call information may also require that user specifies;Based on this information, in the D of calculation procedure Control flow chart CFG in the synchronization module and synchronization module of per thread, wherein synchronization module refer to each in D The relevant part obtained twice between lock operation of thread deadlock, the object lock that this in per thread is locked to operation twice are taken Following mark:First is denoted as h locks, and second is denoted as w locks;
(2) calculate synchronization module in other lock operation set, the operation include to lock acquisition operation, etc. it is to be operated Wait and notice operation Notify;
(3) according to the set obtained in step (2), suitable candidate threads are selected to perform deadlock reparation from deadlock D Operation:If be related in the thread of deadlock, there are a thread, it is relevant deadlock to obtain between lock operation not twice In the presence of the operation to other locks, second lock w of the directly deadlock relevant operation to the thread performs lock and obtains behaviour in advance Make, and the operation before deletion to second lock w, carry out deadlock reparation;
(4) if not having thread to be selected in step (3), other threads are chosen, it meets that lock obtains twice in the thread Minimum thread is operated to other locks between extract operation, performs and acquisition operation in advance is locked described in step (3), it is in addition attached Add context-aware conditions to control, according to the lock action type between lock h operations and lock w operations, there is following A and B Two kinds of situations:
A:If wherein there is the acquisition operation to other locks, it is p to remember the lock, then before the acquisition to locking p, addition Variable vhw, which determines that the value for setting knots modification be true by locking w and h, discharges lock w afterwards, and change original To be retrieved as operating to obtaining while lock p and w to p, variable v is set afterwardshwValue be false;
B:If wherein exist to other locks etc. to be operated or notice operate, remember that the lock is locked for k, then to locking k Before acquisition, variable v is addedhw, the variable by lock w and h determine that the value for setting the variable is true, is discharged afterwards Lock w, and originally to lock k etc. it is to be operated after addition to lock k release operate, and to lock k and lock w it is same When obtain operation, variable v is set afterwardshwValue be false;
(5) after the operation of step (3) or (4), repair the program destroyed because of obtaining in advance for w of lock and patrol Volume;
(6) program after being repaired in step (3) or step (4) is denoted as P';
(7) in addition the program P' after execution is repaired, if compiling failure, returns to (3), selects from deadlock D Candidate threads, deadlock reparation is carried out according to the restorative procedure in step (3) and (4);If the time that can not select Route selection journey, then can not repair the deadlock;
In the step (1), using the function call information of each thread in D during the extraction D generations of DFS searching algorithms.
In the step (3), selected from deadlock D the standard of suitable candidate line for:To other locks in synchronization module The minimum thread of operation amount.
In the step (3), what second was locked is retrieved as in advance:Obtained together with first lock in the thread, Exploratory acquisition operation tryAcq based on lock, can return to whether a lock can be instantly captured at once, if two locks It cannot at the same time obtain, then release immediately the lock wherein obtained, and be attempted next time, until two locks are same When obtain;Synchronous two locks of acquisition are realized using tryAcq, avoid introducing new lock order relation.
In the step (5), the programmed logic destroyed because of obtaining in advance for w of lock is repaired just:According to step (3) Or the thread chosen in (4) is in the operation and step (1) extraction before lock w is obtained in advance to two lock h and w The relation of stream is controlled, there are following five kinds of basic conditions of A, B, C, D, E:
A single entry single exits:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, and obtains behaviour to lock w The acquisition to locking h is had to pass through, then does not add any condition control;
B single entry multiple exit:A certain paths after locking the acquisition of h are contained with the acquisition to locking w, but to lock w's Obtain it is inevitable first obtain lock h, then do not contain on the path to locking w, added to locking w in other after the acquisition of lock h Release operation;
C multiple entries single outlet:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, but to locking the acquisition of w Then after lock w is performed and obtained in advance, a condition can be set to become by being reached without the path for obtaining operation to lock h Measure vwFor true, both the conditional-variable and current thread ID, lock w determine, and recover previous section pair in the step The deletion of original lock w operations, and cause the operation only just to measure v in conditionwValue carry out when being false, finally original Variable v is changed before discharging the operation of wwValue be false;
D multiple entry/multiple exits:Acquisition to locking w is contained to a certain paths after locking the acquisition of h, but to locking w Obtain can by without to lock h obtain operation path reach, then in C adding conditional control on the basis of, to every A acquisition containing to lock h but the operation for not containing addition release w on the path obtained to lock w, and release operation is In C conditional variables vwIt is worth to be performed during true;
E contains loop structure:Lock h is located in for, while loop structure with the acquisition to locking w, then original There is the outside that the release operation to lock w is moved to the loop structure.
In the step (5), the context-aware conditions control added passes through vhwThe acquisition of the lock of control and release Put, be under the protection of the lock w obtained in advance, i.e., it is all to vhwOperation be lock w obtain after and release advance Capable, it can be drawn by 5 fundamental types of A, B, C, D, E.
In the step (3), the reparation for deadlock, is directly changed on source code, the source as program deadlock reparation Code patch;Or directly repaired as patch in the bitcode files of LLVM or the bytecode files of Java.
The present invention compared with prior art the advantages of be:Reparation for program deadlock just has the success rate of higher, at the same time Both new synchrolock will not be introduced, new deadlock will not be introduced, and larger performance will not be caused to reduce problem.
Brief description of the drawings
Fig. 1 realizes flow chart for the present invention's;Two of which set Lp (t) and WNk(t) represent respectively:Thread t its two Between secondary lock operation the set for obtaining the set of operation and other locks being waited and notified is locked to other;
Fig. 2 is the realization for obtaining operation acq (h&w) in advance for locking;
Fig. 3 is the reparation for obtaining operation acq () in synchronization module containing other locks;(a) in Fig. 3 is source program, Fig. 3 In (b) be repair after program;Wherein t1And t2Represent to lock one for two thread Thread, acq (X) and rel (Y) The acquisition operation of X and the release to a lock Y operate, and h and w represent that related linear program is related to two locks of deadlock respectively, P is in two other locks locked among h and w operations;Square frame containing strikethrough and arrow represent the acquisition in advance of lock, W is just obtained in advance in the figure, itself and lock h is obtained together, i.e. acq (h&w);
Fig. 4 is the reparation for waiting wait () notice operations in synchronization module containing lock;(a) in Fig. 4 is source program, Fig. 4 In (b) be repair after program;Wait (k) represents that related linear program needs to wait the notice of another thread on lock k;It is right In the situation of Fig. 4, in addition to the acquisition in advance for the lock w that the square frame containing strikethrough in figure and arrow represent, further relate to The front and rear rel (w) and rel (k) carried out respectively of wait (k);Acq (k&w) is operated;
A kind of realization based on Pthreads for the code that Fig. 5 is controlled for context-aware conditions, with knot in the figure Close the explanation of step of the present invention;
Fig. 6 is five kinds of basic control flow dispositions;
Fig. 7 is the illustration of five kinds of basic conditions in Fig. 6;
Fig. 8 is three programs containing deadlock;
Fig. 9 is recovery scenario of the present invention to three deadlocks in Fig. 8.
Embodiment
As shown in Figure 1, step of the present invention includes:For the per thread t in deadlock, the synchronization module of extraction procedure with And the control flow in synchronization module, calculate in synchronization module to the set of other lock operations;According to obtained set, select Most suitable candidate threads, directly perform and obtain lock operation in advance, and the control of additional context-aware conditions;According to The control flow graph type of the synchronization module of extraction, does respective handling;The program after repairing is performed, if compiling failure, Previous step is then returned to, selects other candidate threads, carries out deadlock reparation operation.If the candidate threads that can not select, So the present invention can not repair the deadlock.
One thread obtains a lock, and the state for waiting another lock to be obtained is the necessary condition that deadlock occurs, thread First lock obtained is known as the h of thread, waits lock to be obtained to be known as the w of thread.
Present invention specific implementation step is as follows:
(1) extract or require user's designated program synchronization module (acq (h) in i.e. each deadlock related linear program with Part between acq (w), is denoted as site (h)~site (w)) and synchronization module in control flow.
(2) set operated in synchronization module site (h)~site (w) of the relevant each thread of deadlock to other locks is calculated, Lp(t) set that acq (p) is operated in the synchronization module of thread t, WN are representedk(t) represent synchronization module in wait (k) and The set of notify (k).
(3) the set L calculated according to step (2) each thread relevant to deadlockp(t) and WNk(t), choose |Lp(t)+WNk(t) | minimum thread performs deadlock reparation operation, i.e., is replaced with acq (h&w) as candidate threads Acq (h) simultaneously deletes acq (w).
If ● | Lp(t)+WNk(t) |=0:Lock is performed to thread t and obtains operation in advance, deadlock reparation is carried out, that is, deletes Acq (w) originally, and w and h are obtained into acq (h&w) together.The operation acq of acquisition in advance (h&w) of lock, uses TryAcq (), the operation can immediately know that whether a lock obtains success, if as shown in Fig. 2, can not obtain two at the same time A lock h and w, then release immediately the lock that (rel ()) has obtained, and avoids introducing new lock sequence.If thread cannot be at the same time Obtain two locks, then the current lock obtained of thread release, circulation perform, until obtaining h and w locks at the same time.
If ● | Lp(t)+WNk(t)|≠0:Context-aware is added being performed to thread t on the basis of lock obtains in advance Condition controls, and carries out deadlock reparation:
There are the operation of other acq (p) in synchronization module, as shown in figure 3, before p is obtained, release first carries The w locks (i.e. rel (w) in figure) of preceding acquisition, then perform acq (p&w) operations again.Utilize context-aware conditions Control, adds a conditional-variable v before rel (w)hwAnd true is assigned a value of to it, it is assigned a value of after acq (p&w) False, while, it is necessary to another thread for needing to obtain w locks is being changed, that is, it is as follows to change its original acq (w): If the acq (w) runs succeeded, the conditional-variable v above set is first determined whetherhwWhether it is true, if true, then Release lock w (i.e. rel (w)), and continues to obtain the lock, and if false, then instruction after continuing to execute is (i.e. from following Jumped out in ring, break operations).Ensure that the thread that lock obtains in advance can obtain lock w with this, but it is related in deadlock Another thread can not really take w lock.
There are wait (k) or notify (k) in synchronization module to operate, as shown in figure 4, with existing in synchronization module Acq (p) operation repair mode it is similar, unlike perform wait (k) operation and or notify (k) operate when, it is necessary to K locks are first discharged, then perform acq (k&w) again, while be also required to set above-mentioned v in the same wayhwCondition and modification Another obtains the thread of w.But there are a special circumstances herein, that is, it is same lock to lock k and lock h, at this time, only in advance Obtain lock w, not just other settings.
" bool acq (Lock*h, Lock*w) " is the realization based on Pthreads of acq (h&w) in Fig. 5, parameter therein " h " and " w " is the lock h and lock w of selected thread respectively.In addition, three method " void in Fig. 5 setHWCondOn(Lock*hLock,Lock*wLock)”、“bool getHWCond(Lock*hLock,Lock* WLock) " and " void setHWCondOff (Lock*hLock, Lock*wLock) " is to conditional-variable vhwThree behaviour A kind of realization based on Pthreads made, corresponds to respectively:V is sethwFor true, v is readhwValue and set vhw For false, parameter " hLock " therein and " wLock " are respectively the lock h of selected thread and lock w.
(4) five basic classes are listed according to the control flow graph type of the synchronization module extracted in step (1), Fig. 6 The processing mode of the specific controlling stream graph of type, Fig. 7 are this five kinds specific examples:
A ((a) in Fig. 7) single entry single exit:Lock w is directly obtained in advance, and deletes original acq (w);
B ((b) in Fig. 7) single entry multiple exit:After acquisition in advance to locking w, in another branch (i.e. if (need_w) Else branches) addition to lock w release rel (w);
C ((c) in Fig. 7) multiple entries single outlet:After acquisition in advance to locking w, conditional-variable v is setwFor true, And the adding conditional if (v on original acq (w)w);
D ((d) in Fig. 7) multiple entry/multiple exit:After acquisition in advance to locking w, conditional-variable v is setwFor true, Adding conditional if (the v on original acq (w)w), and add in another branch (i.e. the else branches of if (need_w)) of acq (h) Add the release rel (w) to locking w;
E ((e) in Fig. 7) contains loop structure:After acquisition in advance to locking w, the rel (w) in circulation is moved to Circulation outside.
Listed in Fig. 5 in the corresponding step to conditional-variable vwThree operation a kind of realizations based on Pthreads, Including " void setPreAcqTaken (Lock*lock) ", " bool preAcqTaken (Lock*lock) ", " void ClearPreAcq (Lock*lock) ", these three operations correspond to respectively:To vwIt is arranged to true, to vwValue reading, V is setwThe lock w obtained in advance is should be for false, the parameter lock in these three realizations.
(5) according to the program performed after repairing, if compiling failure, returns to (3), selects other candidate threads, Carry out deadlock reparation operation.If the candidate threads that can not select, then DFixer can not repair the deadlock;
As Fig. 8 sets forth three program P containing deadlock1,P2,P3, wherein deadlock is respectively D1, D2, D3, Reparation of the invention in these three deadlocks is as shown in figure 9, specific repair process is as follows:
Such as (a) in Fig. 8, for program P1, thread t1With thread t2| Lp(t)+WNk(t) | value be 0, so line Journey t1With thread t2All it is candidate threads, since the control flow of the synchronization module of two threads is all single-input single-output pattern, One of thread can be randomly choosed and directly perform to obtain in advance and lock operation, so as to repair P1Deadlock D in program1。 The two repair modes are shown in (a) in Fig. 9 and (b) in Fig. 9.
Such as (b) in Fig. 8, for program P2, deadlock generation is in thread t1And t2Between, two threads |Lp(t)+WNk(t) | value be 0, so thread t1With thread t2All it is candidate threads.If select thread t2Execution shifts to an earlier date Lock operation is obtained, due to thread t2The control flow of the synchronization module of sum is singly to enter to have more, so will be without acq's (m) Rel (m) operations are added at branch, that is, else branch outlets.(c) in Fig. 9 is the reparation of the deadlock.
Such as (c) in Fig. 8, for program P3, deadlock generation is in thread t1And t2Between, although thread t2Synchronization module Between there are wait (n) to operate, still, since wait (n) is consistent with the object lock that acq (n) is operated, so and P1,P2 It is identical, thread t1With thread t2| Lp(t)+WNk(t) | value be 0, so thread t1With thread t2All it is candidate threads. Since the control flow of the synchronization module of two threads is all single-input single-output pattern, it is straight that one of thread can be randomly choosed Connect execution and obtain lock operation in advance.In (d) in Fig. 9, t have selected2Perform and obtain lock operation in advance.
The present invention on the premise of new deadlock is not introduced, has successfully repaired above three journey by obtaining lock operation in advance Deadlock in sequence.
Validity check:
The characteristic information of 1 each benchmark of table
In order to verify the deadlock repairing effect effect of the present invention, using the data set of 9 benchmark to side of the invention Method is tested, including DB Maintain, Bank Trans., Dining Philo., SQLite, OpenLDAP, and three Different editions MySQL database, wherein first three benchmark only make a search use, remaining benchmark is equal It is as shown in table 1 for the program being widely used in real world, the details of the data set.
Experimental situation:
Experiment carries out on a ThinkPad W540 workbench, it is furnished with Intel Core i7-4710MQ 2.5GHz Processor, 16G memories, operating system Ubuntu14.04.
LLVM is used as platform, realizes method and GA and Grail in the invention.
Experimental procedure:
Table 2.GA, Grail, and DFixer repair comparing result
(1) deadlock of each program is repaired using the restorative procedure in GA, Grail and the present invention respectively, Ran Houyun Program after three method reparations of row and each 100 times of the program do not repaired, the number that deadlock occurs before and after statistics is repaired.In order to Deadlock odds is improved, in the specific location of program, is inserted into the random length of one's sleep.
(2) every kind of restorative procedure and the preprosthetic original program being directed in step 1, count the time of 100 operations (no Add the Random-sleep time);
(3) of the invention and other two kinds of restorative procedure implementation effects are contrasted.
Experimental result:
Table 2 have recorded reparation result of 3 kinds of recovery scenarios to 9 benchmark in detail.
In terms of performance influence, for the deadlock reparation in real world, on average, GA causes 15.8% performance Decline, Grail causes 11.5% hydraulic performance decline, and the method for the present invention has resulted only in 2.1% hydraulic performance decline. In terms of repairing effect, the present invention repairs result to 17 deadlocks in real world and counts again, and GA is successfully repaired A deadlock of 7 (41%) therein, Grail have only successfully repaired a deadlock of 6 (35%) therein, and the side of the present invention Method has successfully repaired a deadlock of 17 (100%).
In conclusion the self-repairing method obtained in advance based on lock proposed in the present invention can be repaired more effectively extremely Lock, and new deadlock will not be introduced, while can only cause the performance of very little to reduce.
Above example is provided just for the sake of the description purpose of the present invention, and is not intended to limit the scope of the present invention.This hair Bright scope is defined by the following claims.The various equivalent substitutions that do not depart from spirit and principles of the present invention and make and repair Change, should all cover within the scope of the present invention.

Claims (5)

1. a kind of deadlock self-repairing method obtained in advance based on lock, it is characterised in that comprise the following steps:
(1) a deadlock D in preset sequence P and P, for the per thread in deadlock D, uses depth-first Search (DFS) searches for and automatically extracts the function call information of each thread in D when deadlock D occurs, which includes Per thread is how to reach deadlock point in D;The function call information may also require that user specifies;Based on this information, Calculate the control flow chart CFG in the synchronization module and synchronization module of per thread, wherein synchronization module in D and refer to D This in per thread, is locked the object of operation by the relevant part obtained twice between lock operation of middle per thread deadlock twice Lock takes following mark:First is denoted as h locks, and second is denoted as w locks;
(2) calculate synchronization module in other lock operation set, the operation include to lock acquisition operation, etc. it is to be operated Wait and notice operation Notify;
(3) according to the set obtained in step (2), suitable candidate threads are selected to perform deadlock reparation from deadlock D Operation:If be related in the thread of deadlock, there are a thread, it is relevant deadlock to obtain between lock operation not twice In the presence of the operation to other locks, second lock w of the directly deadlock relevant operation to the thread performs lock and obtains behaviour in advance Make, and the operation before deletion to second lock w, carry out deadlock reparation;
(4) if not having thread to be selected in step (3), other threads are chosen, it meets that lock obtains twice in the thread Minimum thread is operated to other locks between extract operation, performs and acquisition operation in advance is locked described in step (3), it is in addition attached Add context-aware conditions to control, according to the lock action type between lock h operations and lock w operations, there is following A and B Two kinds of situations:
A:If wherein there is the acquisition operation to other locks, it is p to remember the lock, then before the acquisition to locking p, addition Variable vhw, which determines that the value for setting the variable be true by locking w and h, discharges lock w afterwards, and change original To be retrieved as operating to obtaining while lock p and w to p, variable v is set afterwardshwValue be false;
B:If wherein exist to other locks etc. to be operated or notice operate, remember that the lock is locked for k, then to locking k Before acquisition, variable v is addedhw, the variable by lock w and h determine that the value for setting the variable is true, is discharged afterwards Lock w, and originally to lock k etc. it is to be operated after addition to lock k release operate, and to lock k and lock w it is same When obtain operation, variable v is set afterwardshwValue be false;
(5) after the operation of step (3) or (4), repair the program destroyed because of obtaining in advance for w of lock and patrol Volume;
(6) program after being repaired in step (3) or step (4) is denoted as P';
(7) in addition the program P' after execution is repaired, if compiling failure, returns to (3), selects from deadlock D Candidate threads, deadlock reparation is carried out according to the restorative procedure in step (3) and (4);If the time that can not select Route selection journey, then can not repair the deadlock.
2. the deadlock self-repairing method according to claim 1 obtained in advance based on lock, it is characterised in that:Institute State in step (3), what second was locked is retrieved as in advance:Obtained together with first lock in the thread, based on lock Exploratory acquisition operation tryAcq, can at once return a lock whether can be instantly captured, if two lock cannot be same When obtain, then wherein obtained one lock is released immediately, and attempted next time, until two locks obtain at the same time; Synchronous two locks of acquisition are realized using tryAcq, avoid introducing new lock order relation.
3. the deadlock self-repairing method according to claim 1 obtained in advance based on lock, it is characterised in that:Institute State in step (5), repair the programmed logic destroyed because of obtaining in advance for w of lock:According to step (3) or (4) The middle control stream of operation and step (1) extraction of the thread of middle selection before lock w is obtained in advance to two lock h and w Relation, have following five kinds of basic conditions of A, B, C, D, E:
A single entry single exits:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, and obtains behaviour to lock w The acquisition to locking h is had to pass through, then does not add any condition control;
B single entry multiple exit:A certain paths after locking the acquisition of h are contained with the acquisition to locking w, but to lock w's Obtain it is inevitable first obtain lock h, then do not contain on the path to locking w, added to locking w in other after the acquisition of lock h Release operation;
C multiple entries single outlet:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, but to locking the acquisition of w Then after lock w is performed and obtained in advance, a condition can be set to become by being reached without the path for obtaining operation to lock h Measure vwFor true, which is determined by both current thread ID, lock w, and recovers previous section pair in the step The deletion of original lock w operations, and cause the operation only in conditional-variable vwValue carry out when being false, finally original Variable v is changed before discharging the operation of wwValue be false;
D multiple entry/multiple exits:Acquisition to locking w is contained to a certain paths after locking the acquisition of h, but to locking w Obtain can by without to lock h obtain operation path reach, then in C adding conditional control on the basis of, to every A acquisition containing to lock h but the operation for not containing addition release w on the path obtained to lock w, and release operation is In C conditional variables vwIt is worth to be performed during true;
E contains loop structure:Lock h is located in for, while loop structure with the acquisition to locking w, then original There is the outside that the release operation to lock w is moved to the loop structure.
4. the deadlock self-repairing method according to claim 3 obtained in advance based on lock, it is characterised in that:Institute State in step (4), the context-aware conditions control added passes through vhwThe acquisition and release of the lock of control, are It is under the protection of the lock w obtained in advance, i.e., all to vhwOperation be lock w obtain after and release before carry out, It can be drawn by 5 fundamental types of A, B, C, D, E.
5. the deadlock self-repairing method according to claim 3 obtained in advance based on lock, it is characterised in that:The step Suddenly in (3), the reparation for deadlock, is directly changed on source code, the source code patch as program deadlock reparation; Or directly repaired as patch in the bitcode files of LLVM or the bytecode files of Java.
CN201610069697.7A 2016-02-01 2016-02-01 A kind of deadlock self-repairing method obtained in advance based on lock Active CN105786703B9 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610069697.7A CN105786703B9 (en) 2016-02-01 2016-02-01 A kind of deadlock self-repairing method obtained in advance based on lock

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610069697.7A CN105786703B9 (en) 2016-02-01 2016-02-01 A kind of deadlock self-repairing method obtained in advance based on lock

Publications (3)

Publication Number Publication Date
CN105786703A CN105786703A (en) 2016-07-20
CN105786703B CN105786703B (en) 2018-02-09
CN105786703B9 true CN105786703B9 (en) 2018-04-13

Family

ID=56403224

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610069697.7A Active CN105786703B9 (en) 2016-02-01 2016-02-01 A kind of deadlock self-repairing method obtained in advance based on lock

Country Status (1)

Country Link
CN (1) CN105786703B9 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937365A (en) * 2009-06-30 2011-01-05 国际商业机器公司 Deadlock detection method of parallel programs and system
CN102073588A (en) * 2010-12-28 2011-05-25 北京邮电大学 Code static analysis based multithread deadlock detection method and system
CN104978272A (en) * 2015-07-08 2015-10-14 中国科学院软件研究所 Program scheduling method for data race detection

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937365A (en) * 2009-06-30 2011-01-05 国际商业机器公司 Deadlock detection method of parallel programs and system
CN102073588A (en) * 2010-12-28 2011-05-25 北京邮电大学 Code static analysis based multithread deadlock detection method and system
CN104978272A (en) * 2015-07-08 2015-10-14 中国科学院软件研究所 Program scheduling method for data race detection

Also Published As

Publication number Publication date
CN105786703B (en) 2018-02-09
CN105786703A (en) 2016-07-20

Similar Documents

Publication Publication Date Title
Abdulla et al. Optimal dynamic partial order reduction
Nagarakatte et al. Multicore acceleration of priority-based schedulers for concurrency bug detection
US8972999B2 (en) Method and system for detecting program deadlock
US20070094541A1 (en) Method and apparatus for generating test execution sequences automatically for a software testing process
CN105868116A (en) Semantic mutation operator based test case generation and optimization method
CN104978272B (en) A kind of program scheduler method for data contention detection
Giffhorn Slicing of concurrent programs and its application to information flow control
Adir et al. Verification of transactional memory in power8
Maeoka et al. Depth-first heuristic search for software model checking
CN106227656B (en) A kind of data contention sample detecting method based on hardware and thread-local sequential
CN106844215B (en) Atom violation detection method based on constraint solving
CN105786703B9 (en) A kind of deadlock self-repairing method obtained in advance based on lock
CN111124694A (en) Reachable graph deadlock detection and solution method based on petri net
CN104145249B (en) Method and system for debugging computer program
CN105183633A (en) Method and system for generating test case
Vakkalanka et al. Reduced execution semantics of MPI: From theory to practice
Li et al. Automatically generating functional scenarios from SOFL CDFD for specification inspection
Horlings et al. Analysis of specifications of multiparty sessions with dcj-lint
CN110162967A (en) A kind of memory timing error means of defence based on MPX
Wu et al. A hybrid learnt clause evaluation algorithm for SAT problem
Razavi et al. Bounded-interference sequentialization for testing concurrent programs
Soltanieh et al. Compositional Model Checking and Model Repair for a Class of Product Form Models
Chin et al. A heuristic region-based concurrency bug testing approach
CN109634834B (en) Method and device for verifying exclusive access in synchronous multithreading system
Wu et al. Homology detection based on abstract syntax tree combined simple semantics analysis

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
CI03 Correction of invention patent
CI03 Correction of invention patent

Correction item: Claims

Correct: Zheng Que

False: Cuo Wu

Number: 06-02

Page: Quan Wen

Volume: 34