WARNING: mutexes are preferred for single holder semaphores
Sean MacLennan
seanm at seanm.ca
Mon May 5 10:41:04 EST 2008
This is a bit OT, but I got the warning in the subject from
checkpatch.pl for a piece of code. The code *is* using a mutex. Does it
actually mean I shouldn't use a mutex?
The code declares a global mutex:
static DECLARE_MUTEX(list_lock);
The odds of two accesses to the list_lock at the same time are zero.
But it would be Very Bad(tm) if it did happen. Since the odds of
contention are near zero, the cost of the mutex is near zero, so I put
it in.
I think I can safely ignore the warning, but I want to make sure....
Cheers,
Sean
More information about the Linuxppc-dev
mailing list