RE: reentrant ?

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

 



-> Anybody please explain to me, in the context below, what 
-> "reentrant" means?
-> 
-> - The function search_binary_handler() is designed to be reentrant.

  It is good to know thread-safety before knowing reentrancy.
  Lot of books/papers define thread-safety and reentrancy in
  different ways (sometimes incorrectly).

  A function is said to be thread-safe if and only if it will
  always produce correct results when called repeatedly from
  multiple concurrent threads. We can identify four (nondisjoint)
  classes of thread-unsafe functions:
  
    1. Functions that do not protect shared variables
    2. Functions that keep state across multiple invocations
    3. Functions that return a pointer to a static variable
    4. Functions that call thread-unsafe functions

  Reentrant functions are an important class of thread-safe 
  functions, that they do not reference any shared data when
  they are called by multiple threads. In other words, all 
  functions are partitioned into disjoint sets of thread-safe 
  and thread-unsafe functions. The set of reentrant functions 
  is a proper subset of the thread-safe functions.
 
  Reentrant functions are more efficient than nonreentrant 
  thread-safe functions because they require no synchronization
  operations. There are two types of reentrant functions:

    1. Explicit reentrant functions
    2. Implicit reentrant functions

  If all function arguments are passed by value (ie. no pointers)
  and all data references are to local automatic stack variables
  (ie. no references to static or global variables), then the
  function is explicit reentrant. That is the function is 
  reentrant regardless of how it is called.

  If some function arguments are passed by reference (ie. we 
  allow callers to pass pointers) then we have an implicit 
  reentrant function. That function is reentrant only if the 
  calling threads are careful to pass pointers to nonshared
  data.

  Finally, it is important to realize that reentrancy is 
  sometimes a property of both the caller and callee, and not
  only the callee alone.

  So, coming to your question, we can't say whether the function 
  search_binary_handler() is reentrant or not without knowing
  how the parameters are passed (by value or by reference) and
  how it is called etc.

Venkata.

--
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