Search the web
Sign In
New User? Sign Up
testdrivendevelopment · Test-driven Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Mocking Challenge: Article in DDJ   Message List  
Reply | Forward Message #13789 of 32013 |
I'm cross-posting this to testdrivendevelopment, agile-testing, and
extremeprogramming.

In the January 2006 Issue of Dr. Dobb's Journal, Tomer Abramson
presents an article, "Detecting Potential Deadlocks". It's certainly
possible to purchase a PDF of the whole issue; I'm not sure whether
the article is fully available free on line or not. Check
http://www.ddj.com/documents/s=9938/ddj0601n/0601n.html .

The article describes a "Deadlock Detection Application", written as
a DLL for Visual C++ 6 under Windows 2000. It works by hooking
references to shared resource mutexes, and logging all locks and
releases by all threads. Then an analysis program looks at the
sequences of locks and computes whether there are cycles in any
sequence. If there is, this represents a potential deadlock, and the
program reports on it.

Now, in general, testing is a weak way to detect deadlocks, since
conventional tests can run forever and never encounter a deadlock
that will happen in real life. Threading and deadlock detection are,
so far, areas where TDD techniques, and other approaches commonly
used in Agile software development, have not been very helpful.

It seems to me that it might be possible for a Mock Object expert or
experts to build some mock objects that could be clicked into place
instead of conventional mutex access, record the sequence of events,
and then produce an analysis of whether there were potential
deadlocks in the program.

It seems to me that it ought to be possible, and if it were done, it
would be both a valuable contribution, and a demonstration of the
kind of place where mocks are clearly advantageous.

Consider yourselves challenged!

Ron Jeffries
www.XProgramming.com
He who will not apply new remedies must expect old evils. -- Francis Bacon



Sun Dec 18, 2005 4:19 pm

ronaldejeffries
Offline Offline
Send Email Send Email

Forward
Message #13789 of 32013 |
Expand Messages Author Sort by Date

I'm cross-posting this to testdrivendevelopment, agile-testing, and extremeprogramming. In the January 2006 Issue of Dr. Dobb's Journal, Tomer Abramson ...
Ron Jeffries
ronaldejeffries
Offline Send Email
Dec 18, 2005
4:20 pm

... That's an interesting challenge. Mocking the mutexes is the easy part. The hard part is identifying accesses to the same mutex from multiple threads *in a ...
Anthony Williams
anthony_w.geo
Offline Send Email
Dec 19, 2005
2:22 pm

It would be nice to have a framework within which one could TDD multithreaded apps more easily. Decoupling from the platform's threading related classes is...
Adam Dymitruk
adymitruk
Offline Send Email
Dec 19, 2005
6:55 pm

... In java, using the Executor class is the key. In the unit test, the Executor can either be a direct executor (i.e. executes the task immediately on the...
Neil Swingler
neil_swingler
Online Now Send Email
Dec 20, 2005
1:04 am

Googling I found :- http://devnet.developerpipeline.com/documents/s=9843/q=1/ddj0601n/0601n.html .... [Non-text portions of this message have been removed]...
Keith Nicholas
keith.nicholas@...
Send Email
Dec 20, 2005
3:24 am

... That's it! Have your mock-lock record in a list all lock-requests. It would also need to record sleep and wake requests. Separate the requests according...
Alan Baljeu
alanbaljeu
Offline Send Email
Dec 20, 2005
2:26 pm

My appraoch was to say that you must lock in the same order in all threads, I think that this usually works best, and, I believe, gurantee 100% no locks. ... ...
Ayende@...
ayende_tdd
Offline Send Email
Dec 20, 2005
2:29 pm

... Do you mean, no *dead*locks? Yeah if all locking must follow the sequence a b c d e then you would be safe from deadlocks. (eg. thread1: a b d, thread2: c...
Alan Baljeu
alanbaljeu
Offline Send Email
Dec 20, 2005
2:46 pm

Yeah, I was talking about no deadlocks :-) No determinism is inherit to threads, I don't think you can escape it., ... From: "Alan Baljeu"...
Ayende@...
ayende_tdd
Offline Send Email
Dec 20, 2005
4:28 pm

... But you can escape non-determinism with a synchronizing lock. That's half of what my post demonstrated. In a test-scenario, you can program a desired...
Alan Baljeu
alanbaljeu
Offline Send Email
Dec 20, 2005
5:13 pm

What are you trying to test? That is the question. If you're trying to verify that the threads can't get into a deadlock, that is possible to do both multi &...
Ayende Rahien
ayende_tdd
Offline Send Email
Dec 20, 2005
5:58 pm

... I guess I'm off the original subject of the thread, which was deadlock detection, and onto the subject of correct multi-threaded applications. ... This was...
Alan Baljeu
alanbaljeu
Offline Send Email
Dec 20, 2005
6:37 pm

See below ... This is a much harder point, and (disregarding special circumstances) very hard to do. In some cases, you may be able to run a threading specific...
Ayende Rahien
ayende_tdd
Offline Send Email
Dec 20, 2005
6:58 pm

I am not an expert on multi-threading. But I did have a kind of incomplete thought that there might be a way of probabalistically testing such situations by...
Anderson, Kelly
kellycoinguy
Online Now Send Email
Dec 22, 2005
12:53 am

There is such a system, it's call the scheduler. As far as I know, the NT guys at Microsoft and the Unix guys all over the world sweated for years until they...
Ayende Rahien
ayende_tdd
Offline Send Email
Dec 22, 2005
5:18 am

... Cool! Did they also cover the case of finding all bugs in a multithreaded application with one thread? :-)...
Alan Baljeu
alanbaljeu
Offline Send Email
Dec 22, 2005
1:41 pm

Okay, I'll take you up on that. I created a small framework that you can use DI or IoC to create mutexes, and use them. With a tiny bit of mocking, I also...
Ayende Rahien
ayende_tdd
Offline Send Email
Dec 19, 2005
7:52 pm

... Let's consider two Deadlock Detectors. One is expensive, and capable of detecting potential deadlocks in legacy code. The other is cheap - so cheap that it...
Phlip
phlipcpp
Offline Send Email
Dec 19, 2005
8:23 pm

Yes and no. For the purpose of discussion, let's say that: Foreach deadlock from expensive then cheap deadlock also find ? Then it's mathematically correct and...
Ayende Rahien
ayende_tdd
Offline Send Email
Dec 19, 2005
9:01 pm

... I offered the article as something that an interested party or parties might find to be a useful source of ideas for software development or tools or...
Ron Jeffries
ronaldejeffries
Offline Send Email
Dec 19, 2005
9:13 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help