There's hardly any reason to use SysV shared memory these days. Not for performance, anyway. Plain mmap of a regular file, or anonymous mapping (parent/child scenario) will accomplish much the same. The SysV interface could be convenient in some cases; one example is/was postgres:

PostgreSQL uses System V shared memory, because it provides a feature that is available via neither of the other two systems: the ability to atomically determine the number of processes attached to the shared memory segment.

In your code, the shmwrite() usage is not particularity efficient. (On Linux) each of those writes translate to three system calls — shmctl/shmat/shmdt — and a full memcpy/memset of the segment. IPC::SysV provides shmat, memwrite; the idea of shared memory is to avoid syscalls in the first place.

Finally, to benchmark message passing, one needs both a reader and a writer...


In reply to Re: SysV shared memory (Look-Alike) -- pure perl by oiskuu
in thread SysV shared memory (Look-Alike) -- pure perl by flexvault

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.