Linux virtual memory | copy on write | Linux memory management during process creation | Linux COW

Publicado em: 05 Janeiro 2023
no canal de: Command Line
180
3

Source code of get_phy_addr.c is available at https://github.dev/0xba1a/Command_Lin...

00:00 - Introduction
00:28 - Contents
00:40 - Virtual Memory in Computer Architecture
01:56 - Process Creation in Linux
02:54 - Copy on Write - concept explanation
03:51 - Copy on Write - Demo

Linux developers are real hackers. They make some weird hacks in the operating system which will produce huge benefits. As Linux is running on billions of devices a small hack will produce a huge impact on a collective basis.

Virtual memory in OS is an abstraction between processes and real physical memory. It is introduced for better process management and security reasons. Copy on Write is one of the optimizations we do in the Linux virtual memory management to reduce the process creation time. Without a virtual memory abstraction layer, it is not possible.

Linux provides fork() system call for process creation. When a parent process calls the fork() system call, all of its resources like file descriptors, page table, etc are duplicated and given to the child process. The page-tables are copied as is without updating the physical address of the parent process. And that is updated later when a write happens. It is called as copy-on-write. That's why Linux developers are usually called as Linux kernel hackers ;)

Process management in Linux and process management in Unix are more are less same. Though the overall idea is followed from the Unix, Linux kernel hackers introduced a lot of optimizations in Linux kernel to make it better.

If you want to know more about virtual memory in coputer architecutre or process management in Linux, please leave a comment. I'll make a detailed video on those topics. Kernel hacking is always fun :D

In the demo we used the address of a global variable. Because Linux kernel will update the physical memory upon the first write. So to use any memory for the test, it's memory segment should't be written. Local variables are stored in stack and dynamic allocations are happening in the heap segment. Both of them are contaminated by printf. As global variables are stored in data segment, it makes sense to use a global variable for this testing.


Nesta página do site você pode assistir ao vídeo on-line Linux virtual memory | copy on write | Linux memory management during process creation | Linux COW duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Command Line 05 Janeiro 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 180 vezes e gostou 3 espectadores. Boa visualização!