Hello,

On Thu, Dec 9, 2010 at 7:49 AM, Michael Blizek
<mic...@michaelblizek.twilightparadox.com> wrote:
> I have came upon an interesting situation where I am not sure about mutex
> semantics. What I want to do is something like this:
>
> mutex_lock(&global_lock);
> mutex_lock(small_lock);
>
> do_something_small_which_requires_both_locks();
> do_something_big_which_requires_only_small_lock();
>
> mutex_unlock(small_lock);
> mutex_unlock(&global_lock);
>
> I want to avoid holding the global lock while doing something_big. Can I do
> something like this:
>

Why not do this, i.e. acquire the locks in the other order, then
release the global lock first:

mutex_lock(small_lock);
mutex_lock(&global_lock);
do_something_small_which_requires_both_locks();
mutex_unlock(&global_lock);
do_something_big_which_requires_only_small_lock();
mutex_unlock(small_lock);


Regards,
-- 
Leon

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to