Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • 3
    While both points are true, neither supports why forking method was chosen instead of reating a new process from given executable. Commented Jun 11, 2014 at 20:06
  • 4
    I think this does answer the question. Fork is used because, in cases where creating a new process is the most efficient way to go, the cost of using fork instead is trivial (likely less than 1% of the process creation cost). On the other hand, there are many places where fork is dramatically more efficient or far simpler of an API (such as handling file handles). The decision Unix made was to only support one API, making the specification simpler. Commented Jun 12, 2014 at 1:34
  • 1
    @SkyDan You're right, it's more an answer to why not rather than why, which Mark Plotnick answers more directly -- which I would interpret to mean not just that this was the easiest choice, but also that it was probably the most efficient choice (according to the Dennis Richie quote: "the PDP-7's fork call required precisely 27 lines of assembly...exec as such did not exist; its function was already performed"). So this "why not" is really a musing about two strategies wherein one superficially appears simpler and more efficient, when perhaps it isn't (witness the dubious fate of... Commented Jun 12, 2014 at 7:46
  • 2
    The original Unix implementations didn't have virtual memory or copy-on-write. So while this explains why fork() is cheap now, it doesn't motivate why the model was chosen in the first place. Commented Jun 18, 2014 at 20:54
  • 2
    Your answer referred to the hardware improvements: virtual memory, copy-on-write. Before these, fork actually copied all the process memory, and it was very expensive. Commented Jun 19, 2014 at 4:00