mutex unlock order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

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:

mutex_lock(&global_lock);
mutex_lock(small_lock);

do_something_small_which_requires_both_locks();
mutex_unlock(&global_lock);

do_something_big_which_requires_only_small_lock();
mutex_unlock(small_lock);

The mutex_lock order cannot be changed due to deadlocks. Releasing small_lock
and then reaquiring might be possible, but looks pretty fragile.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


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



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux