home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / programm / 6068 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.8 KB

  1. Xref: sparky comp.unix.programmer:6068 comp.unix.wizards:5672
  2. Path: sparky!uunet!ukma!gatech!paladin.american.edu!howland.reston.ans.net!spool.mu.edu!think.com!barmar
  3. From: barmar@think.com (Barry Margolin)
  4. Newsgroups: comp.unix.programmer,comp.unix.wizards
  5. Subject: Re: Using mmap()
  6. Date: 28 Jan 1993 17:49:25 GMT
  7. Organization: Thinking Machines Corporation, Cambridge MA, USA
  8. Lines: 27
  9. Distribution: usa
  10. Message-ID: <1k96b5INNa1d@early-bird.think.com>
  11. References: <1k7eqrINN3dr@TEDDY.SYSTEMSY.CS.YALE.EDU>
  12. NNTP-Posting-Host: telecaster.think.com
  13.  
  14. In article <1k7eqrINN3dr@TEDDY.SYSTEMSY.CS.YALE.EDU> freeman-elisabeth@cs.yale.edu (Elisabeth Freeman) writes:
  15. >DESCRIPTION
  16. >     mmap() establishes a mapping between the  process's  address
  17. >     space  at  an  address pa for len bytes to the memory object
  18. >     represented by fd at off for len bytes.  
  19. >
  20. >What is this memory object pointed to by fd, and how do I define
  21. >fd?   I want to map some pages created by valloc() to another
  22. >virtual address space.  Can I use mmap() for this purpose?
  23.  
  24. That description really sucks, IMHO.  The purpose of mmap(2) is to map a
  25. portion of a file into virtual memory.  The "memory object" is a file, and
  26. fd is a file descriptor returned by open(2).
  27.  
  28. You can use mmap to create shared memory between two processes by having
  29. both of them map the same file in MAP_SHARED mode.  You can also use the
  30. shm*() family of system calls for this.  But I believe neither mmap() nor
  31. shmat() let you turn an existing part of your address space (such as memory
  32. allocated with valloc()) into shared memory; they are used for *adding*
  33. objects to your address space.  But you can probably use shmat() *instead*
  34. of valloc() to allocate this memory.
  35.  
  36. -- 
  37. Barry Margolin
  38. System Manager, Thinking Machines Corp.
  39.  
  40. barmar@think.com          {uunet,harvard}!think!barmar
  41.