Thanks for the info! Now, since I know that there is some thread waiting on that lock, can I somehow find out *which* thread it is from sos? From a quick reading of the source, this doesn't seem to be possible as threads that ask for a lock don't seem to be recorded anywhere - just the number of threads is stored in the counter. Am I missing something? This would come in handy for debugging deadlocks in production apps
Sriram ---------------------------------------------------------------------------- - I blog at http://www.dotnetjunkies.com/weblog/sriram ---------------------------------------------------------------------------- > -----Original Message----- > From: Discussion of the Rotor Shared Source CLI > implementation [mailto:[EMAIL PROTECTED] On > Behalf Of Jan Kotas > Sent: 17 October 2004 12:06 > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET-ROTOR] Explanation of AwareLock's m_MonitorHeld > > > 1. Why is the number bumped up by 2 every time someone waits on the > lock? > > This field is a combination of a bit flag and counter. The > bit flag is the lowest bit, the counter is the rest. > > > 2. What is the meaning of doing (state - 2) | 1) - and why? > > This decrements the counter and sets the flag. > > > 3. How do I translate the MonitorHeld column in the > !SyncBlk command? > Do I > assume that every 2 incrememnt after 1 corresponds to some > guy waiting? > > Correct. > > > -Jan > > -----Original Message----- > From: Discussion of the Rotor Shared Source CLI > implementation [mailto:[EMAIL PROTECTED] On > Behalf Of Sriram Krishnan > Sent: Saturday, October 16, 2004 11:32 PM > To: [EMAIL PROTECTED] > Subject: [DOTNET-ROTOR] Explanation of AwareLock's m_MonitorHeld > > While debugging with the SOS extension, I used the SyncBlk > command and got the following output. > 0:003> !SyncBlk > Index SyncBlock MonitorHeld Recursion Thread ThreadID Object > Waiting > 3 0016f634 3 1 161a50 910 4 00aa1bac > System.Object > Waiting threads: > 4 0016f660 3 1 161888 d08 3 00aa1ba0 > System.Object > Waiting threads: > > I was curious to know what that MonitorHeld column was - and > dug through the Rotor sos code and found that it mapped to > the m_MonitorHeld of AwareLock. > > The lines of code that interest me are (in SyncBlk.cpp) > > FastInterlockCompareExchange((LONG*)&m_MonitorHeld, state + > 2, state) (which gets executed whenever tries to acquire a lock) > > And > > FastInterlockCompareExchange((LONG*)&m_MonitorHeld, state - > 2, state) (inside AwareLock::EnterEpilog) > > Whenever you get a new guy waiting on the lock, the state > variable (which is the same as the m_MonitorHeld) gets bumped > up by 2 and bumped back down by 2 whenever someone stops waiting. > > When someone *does* acquire the lock, the code executed is > (FastInterlockCompareExchange((LONG*)&m_MonitorHeld, ((state > - 2) | 1), state). > > Now, here are my questions > > 1. Why is the number bumped up by 2 every time someone waits > on the lock? > > 2. What is the meaning of doing (state - 2) | 1) - and why? > > 3. How do I translate the MonitorHeld column in the !SyncBlk > command? Do I assume that every 2 incrememnt after 1 > corresponds to some guy waiting? > > > Thanks in advance, > Sriram > > > -------------------------------------------------------------- > ---------- > ---- > - > > I blog at http://www.dotnetjunkies.com/weblog/sriram > > -------------------------------------------------------------- > ---------- > ---- > > =================================== > This list is hosted by DevelopMentor(r) > http://www.develop.com ASP.NET courses you may be interested in: > > Guerrilla.NET Sept 27-Oct 1, in Torrance > http://www.develop.com/courses/gdotnetls > > Essential.NET Sept 20-24, in San Francisco Essential.NET Oct. > 4-8, in London http://www.develop.com/courses/edotnet > > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > ASP.NET courses you may be interested in: > > Guerrilla.NET Sept 27-Oct 1, in Torrance > http://www.develop.com/courses/gdotnetls > > Essential.NET Sept 20-24, in San Francisco Essential.NET Oct. > 4-8, in London http://www.develop.com/courses/edotnet > > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentorŪ http://www.develop.com ASP.NET courses you may be interested in: Guerrilla.NET Sept 27-Oct 1, in Torrance http://www.develop.com/courses/gdotnetls Essential.NET Sept 20-24, in San Francisco Essential.NET Oct. 4-8, in London http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com