Re: GIANT question

From: Scott Long <scottl_at_freebsd.org>
Date: Wed, 21 Jul 2004 11:12:50 -0600
Bernd Walter wrote:

> Say I have a driver that could run without needing GIANT, but
> makes use of a subsystem that requires GIANT.
> Removing D_NEEDGIANT in cdevsw seems to be enough to get called
> from userland without GIANT held.
> Now I need to aquire GIANT bevor calling the subsystem and release
> it on return.
> What I've found so far is DROP_GIANT/PICKUP_GIANT, which has to be
> paired the other way.
> What is the prefered way to get/release GIANT in that case?
> 

mtx_lock(&Giant);
call_code_needing_giant();
mtx_unlock(&Giant);

Note that you must not be holding any locks when you go to aquire Giant.

Scott
Received on Wed Jul 21 2004 - 15:14:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:02 UTC