English 中文(简体)
虚拟记忆是否真正有用?
原标题:Is Virtual memory really useful all the time?

虚拟记忆是现代操作系统目前使用的良好概念。 但是,我对一个问题置之不理,对此我不够肯定。 这里的问题是:

Suppose there are only a few applications running on a machine, such that the physical memory of system is more than the memory required by all the applications. To support virtual memory, the OS needs to do a lot work. So if the running applications all fit in the physical memory, is virtual memory really needed?

(Furthermore, the applications running together will always fit in RAM.)

最佳回答

即使所有应用的记忆使用都适合记忆,虚拟记忆仍然有用。 考试和测验科可以提供这些特点:

  • Privileged memory isolation (every app can t touch the kernel or memory-mapped hardware devices)
  • Interprocess memory isolation (one app can t see another app s memory)
  • Static memory addresses (e.g. every app has main() at address 0x0800 0000)
  • Lazy memory (e.g. pages in the stack are allocated and set to zero when first accessed)
  • Redirected memory (e.g. memory-mapped files)
  • Shared program code (if more than one instance of a program or library is running, its code only needs to be stored in memory once)
问题回答

虽然在这种情况下并非严格需要,但虚拟记忆不仅仅是提供“更多的”记忆,而不是提供实际的(抽取)。 例如,它有助于避免记忆分散(从申请的角度来看),并视动态/共享的图书馆是如何实施的,它有助于避免搬迁(在动态连接者需要改造图书馆的点人或刚刚装满的可执行点时,重新定位)。

考虑的还有几点:

  • Buggy apps that don t handle failures in the memory allocation code
  • Buggy apps that leak allocated memory

虚拟记忆降低了这些丑恶的严重性。

The other replies list valid reasons why virtual memory is useful but I would like to answer the question more directly : No, virtual memory is not needed in the situation you describe and not using virtual memory can be the right trade-off in such situations.

Seymour Cray took the position that "Virtual memory leads to virtual performance." and most (all?) Cray vector machines lacked virtual memory. This usually leads to higher performance on the process level (no translations needed, processes are contiguous in RAM) but can lead to poorer resource usage on the system level (the OS cannot utilize RAM fully since it gets fragmented on the process level).

So if a system is targeting maximum performance (as opposed to maximum resource utilization) skipping virtual memory can make sense.

When you experience the severe performance (and stability) problems often seen on modern Unix-based HPC cluster nodes when users oversubscribe RAM and the system starts to page to disk, there is a certain sympathy with the Cray model where the process either starts and runs at max performance, or it doesn t start at all.





相关问题
What resources are shared between threads?

Recently, I have been asked a question in an interview what s the difference between a process and a thread. Really, I did not know the answer. I thought for a minute and gave a very weird answer. ...

Random access of multiple files and file caching

This relates to some software I ve been given to "fix". The easiest and quickest solution would make it open and read 10 random files out of hundreds and extract some very short strings for processing ...

What form is DLL & what makes it processor dependent

I know DLL contains one or more exported functions that are compiled, linked, and stored separately.. My question is about not about how to create it.. but it is all about in what form it is stored.. ...

Thread behavior on multicore machines

Does the threads of a single process run in parallel on a multi-core machine on windows XP? Is the behavior same on different windows versions (windows server editions) I have heard that only threads ...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签