Re: try_module_get and module_put usage

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

 



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


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[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