[KJ]use mutex instead of a binary semaphore

From: Milind Arun Choudhary
Date: Mon Apr 16 2007 - 13:54:20 EST



As the new mutex primitive is now in place, I read,it is advised
not to use binary semaphore for mutual exclusion.

while looking at different place where a binary semaphore is initialized,
I came accross bd_mount_sem.

I read a thread on LKML few months back related to the bd_mount_sem
and realized that there are cases where a binary semaphore can not be replaced by a mutex.
The reason being mutex has a sense of ownership, i.e.
a mutex can only be unlocked from the context
from which it was locked.

e.g bd_mount_sem in the block device structure is
used to make sure no new mounts happen on bdev
in between freeze_bdev and thaw_bdev().

so locking is done in freeze_bdev &
unlocking in thaw_bdev these can be from different context i guess..

is my understandig correct..
CMIIW..
would appreciate some pointers on how to identify such cases..


--
Milind Arun Choudhary
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/