Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found