[openbeos] Re: Waiting and waiting

  • From: François Revol <revol@xxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Tue, 10 Dec 2002 16:43:16 +0100 (MET)

En réponse à Michael Phipps <mphipps1@xxxxxxxxxxxxxxxx>:

> 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.
> 
Ah, yeah, right, statics are just desguised globals :^)
Here we just need to use TLS.

> >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: