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

  • From: "Scott MacMaster" <zqxh@xxxxxxx>
  • To: <openbeos@xxxxxxxxxxxxx>
  • Date: Tue, 10 Dec 2002 14:51:58 -0500

> I think there may be a confusion here between "reentrant" and
> "thread-safe".  IIRC, reentrant functions produce the same result each
> time they are called with identical arguments (e.g. sqrt(8)).  strtok
> is an example of a non-reentrant function (look at it's definition to
> see why).  Thread-safe functions are functions which can be called
> from several threads simultaneously.  IMHO, all the BeOS library
> functions should be thread-safe, although many may not be re-entrant.

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



Scott MacMaster



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 12/6/2002


Other related posts: