home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / os2 / programm / 7089 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.3 KB  |  65 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!mcsun!sunic!ericom!eua.ericsson.se!euas67c28!etxabju
  3. From: etxabju@eua.ericsson.se (Anders Bjurman)
  4. Subject: Re: OS/2 libraries thread-safe ?
  5. Message-ID: <1992Dec17.094108.12612@eua.ericsson.se>
  6. Sender: news@eua.ericsson.se
  7. Nntp-Posting-Host: euas67c28.eua.ericsson.se
  8. Reply-To: etxabju@eua.ericsson.se
  9. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  10. References: <1992Dec16.221352.26031@cs.tu-berlin.de>
  11. Date: Thu, 17 Dec 1992 09:41:08 GMT
  12. Lines: 51
  13.  
  14. In article 26031@cs.tu-berlin.de, ernst@opal.cs.tu-berlin.de (Ernst Kloecker) writes:
  15. >Hi,
  16. >
  17. >what precautions do I have to take when calling C-library functions from
  18. >different threads in one process ?
  19. >
  20. What C library? I can only speek for Microsoft C 6.0. I not quite sure about IBM Cset/2
  21. yet, but I think the answers are applicable for that library as well.
  22.  
  23. There are (at least) two versions of the library - one "normal" and one thread safe.
  24. In MSC you invoke the thread safe library with -MT.
  25.  
  26. >What happens to static variables like 'errno' ?
  27.  
  28. No problem. errno is redefined with the preprocessor to a thread-safe function:
  29. #define errno thread_safe_errno_function() or something like that.
  30.  
  31. >
  32. >Can I safely call '...printf()' from different threads ?
  33.  
  34. Not quite sure, but I think so. printf/sprintf etc uses (in MSC) a static result
  35. array. This array is guarded with semaphores. However, there can be a small risk
  36. that the output from several threads are mixed with each other (but only one
  37. of them calls printf() of course).
  38.  
  39. >
  40. >Or are the only safe functions the OS-functions in 'bsedos.h' ?
  41.  
  42. Sorry.
  43.  
  44. >Or are even those functions not completely thread-safe ?
  45. >
  46. Not absolutly sure how they are implemented, but functions like strtok(),
  47. localtime(), gmtime() etc seems a bit dangerous - I guard them with a semaphore
  48. when I use them.
  49.  
  50. >
  51. >Thanks for any info, Ernst.
  52. >--
  53.  
  54. No problem. Hope it helped. Can someone with experience from Cset/2 and emx
  55. tell how it's done there?
  56.  
  57. ---
  58.              __________________________________________________________
  59.  `"""'     _/  RF Anders Bjurman,        Memo: eri.etx.etxabju         \_
  60.   O O   __/    Ericsson Telecom AB       Anders.Bjurman@eua.ericsson.se  \
  61.    >  _/       S-125 25 Alvsjo, Sweden   +46 8 727 49 80                _/
  62.    o   \_______________________________________________________________/
  63.  
  64.  
  65.