[openbeos] Re: POSIX thread safety, was: Re: Waiting and waiting

  • From: "Michael Phipps" <mphipps1@xxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Tue, 10 Dec 2002 19:56:11 -0500

>I researched what reentrant meant after it was mentioned yesterday.  I read
>that reentrant functions are functions that neither use static data nor
>return pointer to static data.  In addition, a reentrant functions does not
>have to be thread-safe but a non-reentrant function is not thread-safe.  The
>definition I read didn't say that a reentrant function has to return the
>same thing each time it's called with the same parameters.
>
>Is what I read correct?
>http://www.unet.univie.ac.at/aix/aixprggd/genprogc/writing_reentrant_thread_
>safe_code.htm

Technically, it is true that the same input parameters do *NOT* have to produce
the same result in order to be re-entrant. A good example is rand(). However, 
since 
it does mean that there is no* inherent storage, it is very likely to be the 
case that 
the same input would yield the same output.

* - of course, with OS level support, this doesn't have to be true. Example - 
read().


Other related posts: