Re: what does a number of "_" mean?

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

 



<quote sender="Robert Love">
> On Mon, 2003-11-03 at 08:17, Shinpei Kato wrote:
> 
> > How about types or variables and functions beggining with one "_"
> > as _exit()?
> 
> Underscores tend to denote internal functions, or ones with a
> corresponding functions that are of a "higher level".
> 
> There is not any official difference between one and two underscore
> proceeded functions, but I guess two underscore functions would tend to
> be "more internal" than one underscore functions.
> 
> For example, consider foo() and __foo().  foo() might obtain requisite
> locks and then call __foo().  The standard interface would be foo(), but
> you could call __foo() if you knew you already held the locks or
> whatever.

I guess the rule of the thumb to choose whether you should use foo(),
_foo(), and __foo(), is to understand the implementation of the foo
function. Then invoke the required functions. Internal, in this case,
may contain lesser statements for checking or locking, as mentioned by
Robert above. 

Just like why you need to use _exit(), and not exit() in the child
process of a fork[1]. exit() performs clean-up related to user-mode
constructs in the library, and calls user-supplied cleanup functions.
_exit() performs only the kernel cleanup for the process. 

[1]http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC6

Eugene

> In the case of the _exit_*() functions, those are internal helper
> functions called by do_exit().
> 
> 	Robert Love
> 
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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