I'm curious about the linux fork() routine

Asked 2 years ago, Updated 2 years ago, 38 views

at fork() on Linux,

I wonder which parts of the memory are shared by Parent and Child, and which parts are copied and kept.

(Before the COW happened.))

linux fork

2022-09-21 15:45

2 Answers

I know that you copy the context of the parent in the user memory area as it is.

alt text

A way to share memory between parents and children is to use shared memory.


2022-09-21 15:45

I was curious about what COW was, so I looked it up and there was this comment like this.

http://unix.stackexchange.com/questions/58145/how-does-copy-on-write-in-fork-handle-multiple-fork

  the (or rather, page) aspects of it, and memory, originally of parent fork child process should have. However, generated child process is shut down to just not that big a deal to the whole page of the process is inefficient, it might be to copy.
So - on copy write that says. - on copy write is changes make another copy only.
Until something changes in memory just traditional parent sseuneungeojyeo as a memory of the process Then write something on page When there are teachable moments, then that should be to copy the page.

In the situation before the copy-on-write (COW) you asked occurs, the entire memory of the process is shared and used.

I knew the concept of COW, but it's my first time hearing the name. COW is used in certain programming languages (for example, Swift) to copy data structures. If you copy an array, it doesn't actually copy at first, but the moment you change the value of one array, it actually copies the memory.


2022-09-21 15:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.