On Friday 27 September 2013 15:01:54 Phil Longstaff wrote:
> I was thinking about this one last night, and it's trickier than I first
> thought.
> 
> L = lock, T = trylock
> Thread1: L1 L2
> Thread2: L2 T1
> 
> Not a deadlock because the trylock will just fail.  However, suppose we
> have:
> 
> Thread1: L1 L2
> Thread2: L2 T1
> 
> And then later:
> 
> Thread 3: L1 L2
> 
> When helgrind handles L2, it would already find the graph edge L1 -> L2 so
> wouldn't it just return since that is the "correct order"?  David sent me
> some past e-mail and I saw some comments about putting lock vs trylock into
> the graph.  Seems to me that when processing T2, helgrind would not report
> a problem, but would add the T2 -> L1 link, and would also need to ensure
> that if L1 -> L2 happens in the future, it is reported.

A failing trylock cannot create a dead lock.
Only a succesful one, can.

So the question is whether we can assume a failed trylock could have succeeded 
in creating a deadlock if it hadn't failed.
In your particular example, we can.
In many other cases, we can't know that "what happened after the failed 
trylock" would have happened too, if it had succeded. There could be an if() 
statement :-)

So IMHO it's much easier to just drop failed trylocks and only remember 
successful ones, but yes, one can refine that for the case above, i.e. when 
the failed-trylock is the last thing in the chain.

If anything happens *after* a failed trylock, then one can't store a
"T1 -> anything" link.

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to