Operating system/Virtual Memory


This is a lesson in in the course, Operating system, which is a part of The School of Computer Science

Objective

edit

Virtual Memory

edit

virtual memory as a memory management technique in which non-contiguous memory is presented to software as contiguous memory. virtual addresses are mapped into real addresses.

Introduction

edit

Virtual memory is a computer design feature that permits software to use more main memory (the memory which the CPU can read and write to directly) than the computer actually physically possesses.

Most computers possess four kinds of memory: registers in the CPU, caches both inside and adjacent to the CPU, physical memory, generally in the form of RAM which the CPU can read and write to directly and reasonably quickly; and disk storage, which is much slower, but also much larger. Many applications require access to more information (code as well as data) than can be stored in physical memory. This is especially true when the operating system is one that wishes to allow multiple processes/applications to run seemingly in parallel. The obvious response to the problem of the maximum size of the physical memory being less than that required for all running programs is for the application to keep some of its information on the disk, and move it back and forth to physical memory as needed, but there are a number of ways to do this.

One option is for the application software itself to be responsible both for deciding which information is to be kept where, and also for moving it back and forth. The programmer would do this by determining which sections of the program (and also its data) were mutually exclusive, and then arranging for loading and unloading the appropriate sections from physical memory, as needed. The disadvantage of this approach is that each application's programmer must spend time and effort on designing, implementing, and debugging this mechanism, instead of focusing on their application; this hampered programmers' efficiency. Also, if any programmer could truly choose which of their items of data to store in the physical memory at any one time, they could easily conflict with the decisions made by another programmer, who also wanted to use all the available physical memory at that point.

The alternative is to use virtual memory, in which a combination of special hardware and operating system software makes use of both kinds of memory to make it look as if the computer has a much larger main memory than it actually does. It does this in a way that is invisible to the rest of the software running on the computer. It usually provides the ability to simulate a main memory of almost any size (as limited by the size of the addresses being used by the operating system and cpu; the total size of the Virtual Memory can be 232 for a 32 bit system, or approximately 4 Gigabytes, while newer 64 bit chips and operating systems use 64 or 48 bit addresses and can index much more virtual memory).

This makes the job of the application programmer much simpler. No matter how much memory the application needs, it can act as if it has access to a main memory of that size. The programmer can also completely ignore the need to manage the moving of data back and forth between the different kinds of memory.

In technical terms, virtual memory allows software to run in a memory address space whose size and addressing are not necessarily tied to the computer's physical memory. While conceivably virtual memory could be implemented solely by operating system software, in practice its implementation almost universally uses a combination of hardware and operating system software.

Base and Bounds Method

edit

2-level Paging

edit

Multi-level Paging

edit

Swap Partions

edit

Evaluating Performance/Overhead

edit

Assignments

edit

Completion status: this resource is a stub, which means that pretty much nothing has been done yet.