CN105786703B - 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 PDFInfo
- Publication number
- CN105786703B CN105786703B CN201610069697.7A CN201610069697A CN105786703B CN 105786703 B CN105786703 B CN 105786703B CN 201610069697 A CN201610069697 A CN 201610069697A CN 105786703 B CN105786703 B CN 105786703B
- Authority
- CN
- China
- Prior art keywords
- lock
- deadlock
- acquisition
- thread
- advance
- 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
- 238000000034 method Methods 0.000 title claims abstract description 32
- 230000008439 repair process Effects 0.000 claims abstract description 18
- 238000000605 extraction Methods 0.000 claims abstract description 6
- 230000006870 function Effects 0.000 claims description 5
- 230000008859 change Effects 0.000 claims description 4
- 230000004048 modification Effects 0.000 claims description 3
- 238000012986 modification Methods 0.000 claims description 3
- 230000001360 synchronised effect Effects 0.000 claims description 3
- 230000009471 action Effects 0.000 claims description 2
- 238000012217 deletion Methods 0.000 claims 2
- 230000037430 deletion Effects 0.000 claims 2
- 235000013399 edible fruits Nutrition 0.000 claims 1
- 238000007792 addition Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 230000000694 effects Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 4
- 239000011800 void material Substances 0.000 description 4
- 230000007423 decrease Effects 0.000 description 3
- 238000011084 recovery Methods 0.000 description 3
- 230000003068 static effect Effects 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000002474 experimental method Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 241000208340 Araliaceae Species 0.000 description 1
- 235000005035 Panax pseudoginseng ssp. pseudoginseng Nutrition 0.000 description 1
- 235000003140 Panax quinquefolius Nutrition 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000006731 degradation reaction Methods 0.000 description 1
- 235000008434 ginseng Nutrition 0.000 description 1
- 238000003780 insertion Methods 0.000 description 1
- 230000037431 insertion Effects 0.000 description 1
- 230000015654 memory Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3636—Software 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, calculate 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, a thread be present, the operation to other locks be not present 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 deadlock of the invention in the case where not introducing new lock, gone in repair procedure.It can prove in theory, the present invention will not introduce new deadlock, not introduce new deadlock during 20 deadlocks are successfully repaired, and serious performance will not be caused to reduce problem.
Description
Technical field
The invention belongs to software testing technology field and software reliability field, more particularly in multithread programs deadlock from
Dynamic restorative procedure.
Background technology
With widely using for multi-core CPU, it is certain concomitantly to handle that increasing software has used multithreading
Task.But multithread programs need each thread synchronously to complete some task well in the process of running.When these
When synchronization between thread occurs wrong, the generation of concurrent defect is may result in, deadlock (Deadlock) is exactly most basic one
The concurrent defect of kind.
Deadlock is commonly divided into resource deadlock (resource deadlock) and communication deadlock (communication
Deadlock) two major class, communication deadlock be often as to information send with reception Buffer competition and it is caused;Resource is dead
Lock, i.e. two or more thread is when concurrently performing, because the resource for each needing to ask is by them
Other threads occupy, and cause mutually to wait, the state that can not be continued to run with.Present invention is generally directed to the reparation of resource deadlock.It is main
The deadlock recovery technique of stream, mostly transported by the new lock of static or dynamic insertion to serialize the thread in concurrence error
OK, so as to repairing deadlock (these repair modes are referred to as GA).Although such repair mode is very simple, in reparation
During, easily introduce new deadlock;And the mode of deadlock is repaired in this serialization utilized between thread, it is most likely that
Reduce performance and efficiency that program performs.Grail (FSE 2014) is also by adding a new lock in outer layer to carry out deadlock
Repair, unlike, the new lock of Grail additions is not static, but the object lock with deadlock occurs is relevant.Grail exists
The performance issue repaired and brought is reduced to a certain extent, but can still introduce new deadlock.Therefore, static or dynamic is passed through
To add new lock in outer layer be not optimal deadlock restorative procedure.
The content of the invention
The technology of the present invention solves problem:Overcome the deficiencies in the prior art, there is provided a kind of deadlock obtained in advance based on lock is certainly
Dynamic restorative procedure (present invention is directed to the automatic reparation of resource deadlock), do not introducing new deadlock (including resource deadlock and communication
Deadlock) on the premise of, all deadlocks are successfully repaired, and test and show, automatic reparation of the invention will not cause serious
Degradation problem.
The technology of the present invention solution:A kind of deadlock self-repairing method DFixer obtained in advance based on lock, by carrying
The synchronization module and control flow of the related thread of deadlock are taken, calculates in each synchronization module to the operational set of other locks, selects
Suitable candidate threads, perform lock and obtain operation in advance, in the case where avoiding adding new lock, successfully repair all deadlocks,
And avoid introducing new deadlock (resource deadlock and communication deadlock), comprise the following steps:
(1) a deadlock D in preset sequence P and P, for each thread in deadlock D, carried automatically using DFS search
When taking the deadlock D to occur in D each thread function call information, the packet contains each thread in D is how to reach deadlock point
's;The function call information may also require that user specifies;Based on this information, the synchronous mould of each thread in the D of calculation procedure
Control flow chart CFG in block and synchronization module, wherein synchronization module refer to the acquisition twice that each thread deadlock is related in D
Part between lock operation, the object lock that this in each thread is locked to operation twice take following mark:First is denoted as h locks,
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 behaviour from deadlock D
Make:If be related in the thread of deadlock, a thread be present, be not present between the related lock operation of acquisition twice of itself and deadlock pair
The operation of other locks, lock acquisition operation, and delete it in advance directly is performed to second lock w of the deadlock associative operation of the thread
The preceding operation 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 operation, performs and acquisition operation in advance is locked described in step (3), add in addition
Context-aware conditions control, and according to the lock action type between lock h operations and lock w operations, there is following two kinds of feelings of A and B
Condition:
A:If the acquisition operation to other locks wherein be present, it is p to remember the lock, then before the acquisition to locking p, adds variable
vhw, the variable by lock w and h determines that the value for setting knots modification be true, afterwards release lock w, and modification p was retrieved as originally
To obtaining operation while lock p and w, variable v is set afterwardshwValue be false;
B:If wherein exist to other locks etc. it is to be operated or notice operate, remember the lock for k lock, then to lock k obtain
Before taking, variable v is addedhw, the variable determines that the value for setting the variable be true by locking w and h, discharges lock w afterwards, and in original
Come to lock k etc. it is to be operated after addition to lock k release operate, and to lock k and lock w while obtain operate, Zhi Houshe
Put variable vhwValue be false;
(5) after the operation of step (3) or (4), the programmed logic destroyed because of obtaining in advance for w of lock is repaired;
(6) program after being repaired in step (3) or step (4) is denoted as P';
(7) the program P' after repairing is performed, if compiling failure, returns to (3), other candidate is selected from deadlock D
Thread, deadlock reparation is carried out according to the restorative procedure in step (3) and (4);If the candidate threads that can not select, nothing
Method repairs 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:Other locks are grasped in synchronization module
Make the thread of minimum number.
In the step (3), what second was locked is retrieved as in advance:Obtained together with first lock in the thread, base
TryAcq is operated in the exploratory acquisition of lock, can return to whether a lock can be instantly captured at once, if two locks can not
Obtain simultaneously, then discharge the lock wherein obtained immediately, and attempted next time, until simultaneously two locks 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
(4) operation and the pass of the middle controlling stream of step (1) extraction of the thread chosen in before lock w is obtained in advance to two lock h and w
, there are following five kinds of basic conditions of A, B, C, D, E in system:
A single entry single exits:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, and obtains operation 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 h acquisition are contained with the acquisition to locking w, but lock w is obtained
Take it is inevitable first obtain lock h, then do not contained in other after lock h acquisition on the path to locking w, add and the release for locking w is grasped
Make;
C multiple entries single outlet:Acquisition operation to lock h necessarily causes to operate the acquisition for locking w, but the acquisition to locking w can
By being reached without the path that operation is obtained to lock h, then after lock w is performed and obtained in advance, to set a conditional-variable vwFor
Both true, the conditional-variable and current thread ID, lock w are determined, and recover what previous section in the step operated to original lock w
Delete, and cause the operation only just to measure v in conditionwValue carry out when being false, finally changed before original release w operation
Variable vwValue be false;
D multiple entry/multiple exits:A certain paths after locking h acquisition are contained with the acquisition to locking w, but lock w is obtained
Take can be by reaching, then in C on the basis of adding conditional control, to each containing right without the path that operation is obtained to lock h
Lock h acquisition 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
Release operation to lock w is moved to the outside of 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 lock w obtained in advance protection, i.e., it is all to vhwOperation be lock w obtain after and release before carry out, can
Drawn by 5 fundamental types of A, B, C, D, E.
In the step (3), the reparation for deadlock, directly changed on source code, the source generation as program deadlock reparation
Code patch;Or directly repaired as patch in LLVM bitcode files or Java bytecode files.
The present invention compared with prior art the advantages of be:Reparation for program deadlock just has higher success rate, together
When will not both introduce new synchrolock, will not also introduce new deadlock, and larger performance will not be caused to reduce problem.
Brief description of the drawings
Fig. 1 is the implementation process figure of the present invention;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, in Fig. 3
(b) be repair after program;Wherein t1And t2Represent to obtain a lock X for two thread Thread, acq (X) and rel (Y)
Extract operation and the release operation to a lock Y, h and w represent that related linear program is related to two locks of deadlock respectively, and p is to lock h at two
With other locks among w operations;Square frame containing strikethrough and arrow represent the acquisition in advance of lock, w are just carried in the figure
Preceding acquisition, itself and lock h is set to obtain 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;For
Fig. 4 situation, in addition to the acquisition in advance for the lock w that the square frame containing strikethrough in figure and arrow represent, further relate in wait (k)
The front and rear rel (w) carried out respectively and rel (k);Acq (k&w) is operated;
A kind of realization based on Pthreads for the code that Fig. 5 controls for context-aware conditions, have in the figure
With reference to 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 each thread t in deadlock, the synchronization module of extraction procedure and
Control flow in synchronization module, calculate the set to other lock operations in synchronization module;According to obtained set, select and most close
Suitable candidate threads, directly perform and obtain lock operation in advance, and the control of additional context-aware conditions;According to extraction
The control flow graph type of synchronization module, does respective handling;The program after repairing is performed, if compiling failure, returns to one
Step, other candidate threads are selected, carry out deadlock reparation operation.If the candidate threads that can not select, then the present invention
The deadlock can not be repaired.
One thread obtains a lock, and the state for waiting another lock to be obtained is the necessary condition that deadlock occurs, line
First lock that journey obtains is referred to as the h of thread, waits lock to be obtained to be referred to as the w of thread.
Present invention specific implementation step is as follows:
(1) extract or require synchronization module (acq (h) and acq in i.e. each deadlock related linear program of user's designated program
(w) part between, be designated as site (h)~site (w)) and synchronization module in control flow.
(2) calculate in synchronization module site (h)~site (w) of the related each thread of deadlock to the collection of other lock operations
Close, Lp(t) set that acq (p) is operated in thread t synchronization module, WN are representedk(t) represent synchronization module in wait (k) and
Notify (k) set.
(3) the set L calculated according to step (2) the related each thread of deadlockpAnd WN (t)k(t), choose | Lp(t)+
WNk(t) | minimum thread performs deadlock reparation operation, i.e., is replaced acq (h) with acq (h&w) and deleted as candidate threads
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, using tryAcq (),
The operation can immediately know that whether a lock obtains success, if as shown in Fig. 2 can not obtain simultaneously two lock h and w,
The lock that release (rel ()) has obtained immediately, avoids introducing new lock sequence.If thread can not obtain two locks simultaneously, then
The current lock obtained of thread release, circulation perform, until obtaining h and w locks simultaneously.
If ● | Lp(t)+WNk(t)|≠0:Context- is added being performed to thread t on the basis of lock obtains in advance
Aware conditions control, and carry out deadlock reparation:
Other acq (p) operations in synchronization module be present, as shown in figure 3, before p is obtained, discharge obtain in advance first
W lock (i.e. rel (w) in figure), then perform again acq (p&w) operate.Controlled using context-aware conditions, in rel (w)
One conditional-variable v of preceding additionhwAnd true is entered as to it, be entered as false to it after acq (p&w), while, it is necessary to
Another thread for needing to obtain w locks is changed, that is, it is as follows to change its original acq (w):If the acq (w) runs succeeded,
Then first determine whether the conditional-variable v above sethwWhether it is true, if true, then release lock w (i.e. rel (w)), and continuing
The lock is obtained, if false, then the instruction (being jumped out from circulation, break operations) after continuing executing with.Ensure to lock with this
The thread obtained in advance can obtain lock w, but another thread related in deadlock can not really take w locks.
Wait (k) or notify (k) operations in synchronization module be present, 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 change another
Obtain w thread.But there are individual special circumstances herein, that is, it is same lock to lock k and lock h, now, only obtains lock w in advance, not just
Other settings.
" bool acq (Lock*h, Lock*w) " is acq (h&w) realization based on Pthreads in Fig. 5, ginseng therein
Number " h " and " w " is the lock h and lock w of selected thread respectively.In addition, three method " void setHWCondOn in Fig. 5
(Lock*hLock, Lock*wLock) ", " bool getHWCond (Lock*hLock, Lock*wLock) " and " void
SetHWCondOff (Lock*hLock, Lock*wLock) " is to conditional-variable vhwThree operation one kind be based on
Pthreads realization, is corresponded to respectively:V is sethwFor true, v is readhwValue and set vhwFor false, parameter therein
" hLock " and " wLock " is the lock h and lock w of selected thread respectively.
(4) five fundamental types are listed according to the control flow graph type of the synchronization module extracted in step (1), Fig. 6
Specific controlling stream graph processing mode, Fig. 7 is this five kinds specific example:
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:To lock w acquisition in advance after, another branch (i.e. if's (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
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, in original
There are adding conditional if (v on acq (w)w), and added in acq (h) another branch (i.e. if (need_w) else branches) to lock
W release rel (w);
E ((e) in Fig. 7) contains loop structure:After acquisition in advance to locking w, the rel (w) in circulation is moved to and followed
Outside ring.
Listed in Fig. 5 to should be in step to conditional-variable vwThree operation a kind of realities based on Pthreads
It is existing, 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, set
vwThe 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, enter
The reparation of row deadlock operates.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, the present invention
These three deadlocks reparation 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, can be with because the control flow of the synchronization module of two threads is all single-input single-output pattern
Randomly choose one of thread and directly perform to obtain in advance and lock operation, so as to repair P1Deadlock D in program1.The two are repaired
Mode is 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 t2Perform and obtain lock operation in advance,
Due to thread t2The control flow of the synchronization module of sum is singly to enter to have more, so to be else branches in the branch without acq (m)
Exit addition rel (m) operations.(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 wait (n) be present and operate, still, because wait (n) is consistent with the object lock that acq (n) is operated, so and P1,P2Phase
Together, thread t1With thread t2| Lp(t)+WNk(t) | value be 0, so thread t1With thread t2All it is candidate threads.Due to
The control flow of the synchronization module of two threads is all single-input single-output pattern, can randomly choose one of thread and directly perform
Lock operation is obtained 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 by obtaining lock operation in advance
Deadlock in program.
Validity check:
1 each benchmark of table characteristic information
In order to verify the deadlock repairing effect effect of the present invention, using 9 benchmark data set 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, and remaining benchmark is true generation
The program being widely used in boundary, the details of the data set are as shown in table 1.
Experimental situation:
Experiment is carried out on a ThinkPad W540 workbench, and it is furnished with Intel Core i7-4710MQ
2.5GHz processors, 16G internal 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, then
Program after three method reparations of operation and each 100 times of the program do not repaired, the number that deadlock occurs before and after statistics is repaired.For
Raising deadlock odds, in the ad-hoc location of program, inserts the random length of one's sleep.
(2) every kind of restorative procedure and the preprosthetic original program being directed in step 1, the time of 100 operations is counted
(not adding 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 impact, 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.Repairing
In terms of effect, the present invention repairs result to 17 deadlocks in real world and counted again, and GA has successfully repaired therein 7
(41%) individual deadlock, Grail has only successfully repaired the individual deadlock of 6 (35%) therein, and the method for the present invention has successfully repaired 17
(100%) individual deadlock.
In summary, 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
The scope of invention 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, all should 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)Preset sequencePWithPIn a deadlockD, for deadlockDIn each thread, use depth-first search(DFS)
Search for and automatically extract deadlockDDuring generationDIn each thread function call information, the packet containsDIn each thread be as
What reaches deadlock point;The function call information may also require that user specifies;Based on this information, calculateDIn each thread
Control flow chart in synchronization module and synchronization moduleCFG, wherein synchronization module refers toDIn each thread deadlock it is related two
The secondary part obtained between lock operation, the object lock that this in each thread is locked to operation twice take following mark:First note
MakehLock, second is denoted aswLock;
(2)Calculate synchronization module in other lock operation set, the operation include to lock acquisition operation, etc. it is to be operatedWaitAnd notice operationNotify;
(3)According to step(2)In obtained set, from deadlockDThe middle suitable candidate threads of selection perform deadlock reparation operation:Such as
Fruit is related in the thread of deadlock, a thread be present, and it is not present to other between the lock operation of acquisition twice of deadlock correlation
The operation of lock, directly second lock to the deadlock associative operation of the threadwPerform lock and obtain operation in advance, and it is right before deletion
Second lockwOperation, carry out deadlock reparation;
(4)If step(3)In there is no thread to be selected, then choose other threads, it meets in the thread that lock obtains operation twice
Between minimum thread is operated to other locks, perform step(3)Described in lock in advance obtain operation, in addition add context-
Aware conditions control, according to lockhOperation and lockwLock action type between operation, there are following two kinds of situations of A and B:
A:If the acquisition operation to other locks wherein be present, remember that the lock isp, then to lockpAcquisition before, add variablev hw ,
The variable is by lockingwWithhDetermine, the value for setting the variable istrue, lock is discharged afterwardsw, and modification is original rightpBe retrieved as to lockpWithwWhile obtain operation, variable is set afterwardsv hw Value befalse;
B:If wherein exist to other locks etc. it is to be operated or notice operate, remember that the lock iskLock, then to lockkAcquisition it
Before, add variablev hw , the variable is by lockingwWithhDetermine, the value for setting the variable istrue, lock is discharged afterwardsw, and original right
LockkEtc. it is to be operated after addition to lockkRelease operation, and to lockkAnd lockwWhile obtain operation, afterwards set become
Amountv hw Value befalse;
(5)In step(3)Or(4)Operation after, repair because lockwThe programmed logic for obtaining and destroying in advance;
(6)By step(3)Or step(4)Program after middle reparation is denoted asP';
(7)Perform the program after repairingP'If compiling failure, is returned to(3), from deadlockDThe other candidate threads of middle selection,
According to step(3)With(4)In restorative procedure carry out deadlock reparation;If the candidate threads that can not select, it can not repair
The multiple deadlock.
2. the deadlock self-repairing method according to claim 1 obtained in advance based on lock, it is characterised in that:The step
(3)In, what second was locked is retrieved as in advance:Obtained together with first lock in the thread, the exploratory acquisition based on lock
OperationtryAcq, can return to whether a lock can be instantly captured at once, if two locks can not obtain simultaneously, release immediately
The lock wherein obtained is put, and is attempted next time, until simultaneously two locks obtain;UsingtryAcqRealize synchronous
Two locks are obtained, 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:The step
(5)In, repair because lockwThe programmed logic for obtaining and destroying in advance:According to step(3)Or(4)The thread of middle selection is being lockedw
To two lock before obtaining in advancehWithwOperation and step(1)The relation of the middle controlling stream of extraction, has as followsA、B、C、D、E
Five kinds of basic conditions:
A single entry single exits:To lockhAcquisition operation necessarily cause to lockwAcquisition operation, and to lockwIt is necessary to obtain operation
By to lockhAcquisition, then do not add the control of any condition;
B single entry multiple exit:To lockhAcquisition after a certain paths contain to lockwAcquisition, but to lock w acquisition must
So first obtain lockh, then lockinghAcquisition after it is other do not contain to lockwPath on, add to lockwRelease operation;
C multiple entries single outlet:To lockhAcquisition operation necessarily cause to lockwAcquisition operation, but to lockwAcquisition can be by
Without to lockhThe path for obtaining operation reaches, then is lockingwPerform after obtaining in advance, a conditional-variable is setv w Fortrue,
The conditional-variable is by current thread ID, lockwBoth determine, and recover in the step previous section to original lockwThe deletion of operation,
And cause the operation only in conditional-variablev w Value befalseShi Jinhang, finally change variable before original release w operationv w
Value befalse;
D multiple entry/multiple exits:To lockhAcquisition after a certain paths contain to lockwAcquisition, but to lockwAcquisition can
With by without to lockhThe path for obtaining operation reaches, then in C on the basis of adding conditional control, to each containing to lockh's
Obtain but do not contain to lockwRelease is added on the path of acquisitionwOperation, and the release operation be in C conditional variablesv w Value
FortrueShi Zhihang;
E contains loop structure:To lockhWith to lockwAcquisition be located at onefor、whileIn loop structure, then original to lockw
Release operation be moved to the outside of the loop structure.
4. the deadlock self-repairing method according to claim 1 obtained in advance based on lock, it is characterised in that:The step
(4)In, the context-aware conditions control added passes throughv hw The acquisition and release of the lock of control, are obtained in advance
LockwProtection under, i.e., it is all rightv hw Operation be to lockwCarried out after acquisition and before release, can be 5 by A, B, C, D, E
Fundamental type is drawn.
5. the deadlock self-repairing method according to claim 1 obtained in advance based on lock, it is characterised in that:The step
(3)In, the reparation for deadlock, directly changed on source code, the source code patch as program deadlock reparation;Or LLVM's
Bitcode files or Java bytecode files are directly repaired as patch.
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 true CN105786703B (en) | 2018-02-09 |
CN105786703B9 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)
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 |
-
2016
- 2016-02-01 CN CN201610069697.7A patent/CN105786703B9/en active Active
Patent Citations (3)
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 |
---|---|
CN105786703A (en) | 2016-07-20 |
CN105786703B9 (en) | 2018-04-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Abdulla et al. | Optimal dynamic partial order reduction | |
CN105868116B (en) | Test cases technology based on semantic variation operator and optimization method | |
US8972999B2 (en) | Method and system for detecting program deadlock | |
US8972994B2 (en) | Method and apparatus to bypass object lock by speculative execution of generated bypass code shell based on bypass failure threshold in managed runtime environment | |
Groote et al. | An O (m log n) algorithm for computing stuttering equivalence and branching bisimulation | |
CN104461871B (en) | A kind of deadlock detection method netted based on petri | |
Kaiser et al. | A widening approach to multithreaded program verification | |
CN105975377B (en) | A kind of method and device for monitoring memory | |
CN109669858B (en) | Program deadlock test method, device and equipment | |
Jaiganesh et al. | A high-performance connected components implementation for GPUs | |
CN108628600B (en) | Software dynamic behavior modeling method and device based on control flow analysis | |
CN104978272B (en) | A kind of program scheduler method for data contention detection | |
CN107886000B (en) | A kind of software vulnerability detection method, response at different level method and software bug detection system | |
JP6205168B2 (en) | System and method for parallel model checking utilizing parallel structured duplicate detection | |
CN106227656B (en) | A kind of data contention sample detecting method based on hardware and thread-local sequential | |
Abdulla et al. | Parameterized verification under TSO is PSPACE-complete | |
CN105786703B (en) | A kind of deadlock self-repairing method obtained in advance based on lock | |
US8490098B2 (en) | Concomitance scheduling commensal threads in a multi-threading computer system | |
CN111124694A (en) | Reachable graph deadlock detection and solution method based on petri net | |
CN116861433A (en) | No GIL parallel-based intelligent Ethernet contract transaction defect detection method and device | |
CN108345505B (en) | Multithreading resource management method and system | |
CN107003954A (en) | Synchronization in computing device | |
Bérard et al. | When are timed automata weakly timed bisimilar to time Petri nets? | |
Ferris et al. | WalkSAT as an Informed Heuristic to DPLL in SAT Solving | |
CN107193535A (en) | Based on the parallel implementation method of the nested cyclic vector of SIMD extension part and its device |
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: Error Number: 06-02 Page: full text Volume: 34 |