Re: try_module_get and module_put usage

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

 





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.

Vikas


On 16 May 2010 13:40, Simon Kitching <simon.kitching@xxxxxxxxxx> wrote:
On Sun, 2010-05-16 at 03:06 +0545, vikas chauhan wrote:
> 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.
>

The implementation of try_module_get can be found in file
  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




[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