O
O
Oleg Filimonenko2018-04-19 10:29:42
Operating Systems
Oleg Filimonenko, 2018-04-19 10:29:42

Why does POSIX 'fork' create a full copy?

Good day, comrades. Studying operating systems, I asked myself the question: why in POSIX-like systems, when creating a process, the path of full copying of the parent to the child was chosen and only after that, using the execue syscall, it is overwritten with useful content. What is the point of passing the entire memory image, config lines, etc., when, for example, in Windows it creates, well, very roughly speaking, "empty nothing" and it is already given arguments, the executing program and 7-8 more standard parameters. I don’t have a goal to hate one of the ways, I want to figure out what are the pros and cons of both methods. It's not just that 'fork' has not found a replacement for several decades, right? Thanks to those who will try to describe the essence of so many different approaches in a simple (or maybe not simple) language. Any links with descriptions are accepted. )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
voronkovich, 2018-04-19
@voronkovich

The fork behavior you describe applies to early versions of Unix. Modern Unix-like systems use the idea of ​​"copy-on-write": https://en.wikipedia.org/wiki/%D0%9A%D0%BE%D0%BF%D...

A
anikavoi, 2018-04-19
@anikavoi

They are just two different approaches.
Comparing fork and CreateThread is not entirely correct, because they are similar but different entities.
and the answer to your question is the isolation of shared variables.
Just create a shared variable and change it in trid and fork, then read it from another branch and you will understand everything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question