why so little usage of DEFINE_SEMAPHORE()?
Robert P. J. Day
rpjday at crashcourse.ca
Sat Sep 29 09:24:14 EDT 2012
following up on my earlier post, i'm summarizing the current use of
semaphores in the kernel and quite a lot of docs are going to have to
cleanse themselves of now-obsolete references to all of
DECLARE_MUTEX[_LOCKED] and init_MUTEX[_LOCKED], since the current API
consists simply of:
but a quick grep for the former produces only:
$ grep -rw DEFINE_SEMAPHORE *
include/linux/semaphore.h:#define DEFINE_SEMAPHORE(name) \
ignoring what's under drivers/staging/ (which is generally a bit of
a mess at the best of times), the above shows that there is almost
*no* usage of DEFINE_SEMAPHORE(), which surprised me somewhat, but i
can imagine a couple reasons.
first, a lot of semaphores have been replaced by the newer and
simpler mutex. also, rather than semaphores being created standalone,
they're normally defined as part of a structure, and when an instance
of that structure is declared, it's naturally initialized with
sema_init() in the appropriate initialization code.
so i'm not surprised that the usage of DEFINE_SEMAPHORE() is
dropping, i'm just surprised that it's almost non-existent. thoughts?
Robert P. J. Day Ottawa, Ontario, CANADA
More information about the Kernelnewbies