Doubts about PICKUP_GIANT() and mtx_lock(&Giant)

prime guomingyan at gmail.com
Sun Mar 12 14:28:29 UTC 2006


Date: Sun, 12 Mar 2006 16:25:07 +0530

> From: "Pranav Peshwe" <pranavpeshwe at gmail.com>
> Subject: Doubts about PICKUP_GIANT() and mtx_lock(&Giant).
> To: freebsd-hackers at freebsd.org
> Message-ID:
>         <cdfd7d6d0603120255x3039efa2w68c9217f5706e78c at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello,
>           What is effectively the difference between PICKUP/DROP_GIANT and
> mtx_lock/unlock(&Giant)  ? From the macro expansion, i surmise that
> PICKUP/DROP_GIANT deals with recursion in Giant locking.Is this correct ?
> is
> this the only difference ? What will happen if i mix the usage of
> PICKUP/DROP_GIANT and mtx_lock/unlock(&Giant) ?
> Also,is there any hard and fast rule prescribing which method of taking
> the
> Giant should be used where in the kernel ?
>
> TIA.
>
> Regards,
> Pranav
>
>
> ---------------------------------------------------------------------------
> To argue with a person who has renounced the use of reason is like
> administering medicine to the dead. -- Thomas Paine
>
>    In my opinion,DROP_GIANT() guarantees that Giant is *really*
dropped even it is recursively held.Sometimes we have to make sure
that Giant is not held,and mtx_unlock(&Giant) can't give us such
a promise,so you shouldn't use it in such situations.
   Mix the usage of DROP_GIANT() and mtx_unlock(&Giant) is not
a good idea,I think. In fact,if you really do it,even the compiler
 will reject your source code :-).


Regards,
MingyanGuo

--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
                         ---------Bertrand Russell


More information about the freebsd-hackers mailing list