Subj : Re: pthreads and othe POSIX APISa To : comp.programming.threads From : loic-dev Date : Mon Apr 18 2005 04:19 am Hi Jarek, > What is the relation between pthreads and other POSIX defined > system/library calls ? How can I know, wheather a function can > /cannot be concurrently called from many treads ? > Is there any guideline for this ? Yes: the Single Unix Specification (SUS): http://www.unix.org/version3/online.html Just register (this is a free and painless process) to access the full spec. > Or should I just carefully > read the man pages about each call I'm going to use > from within a thread ? That would have been a good idea to force people to read all the POSIX standards ;-) Fortunately, there is a simple rule: all SUS functions are thread-safe, except a well defined list of functions that are not required to be thread-safe. [ Not required to be thread-safe doesn't mean that they are necessarily unsafe . On a particular implementation, the function might be well thread-safe. But that's implementation specific: on another implementation, the same function might be unsafe. Hence, for portability reasons, don't make any assumption about thread safety for those functions) Cheers, Loic. The list of functions that are not required to be thread-safe accordingly to SUSv3: asctime() basename() catgets() crypt() ctime() dbm_clearerr() dbm_close() dbm_delete() dbm_error() dbm_fetch() dbm_firstkey() dbm_nextkey() dbm_open() dbm_store() dirname() dlerror() drand48() ecvt() encrypt() endgrent() endpwent() endutxent() fcvt() ftw() gcvt() getc_unlocked() getchar_unlocked() getdate() getenv() getgrent() getgrgid() getgrnam() gethostbyaddr() gethostbyname() gethostent() getlogin() getnetbyaddr() getnetbyname() getnetent() getopt() getprotobyname() getprotobynumber() getprotoent() getpwent() getpwnam() getpwuid() getservbyname() getservbyport() getservent() getutxent() getutxid() getutxline() gmtime() hcreate() hdestroy() hsearch() inet_ntoa() l64a() lgamma() lgammaf() lgammal() localeconv() localtime() lrand48() mrand48() nftw() nl_langinfo() ptsname() putc_unlocked() putchar_unlocked() putenv() pututxline() rand() readdir() setenv() setgrent() setkey() setpwent() setutxent() strerror() strtok() ttyname() unsetenv() wcstombs() wctomb() .