home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4237 < prev    next >
Encoding:
Internet Message Format  |  1992-08-15  |  1.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!PKSMRVM.VNET.IBM.COM!KENKAHN
  2. From: KENKAHN@PKSMRVM.VNET.IBM.COM ("Kenneth A. Kahn")
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: Process/Thread Memory Sharing
  5. Message-ID: <9208152116.AA16850@ucbvax.Berkeley.EDU>
  6. Date: 15 Aug 92 10:13:59 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 27
  9.  
  10. Organization: Staff of IBM Fellow - NetWork Computing
  11. Disclaimer: This posting represents the poster's views, not those of IBM
  12. News-Software: UReply 3.0
  13. X-X-From: KENKAHN@PKSMRVM.VNET.IBM.COM (Ken Kahn)
  14. References: <1992Aug15.003258.24311@elroy.jpl.nasa.gov>
  15.  
  16. In <1992Aug15.003258.24311@elroy.jpl.nasa.gov> Les Hartzman writes:
  17. >Reading some OS/2 documentation indicates that threads created within a
  18. >single process may share that process' memory.  What is the process' memory?
  19. >Is it the process' global memory (e.g., variables defined outside of 'main'),
  20. >or is it an an actual memory object that is owned by the process?
  21. >
  22. >IF it is a memory object that the process creates, how do the threads get
  23. >the address of the memory object?
  24.  
  25. Remember that a process is nothing more than a single application.  A thread
  26. is logically just a subroutine that happens to be running asynchronously at
  27. the same time as the main program (thread 1; e.g. main function in C).  All
  28. threads have access to the program's Global storage pointed to by it's DS.
  29. If any thread, including thread 1, happens to allocate more storage using an
  30. API like DosAllocSeg or DosAllocShrSeg, all threads have access to that new
  31. storage.  The on;y 'trick' is in order to access the allocated storage you
  32. have to store the Selector to it in a global area (or you could store an
  33. actual pointer that you create via MAKEP or similar).
  34.  
  35. In general, resources created by threads, e.g. Storage, Queues, File Handles,
  36. are accessable by the entire owning process.
  37.