将虚拟地址存储在指针中而不是物理地址有什么好处? [英] what is the benefit of storing virtual address in a pointer rather than physical address?

查看:16
本文介绍了将虚拟地址存储在指针中而不是物理地址有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览了下面的链接,它说在大多数操作系统上,指针存储的是虚拟地址而不是物理地址,但我无法获得将虚拟地址存储在指针中的好处.

I have gone through below link and it says that on most Operating Systems , pointers store the virtual address rather than physical address but I am unable to get the benefit of storing virtual address in a pointer .

最后我们可以直接通过指针修改特定内存位置的内容,那么它是虚拟地址还是物理地址有什么问题?同样在代码执行期间,大部分时间数据段也会保留在内存中,所以我们只处理物理内存位置,那么虚拟地址有什么用呢?

when at the end we can modify the contents of a particular memory location directly through a pointer so what is the issue whether it is a virtual address or a physical address ? Also during the time the code executes , most of the time the data segment will also remain in memory ,so we are dealing with physical memory location only so how the virtual address is useful ?

C 指针和物理地址

推荐答案

其实指针一般都持有LOGICAL ADDRESSES.

Actually, pointers normally hold LOGICAL ADDRESSES.

使用逻辑寻址有几个原因,包括:

There are several reasons for using logical addressing, including:

  1. 易于内存管理.操作系统永远不必为进程分配连续的物理页框.

  1. Ease of memory management. The OS never has to allocate contiguous physical page frames to a process.

安全.每个进程都可以访问自己的逻辑地址空间,并且不能与另一个进程的地址空间混淆.

Security. Each process has access to its own logical address space and cannot mess with another processes address space.

虚拟内存.逻辑地址转换是实现虚拟内存的前提.

Virtual Memory. Logical address translation is a prerequisite for implementing virtual memory.

页面保护.通过将系统页面的访问限制为更高的处理器模式来提高安全性.通过限制对页面的访问类型(例如,不允许写入或执行数据页面)来帮助捕获错误(和病毒).

Page protection. Aids security by limiting access to system pages to higher processor modes. Helps error (and virus) trapping by limiting the types of access to pages (e.g., not allowing writes to or executes of data pages).

这不是一个完整的列表.

This is not a complete list.

这篇关于将虚拟地址存储在指针中而不是物理地址有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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