两个进程访问同样的逻辑地址物理地址为何不同

在Linux系统中,每个进程拥有独立的页全局目录和页表,进程切换时通过更新cr3控制寄存器实现页表切换。Copy-On-Write技术允许父进程和子进程共享物理页面,写操作时会复制到新的物理页面。因此,不同进程访问相同逻辑地址时,实际映射的物理地址可能不同。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Linux 段表

In uniprocessor systems there is only one GDT, while in multiprocessor systems there is one GDT for every CPU in the system.

 

2.Linux页表

each process has its own Page Global Directory and its own set of Page Tables. When a process switch occurs Linux saves the cr3 control register in the descriptor of the process previously in execution and then loads cr3 with the value stored in the descriptor of the process to be executed next. Thus, when the new process resumes its execution on the CPU, the paging unit refers to the correct set of Page Tables.

The Copy On Write technique allows both the parent and the child to read the same physical
pages. Whenever either one tries to write on a physical page, the kernel copies its contents
into a new physical page that is assigned to the writing process. The implementation of this
technique in Linux is fully explained in

 linux系统下每个进程都拥有自己的页表,父进程fork出新的子进程时,子进程拷贝一份父进程的页表,且父子进程将页表状态修改为写保护。当父子进程中的进程发生写操作时将会发生缺页异常,缺页异常处理函数将会为父子进程各自分配新的物理地址。所以不同的进程访问同样的逻辑地址而对应的物理地址不同,是由于各自页表的不同。
两个进程访问同样的逻辑地址物理地址为何不同_linghaidong的专栏-CSDN博客_两个物理地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值