Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: thread-safe mmap module ?

by perrin (Chancellor)
on Feb 22, 2009 at 00:56 UTC ( #745583=note: print w/replies, xml ) Need Help??

in reply to thread-safe mmap module ?

Why don't you use a standard hash shared between the threads? Do you need it to be persistent when you shut down apache?

Replies are listed 'Best First'.
Re^2: thread-safe mmap module ?
by jdd (Acolyte) on Feb 22, 2009 at 07:46 UTC
    Indeed persistency isn't necessary, although supported; you have a point. I see in CPAN the very promising threads-shared module - its .xs clearly proves the win32 support, and in addition it works in non-threaded environments - great suggestion - thank you -;
      You're welcome. There are some other tricks for getting good thread performance with mod_perl, mostly to do with when you load things. If you need more help and suggestions, come visit us on the mod_perl list.
Re^2: thread-safe mmap module ?
by zentara (Archbishop) on Feb 22, 2009 at 11:59 UTC
    Indeed.... thats why threads are used .... to facilitate sharing between threads....otherwise just fork. Fork and shared memory are an alternative to threads and threads::shared.

    There may be an advantage to using shared memory in threads, notably it is the fastest IPC out there; but there are how would you control simultaneous concurrent access to the mmap region from different threads? You are risking data corruption.

    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
      threads:::shared offers a lock() method that is released outside of the {} scope where it is. To try -;
        Thanks, I've seen that. However, in my design processes in my head, I always prefer to keep thread shared variables read-only from the outside. In otherwords, one thread should not be able to change a variable in another thread, without the target thread knowing(or asking for it). This is better for security, and avoids all chances for a run away condition, where threads are all trying to lock and change a var at the same time....constantly looping....and having their change thwarted millisecs later by another thread. This requires you to have a thread that acts as a main controlller..... like a parent, keeping order among the child threads.

        I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://745583]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2022-01-25 03:07 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (65 votes). Check out past polls.