COW in a nutshell

This requires a bit of explanation. Until now, to keep the discussion conceptually simple, we have said that upon fork, the kernel copies all the parent's VAS segments (plus all the other inherited process attributes) to the new child process. This is an exaggeration; the reality is, attempting to do this would make the fork(2) untenable in practice as it would require too much RAM and too much time. (As it is, even with several optimizations, the fork is still considered heavyweight.)

Let's digress: one of the optimizations, upon fork is that the kernel does not copy the text (code) segment into the child; it merely shares the parent's text segment (virtual) pages with the child process. This works well, as text is in any ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.