Everything Totally Explained


Ask & we'll explain, totally!
Reentrant
Totally Explained


  FOR SALE!Either this or the left-hand panel are available for just $19.95 per
day, or you can have both for only $34.95! Contact us for details.  


View this entry using RSS

Everything about Reentrant totally explained

» For other uses of the term, see Reentrant (disambiguation)A computer program or routine is described as reentrant if it can be safely executed concurrently; that is, the routine can be re-entered while it's already running. To be reentrant, a function must:

  • Hold no static (global) non-constant data.
  • Must not return the address to static (global) non-constant data.
  • Must work only on the data provided to it by the caller.
  • Must not rely on locks to singleton resources.
  • Must not call non-reentrant functions.
Multiple levels of 'user/object/process priority' and/or multiprocessing usually complicate the control of reentrant code. Also, IO code is usually not reentrant because it relies on shared, singleton resources such as disks.
   Reentrancy is a key feature of functional programming.

Examples

In the following piece of C code, neither functions f nor g are reentrant.
    int g_var = 1; int f

Relation to thread-safety

Both concepts of reentrance and thread-safety relate to the way functions handle resources. However, they're not the same. While the concept of reentrance can affect the external interface of a function, thread-safety only concerns the implementation of the function and not its external interface.
  • In most cases, to make a non-reentrant function reentrant, its external interface must be modified such that all data is provided by the caller of the function.
  • To make a thread-unsafe function thread-safe, only the implementation needs to be changed, usually by adding synchronization blocks to protect shared resources from concurrent accesses by different threads. Therefore, reentrance is a stronger property than thread-safety and by definition results in it: every reentrant function is thread-safe, but not every thread-safe function is reentrant.

    Further Information

    Get more info on 'Reentrant'.


    External Link Exchanges

    Do you know how hard it is to get a link from a large encyclopaedia? Well we're different and will prove it. To get a link from us just add the following HTML to your site on a relevant page:

      <a href="http://reentrant.totallyexplained.com">Reentrant Totally Explained</a>

    Then simply click through this link from your web page. Our crawlers will verify your link, extract the title of your web page and instantly add a link back to it. If you like you can remove the words Totally Explained and embed the link in article text.
       As long as your link remains in place, we'll keep our link to you right here. Please play fair - our crawlers are watching. Your site must be closely related to this one's topic. Any kind of spamming, dubious practises or removing the link will result in your link from us being dropped and, potentially, your whole site being banned.



  • Copyright © 2007-8 totallyexplained.com | Licensed under the GNU Free Documentation License | Site Map
    This article contains text from the Wikipedia article Reentrant (History) and is released under the GFDL | RSS Version