Похожие чаты

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 ответов

16 просмотров

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!

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

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

Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
да кстати заметил всюда почему то всех сюда прёт, ни в одном чате столько ботов не прёт как сюда.. Может чота надо доработать?
REDis
15
I get confused when people talk about the ‘bull market’ and the ‘next bull market’ as if anyone really has a clue what’s really going on in the world. First of all - there i...
Shah
1
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
> Копаем глубже > Следующий момент был, когда я спросил его, знает ли он JavaScript. Он ответил, что его учили работать с C#. Я тоже в университете писал на C#, но даже там мн...
Oleg Volkov
4
Добрый день, подскажите, пожалуйста, по проблеме. Сегодня на работе утром обнаружилось что по рдп подключиться не получается к серверу 2022. В серверную зашел - на системно...
srv
19
Всем привет, я тут короче оторвал кусок от рут-раздела и сделал свап, перезаписал fstab, загружаюсь и меня перекидывает в дебаг-шелл. Вижу ошибки бтрфс: Device total_bytes sho...
&[SirJiga] Jiga
9
Карта сайта