没有虚拟内存支持的系统中的链接和分页 [英] linking and paging in the system without virtual memory support

查看:189
本文介绍了没有虚拟内存支持的系统中的链接和分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 首先,虚拟内存是系统的硬件功能,还是仅由OS实现?

在链接时重定位期间,链接器在生成的可执行文件中为每个节和每个符号分配运行时地址

During link-time relocation, the linker assigns run-time addresses to each section and each symbol, in the generated executable

  • 那些运行时地址是否对应于虚拟地址?

  • Do those run-time addresses correspond to virtual addresses?

如果为其生成可执行文件的系统不使用虚拟内存怎么办?

What if the system for which the executable is generated, does not use virtual memory?

接下来,如果不使用虚拟内存,则在加载时重定位后,应用程序的地址空间将限制为OS为其分配的物理地址空间

Next, if virtual memory is not used, then the application's address space is limited to the physical address space allocated for it by OS after load-time relocation

  • 如果不使用虚拟内存,是否会发生页面错误?

我认为是的:如果包含请求的物理地址的物理页面尚未存储在RAM中,则应该发生页面错误,这由OS页面错误处理程序提供服务

I think, it does: in case if the physical page containing the requested physical address has not yet been stored in RAM, then page fault should occur, which is serviced by OS page fault handler

  • 最后,没有虚拟内存就可以进行分页吗?

我问是因为分页总是和虚拟内存一起提到,但是似乎不需要虚拟内存来进行分页

I'm asking because paging is always mentioned together with virtual memory, but it seems that the presence of virtual memory is not required to do paging

谢谢

推荐答案

哇,很多问题.

  • 在何处实现虚拟内存?基础硬件需要支持虚拟内存.请记住,当您访问程序中的内存地址时,CPU需要某种方式来获取属于该地址的数据.如果您只有物理访问权限,则该操作将直接发送到内存控制器.在具有虚拟内存的系统中,您有一个 MMU(内存管理单元),它将虚拟地址转换为物理的. (请注意,某些微控制器提供了简化的版本,称为内存保护单元(MPU),该版本不提供此转换步骤,但至少允许访问权限检查.)
  • 链接时地址是否在运行时对应虚拟地址?通常,链接时地址对应于运行时虚拟地址.但是,有一种情况并非如此:与位置无关的代码.此处,虚拟地址是在加载时由动态链接程序确定的.此方法通常用于将动态链接的库(DLL/.so)加载到应用程序.有关该主题的更多详细信息,您想迁移链接器和加载器" .
  • >
  • 如果我的目标系统没有虚拟内存怎么办?如果您的系统不支持虚拟内存,那么从编译器/加载器的角度来看,什么都没有真正改变:您仍然需要生成代码来访问内存.唯一的区别是您的CPU不再执行从虚拟地址到物理地址的其他转换.
  • 如果没有虚拟内存,是否存在页面错误?如果您没有虚拟内存,则没有页面错误.但是,在使用MPU的情况下,您可能仍然会看到硬件报告的访问冲突,如果您的应用程序尝试访问一个不应该读取/写入的地址.请注意,不需要将物理地址(更好的是:由物理地址指向的数据)加载到RAM中.它们只是指向已经存在的RAM的指针.
  • 在没有虚拟内存的情况下是否可以进行分页?分页"和虚拟内存"通常用于表示同一事物.但是,分页也可以指将内存分为相同大小的块(页面)的概念.问题的答案取决于分页的含义. ;)
  • Where is virtual memory implemented? The underlying hardware needs to support virtual memory. Remember, when you access a memory address in your program, the CPU needs some way to obtain the data belonging to this address. If you only have physical access, then the operation is directly sent to the memory controller. In systems with virtual memory you have an MMU (memory management unit), which translates a virtual address into a physical one. (Note, that some microcontrollers provide a stripped-down version, called a Memory-Protection Unit (MPU), which does not provide this translation step, but at least allows access rights checking.)
  • Do link-time addresses correspond to virtual addresses at runtime? In general, link-time addresses correspond to runtime virtual addresses. However, there is a mode where this is not the case: position-independent code. Here, the virtual addresses are determined at load time by a dynamic linker. This approach is usually used to load dynamically linked libraries (DLL / .so) to an application. For more details on that topic, you migth want to check out "Linkers and Loaders".
  • What if my target system does not have virtual memory? If your system does not support virtual memory, from the compiler's/loader's perspective nothing really changes: you still need to generate code to access memory. The only difference is that your CPU does no additional translation from a virtual to a physical address anymore.
  • Are there page faults if there is no virtual memory? There are no page faults if you don't have virtual memory. However, in case of an MPU you might still see access violations reported by the hardware, if your application tries to access an address it is not supposed to read/write. Note, that physical addresses (better: data pointed to by physical addresses) don't need to be loaded into RAM. They are just pointers into the RAM which is already there.
  • Is paging possible without virtual memory? 'Paging' and 'Virtual Memory' are often used to denote the same thing. However, paging may also refer to the concept of splitting memory into chunks of the same size - pages. The answer to your question depends on what you mean by paging. ;)

这篇关于没有虚拟内存支持的系统中的链接和分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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