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

问题描述

我已经看过下面的链接,它说在大多数操作系统中,指针存储虚拟地址而不是物理地址,但是我无法从将虚拟地址存储在指针中受益.

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指针和物理地址

推荐答案

实际上,指针通常包含逻辑地址.

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).

这不是完整的列表.

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

09-03 18:10