在虚拟内存中,两个不同的进程可以具有相同的地址吗? [英] In virtual memory, can two different processes have the same address?

查看:1051
本文介绍了在虚拟内存中,两个不同的进程可以具有相同的地址吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在网站上发现的一个采访问题,问题说:在虚拟内存中,两个不同的进程可以具有相同的地址吗?当您回答否"时,这是正确的,一个进程可以访问另一个进程.内存,例如调试器可以访问变量并在调试时更改它们?"

This is an interview question I found in a website, the questions says: "In virtual memory, can two different processes have the same address? When you answer "No" which is correct, how one process can access another process' memory, for example the debugger can access the variables and change them while debugging?"

我了解的是:

  1. 2 diff进程可以具有相同的虚拟内存地址.这是因为每个进程都有自己的页表.每个进程都将其视为32位计算机上的4Gb内存.因此,P1和P2都可以访问地址0xabcdef-但物理内存位置可能不同.这不是吗?

  1. 2 diff process can have same virtual memory address. This is because each process has its own page table. Each process thinks it as 4Gb memory on a 32-bit machine. So both P1 and P2 can access address 0xabcdef - but the physical memory location might be different. Isnt this right ?

调试器的工作原理相同-2个进程可以访问相同的地址.因此它可以即时修改变量等.

The debugger works on the same principle - 2 processes can access the same address. So it can modify variables etc on the fly.

推荐答案

1)

  • 同时具有相同的物理内存地址:否
  • 同时使用相同的虚拟内存地址:是(每个映射到不同的网络物理地址或交换空间)

2)我认为调试器不会直接访问已调试的其他进程,而是会与已调试进程中的运行时进行通信以进行更改.

2) I think the debuggers don't access directly the other process debugged but communicates with the runtime in the debugged process to do that changes.

也就是说,如果您有权限,也许OS或处理器指令会提供对其他人的内存访问的访问/修改.这并不意味着它具有相同的地址,仅表示进程1可以说"Process2中的访问内存@ address1".某人(处理器/操作系统/运行时)将为进程1执行此操作.

That said, maybe the OS or processor instructions provide access/modify to other's memory access if you have the right. That doesn't mean it has the SAME address, it only says process 1 can say "access memory @address1 in Process2". Someone (processor / OS / runtime) will do that for process 1.

这篇关于在虚拟内存中,两个不同的进程可以具有相同的地址吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆