Search This Blog

Sunday, November 1, 2009

Thread, Re-entrant And Thread Safe

http://en.wikipedia.org/wiki/Reentrant_%28subroutine%29
Re-entrant is the fundamental property to thread safety, by definition, leads to thread safety.


Re-entrant function: (all by myself)
  • Must hold no static (or global) non-constant data.
  • Must not return the address to static (or 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 modify its own code.[1] (unless executing in its own unique thread storage)
  • Must not call non-reentrant computer programs or routines.
Thread safe function: (cooperation needed, because I share something with others)
Synchronize -- protect critical resource from all concurrent threads

No comments: