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

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

>Although the POSIX standard may declare that these functions need not
>be thread-safe, an implementation where they are thread-safe would
>certainly satisfy POSIX.  In BeOS, where threads are pervasive, I'd
>argue that all of the standard library should be thread-safe.

Thread safe may be a good thing or a bad thing.
Example:
        thread 1                                                                
thread 2
read (fd,buffer,2048);                                          
acquire_sem(thread2Pause);
char *foo=strtok(buffer,":");                                   char 
*bar=strtok(NULL);
release_sem(thread2Pause);                              // Process
// Continue on doing other things...

Yeah, I know that this is a small, contrived example, but one *could* want and 
even expect that strtok works across threads. 


Other related posts: