Consider the following:
use IPC::Shareable; use IPC::SysV qw(ftok); $ftok = ftok($0); printf("ftok=$ftok (0x%08X)\n", $ftok); $tied = tie %Sess, 'IPC::Shareable', {key => $ftok, mode => 0666, crea +te=>"yes"};

Before executing the above, I do an ipcs -a

It tells me that there are no Semaphore Arrays and only a handful of shared-memory segments.

I invoke the perl-debugger and execute the above code (including the tie).

ftok() gives me 0x01003A83

I now do another ipcs -a ... and now I see:

 Shared-memory-segment with key 0x01003A83 and size 65536 bytes

 Semaphore-array with the same key and 3 semaphores

Question-1: is it normal that a semaphore is created when a shared-memory-segment is set up?

In the debugger, I now do $Sess{abc} = 1

There is no change to what is reported by ipcs -a

However, if I do now $Sess{a}{b}{c}{d}{e} = 1

I now find 4 more 65536 shared-memory-segments created and a load of corresponding semaphores.

Question-2:Does that seem reasonable?

It just seems very curious that the originally created shared-memory segment doesn't simply grow as the data-structure %Sess gets populated

And the %Sess isn't heavily populated, yet I now have five 65536-byte segments, each with it's own semaphore ... very curious?


In reply to IPC::Sharable ... curious ipcs -a results by andyok

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.