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