mmap is great for IPC. I even worked on a flavor of Unix that had a special shared-memory semaphore (that worked on any shared memory, not just mmap'd shared memory) that required no kernel involvement unless you wanted to wait for a lock to be released.

That is, w/o involving the kernel, you can use mmap'd memory to get a lock w/o race conditions and, for the very small percentage of cases (if you've designed your system well) when there is lock contention, you allocate a kernel resource that you can sleep on and mark the mmap lock area so the lock holder will wake you up when they release the lock. I believe this shared-memory locking technique required just 4 d-words of shared memory per lock.

You can also use byte-range file locks on even an empty file that doesn't even have to be related to the mmap'd memory.

- tye        


In reply to Re^4: Mmap question (fud) by tye
in thread Mmap question by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.