Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Threads share memory by using the same virtual memory space. Memory at address 0xDD000000 in one thread is the same memory at address 0xDD000000 in the other thread. If malloc() is executed in one thread, the address can be passed to the other thread, and the other thread can access it as expected.

IPC shared memory segments are a little different. The memory is registered against an identifier, and exists outside of the address space of the other processes. Processes that use the shm*() controls can map the shared memory segment into their virtual memory. IPC shared memory segments are protected, as you say, with user and group permissions.

As for which one to use? This is a hard call. It becomes even harder when you bring Perl into the picture, as Perl threads does not allow you to take full advantage of the fact that memory is shared (memory has to be copied from one thread to another, as opposed to accessed in a synchronized manner). Given that you want to use permissions, and have each execution thread running as a different userid, IPC::Shareable may be your only real option.

Good luck!
mark


In reply to Re: Re: Re: Change UID for threads? by MarkM
in thread Change UID for threads? by mbalex

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 sharing their wisdom with the Monastery: (1)
As of 2024-04-19 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found