Похожие чаты

Hey everybody, I'm reading the Operating System Concepts book, 10th

edition. And I came across this practice exercise (3.1). I understand why the value is 5, but when I ran the code on my machine with some modifications, I printed the address of the "value" variable, and it was the same. Why do they point to the same address if each process should have a separate copy of its own?

2 ответов

17 просмотров

Each process has its own address space. The fork() syscall exactly duplicates file descriptors, credentials, namespace, cgroup settings, MM (this includes the pointer you showed, so yes, the pointer is duplicated too), and many more. What you see here is a virtual address. The same virtual address in a different process occupies a different physical address, (assuming we ignore the COW optimization on fork). But the point is the address space is private to each process. A process can't clobber other processes' addresses unless explicitly shared (e.g., using mmap + MAP_ANONYMOUS | MAP_SHARED before fork()).

Haney-Samer Автор вопроса
Alviro Iskandar Setiawan
Each process has its own address space. The fork()...

Yeah, I also thought it had something to do with virtual memory. Thanks!

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта