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

Re: To fork() or not to fork()

by ehdonhon (Curate)
on Nov 05, 2003 at 23:00 UTC ( #304894=note: print w/replies, xml ) Need Help??

in reply to To fork() or not to fork()

Questions to consider:

  • Is there ever a time when its valid for one of these things to run without the other? If yes, that's an argument that they should be seperate programs, or at least the same program with command line options. If no, then it might be better to have them all fork from one process. That way if one dies, the default child and hup signal handlers will kill the others.
  • Can you gain any efficency having all the code run under one process? If each of your programs has a very high startup cost, it might be more efficent if you only have to start it once.
  • Is shared memory useful at all? Granted, you don't get real "shared memory" when you fork(), but on many operating systems, you do get copy-on-write memory, which means if you have a lot of memory that you only need to populate once and then read only, you could reduce memory usage by having just one program that does forks.
  • What is the easiest to maintain? If all you are doing is dumping three big programs into one huge program, you are going to make it harder on yourself later on. However, if this gives you opportunity to re-use code, it could be a bonus for you.

I'm sure there are more points to consider, but those are a few just off of the top of my head.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2023-03-24 04:13 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.