Hi,
I have a multithreaded application and there is
deadlock.
When I execute !locks in WinDbg it gives me following
output…
CritSec +da1a44 at 00DA1A44
LockCount 0
RecursionCount 0
OwningThread 0
EntryCount 2
ContentionCount 2
*** Locked
How do i interpret this.
As far as i know, owning thread is the id of the
thread who have entered the critical section already,
lock count is the no. of threads who wants to acquire
the crit sec nexxt, and recursion count denotes no. of
times the same thread have entered the critical
section.
But what does the EntryCount and ContentionCount field
denote.
thanx,
manish
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> Hi,
I have a multithreaded application and there is
deadlock.
When I execute !locks in WinDbg it gives me following
output…
I wrote my own implementation of user-mode mutex with the embedded deadlock
detection stuff to debug such a thing.
Max
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Hi Max,
I could solve my problem but i definately would like
to know more what u are talking about…
could u please give me some more idea what exactly are
u doing…
thanx,
Manish
— “Maxim S. Shatskih”
wrote:
> > Hi,
> > I have a multithreaded application and there is
> > deadlock.
> > When I execute !locks in WinDbg it gives me
> following
> > output…
>
> I wrote my own implementation of user-mode mutex
> with the embedded deadlock
> detection stuff to debug such a thing.
>
> Max
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> Hi Max,
I could solve my problem but i definately would like
to know more what u are talking about…
could u please give me some more idea what exactly are
u doing…
There are classic books on OS design (Deitel IIRC) where the deadlock
detection is described.
If the thread 1 is waiting on mutex A, which is acquired by thread 2 - then
let’s say “thread 1 waits for thread 2”.
You can maintain this “waits for” relationship in your code by using the TLS
pointer variable (for me, __declspec(thread) worked fine. After all, this is
for debug build only).
Then you must write your own mutex (using SetEvent, WaitForSingleObject and
InterlockedExchange). Again for debug build only - the release build will
use Win32 critical section instead.
The acquisition routine of your mutex must maintain the “waits for” relation
and must detect loops in it. If the thread is going to be blocked on the
mutex AND the “waits for” relation has a loop in it (like - 1 waits for 2, 2
waits for 3, 3 waits for 4, 4 waits for 1) - then a deadlock occured. The
only thing which you can do there is to print some trace message and stop on
DbgBreakPoint().
This will allow you to catch the deadlock by examining the stacks of all
threads in the debugger.
The situation is much harder if you have shared/exclusive mutexes - then you
will have a dependency tree and not a chain - but this is solvable
nevertheless.
Max
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com