Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: WHY copying does happen (fork)

by stiller (Friar)
on May 07, 2008 at 05:27 UTC ( #685145=note: print w/replies, xml ) Need Help??

in reply to WHY copying does happen (fork)

Do you read the data in before or after forking? I haven't used shared memory directly, so I might be way off here, but I thought that you would have to fork first, then build up the shared data between the processes?

Replies are listed 'Best First'.
Re^2: WHY copying does happen (fork)
by Anonymous Monk on May 07, 2008 at 14:34 UTC
    i read the data in BEFORE forking.
    when you fork, each thread is a kind of replication of the original. via copyOnWrite the original data is shared. if one fork writes, it creates a copy of the original data and does its modifications. So no other fork can see the modification. sharing the data between different forks is expensive and slow
    my idea was that since I only read the operating system shouldn't need to create copies (slow and requires memory), but after reading the answers here it seems that even with readOnly perl does enough writing to the data to let the OS start the copying :(
    thats not nice but I guess I have to live with that and find other solutions like the in memory databases mentioned...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://685145]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-05-27 12:28 GMT
Find Nodes?
    Voting Booth?