[openbeos] Re: Waiting and waiting

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

IIRC, the classic implementation of strtok uses a static char * to retain state
between calls. That would make it thread unsafe. That is why there is a strtok_r
that passes that value in and out, to be reentrant.

>This one is the perfect example of self-contained function (not dealing with
>IO or anything) that doesn't need to be taken care of. Except of course if
>you implement it using global variables, but this would be very dumb :^)
>
>as long as it uses local variables *only* it can be considered as 
>intrinsically thread-safe, as each instance is fully located on the stack of 
>the calling thread.
>
>On the opposite every function that deals with something that belongs to a 
>whole team (memory, files, ...) must use locking (malloc(), fread, ...)
>
>François.
>
>




Other related posts: