On Wed, 9 Aug 2006, Nitin Hande wrote:

> C, Kiran (STSD) wrote:
>> 
>> HI,
>> 
>> I have a doubt in mdb.
>> 
>> When I do, ::threadlist -v it will list all the kernel threads
>> 
>> In the Solaris OS, the WCHAN column is the address of a synchronization
>> variable on which the thread is blocked.
>> 
>> Say, There is a thread called abcd() which is blocked, and the address
>> of  the sychronization variable  say  xxxx
>> 
>> I want to know which function in this thread is holding this lock so
>> that I can look into that function in more detail.
>> 
>
> But threadlist -v also shows the stacktrace of the thread doing wait...or am 
> I not understanding your question ?

Misunderstanding on both parts :)

Condition variables are not locks. They're a "synchronization primitive" 
(as are semaphores, mutexes, rwlocks, spinlocks, ...), but not every 
synchronization primitive has/needs an owner ...

When a thread is waiting on a condition variable, there will not be an 
"owner" of the lock. Blocking on a condition variable is an indication of 
state - the thread has an expectation about an event/statechange to happen 
that hasn't happened yet. Code that waits on condition variables always 
looks like this:

        mutex_enter(somelock);
        while (cond_not_met)
                cv_wait(condvar, somelock);
        [ ... perform action now ... ]
        mutex_exit(somelock);

That cv_wait(9f) requires a mutex is for synchronizing wakeups (avoid 
thundering herds). While threads sleep on a condvar the lock is unheld. 
It'll be pure coincidence if during that time another thread happens to 
hold that lock. Unless, of course, you have a systematic problem where the 
thread that is supposed to perform the wakeup, aka call either of the two 
cv_signal(9f)/cv_broadcast(9f), has acquired the mutex already but is now 
stuck/looping itself somewhere.

Condition variables have no owners. They only have waiters.

The mutex required for going to sleep on a condvar may have an owner. But 
it will only while a thread is in such a critical section, and that will, 
usually, not be true for 99.99% of the time the waiters are blocked on the 
condvar.

FrankH.

>
> Thanks
> Nitin
>
>> Or is there any other command in mdb where we can find who is holding
>> the lock in a blocked thread
>> 
>> 
>> 
>> Regards
>> 
>> Kiran
>> _______________________________________________
>> mdb-discuss mailing list
>> mdb-discuss at opensolaris.org
>> 
>
> _______________________________________________
> mdb-discuss mailing list
> mdb-discuss at opensolaris.org
>

==========================================================================
No good can come from selling your freedom, not for all gold of the world,
for the value of this heavenly gift exceeds that of any fortune on earth.
==========================================================================

Reply via email to