Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Mmap question

by Aristotle (Chancellor)
on Jan 31, 2005 at 00:26 UTC ( [id://426465]=note: print w/replies, xml ) Need Help??


in reply to Mmap question

You misunderstood. $shmid is the wrong name, you are getting the address of the mmapped area, not a shared memory ID. mmap(2) has nothing to do with the SysV IPC facilities.

I am not entirely certain on how to use mmap(2) as an alternative to shared memory, since I've never done that, but my reading of the docs and manpage suggest that it is limited to passing down the mmap to child processes on fork. I could be wrong here though, as I said, since I've never tried to use the facility in that capacity.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: Mmap question
by leriksen (Curate) on Jan 31, 2005 at 00:46 UTC
    Your quite right about being passed on fork (but it is not copied across exec's if working at the C level).

    And zentara I think your right about the octal to decimal conversion.

    As for using mmap(2) for IPC, Stevens demonstrates a technique for mmap across related processes (you cant use mmap across unrelated processes, because the address is for that process family. If an unrelated process tries to use it, you'll get a SIGSEGV or SIGBUS core dump). He creates a mmap'd area from /dev/zero, then has co-operating parent and child increment a long integer in turn.

    Stevens last word on mmap and shared memory is "If shared memory is required between unrelated processes, the shmXXX functions must be used"

    ...it is better to be approximately right than precisely wrong. - Warren Buffet

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://426465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-25 18:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found