Got this link, explaining all things in detail about above functions. http://lwn.net/Articles/22197/ . Thanks for all the help.
Vikas
On 16 May 2010 20:20, vikas chauhan <presentisgood@xxxxxxxxx> wrote:
On 16 May 2010 20:17, vikas chauhan <presentisgood@xxxxxxxxx> wrote:
Actually, I was a bit confused about reference counts, since some older modules ( like the OSSv4 drivers ) use their own copy of reference counts, and the above functions, it seems like , is being used by kernel to maintain its own reference count table. Please pardon me, if I am saying something stupid, as I am very very new to Linux kernel world.VikasOn 16 May 2010 13:40, Simon Kitching <simon.kitching@xxxxxxxxxx> wrote:
On Sun, 2010-05-16 at 03:06 +0545, vikas chauhan wrote:
The implementation of try_module_get can be found in file> Hi,
> Can any one tell me, what are the
> functions try_module_get and module_put used for ? I couldn't find any
> documentation by googling.
>
include/linux/module.h
(it is an inline function).
The implementation of module_put can be found in
kernel/module.c
Dynamically-inserted kernel modules are reference-counted, so that a
call to "rmmod" will fail if the reference-count is not zero, ie if the
module is still in use.
Function module_get increments the reference count of a module; once
this has returned success then the calling code can rely on the
specified module *not* being unloaded. When the caller no longer needs
that module, then module_put must be called to decrement the reference
count.
Well, the reference-counting scheme is slightly more complicated than
just a single integer (it keeps per-cpu "incs" and "decs" counts). But
the effect is the same.
Regards,
Simon