0% found this document useful (0 votes)
38 views

Virtual Memory

Virtual memory is a technique that allows processes to run even if they are not entirely present in physical memory. It abstracts main memory so programs can be larger than physical memory. This separation of logical memory from physical memory provides several benefits: it allows for larger virtual address spaces, more processes can run simultaneously since they take up less physical memory, and less I/O is needed since user programs do not need to be entirely loaded into memory. Virtual memory uses page frames to map logical pages to physical memory, allowing for sparse address spaces with holes that can be filled as programs' stacks and heaps grow. It also enables sharing of files, memory, and libraries between processes.

Uploaded by

leo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Virtual Memory

Virtual memory is a technique that allows processes to run even if they are not entirely present in physical memory. It abstracts main memory so programs can be larger than physical memory. This separation of logical memory from physical memory provides several benefits: it allows for larger virtual address spaces, more processes can run simultaneously since they take up less physical memory, and less I/O is needed since user programs do not need to be entirely loaded into memory. Virtual memory uses page frames to map logical pages to physical memory, allowing for sparse address spaces with holes that can be filled as programs' stacks and heaps grow. It also enables sharing of files, memory, and libraries between processes.

Uploaded by

leo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Virtual memory

Intro

In previous chapter, it tackles about memory-management strategies, and all that strategies have the
same goal; to keep many processes in main memory to allow multi-programming, but it requires that an
entire process be in the memory before it can execute.

It comes up with a solution or technique to this problem, and it is virtual memory.

What is virtual memory?

Virtual Memory technique:

Running process need not be in memory entirely

Programs can be larger than physical memory

Abstraction of main memory; need not concern with storage limitations

Allows easy sharing of files and memory

Provide efficient mechanism for process creation

Background

The requirement that instructions must be in physical memory to be executed seems both necessary and
reasonable; but it is also unfortunate, since it limits the size of a program to the size of physical memory.
In fact, an examination of real programs shows us that, in many cases, the entire program is not needed.
For instance, consider the following:

• Programs often have code to handle unusual error conditions. Since these errors seldom, if ever, occur
in practice, this code is almost never executed.

• Arrays, lists, and tables are often allocated more memory than they actually need. An array may be
declared 100 by 100 elements, even though it is seldom larger than 10 by 10 elements.

• Certain options and features of a program may be used rarely.

The ability to execute a program that is only partially in memory would confer many benefits:

• A program would no longer be constrained by the amount of physical memory that is available. Users
would be able to write programs for an extremely large virtual address space, simplifying the
programming task.
• Because each user program could take less physical memory, more programs could be run at the same
time, with a corresponding increase in CPU utilization and throughput but with no increase in response
time or turnaround time.

• Less I/O would be needed to load or swap user programs into memory, so each user program would
run faster.

Virtual memory – involves the separation of logical memory as perceived by users from physical memory.

- This separation allows an extremely large virtual memory to be provided for programmers when
only a smaller physical memory is available.
- makes the task of programming much easier, because the programmer no longer needs to worry
about the amount of physical memory available; she can concentrate instead on the problem to
be programmed.

Virtual address space - refers to the logical (or virtual) view of how a process is stored in memory.

- this view is that a process begins at a certain logical address 0 exists in contiguous memory
- physical memory may be organized in page frames and that the physical page frames assigned to
a process may not be contiguous.
- It is up to the memory management unit (MMU) to map logical pages to physical page frames in
memory.

We allow the heap to grow upward in memory as it is used for dynamic memory allocation. Similarly, we
allow for the stack to grow downward in memory through successive function calls.

The large blank space (or hole) between the heap and the stack is part of the virtual address space but
will require actual physical pages only if the heap or stack grows.

Virtual address spaces that include holes are known as sparse address spaces.

- Using a sparse address space is beneficial because the holes can be filled as the stack or heap
segments grow
- Or if we wish to dynamically link libraries (or possibly other shared objects) during program
execution.
In addition to separating logical memory from physical memory, virtual memory allows files and memory
to be shared by two or more processes through page sharing (Section 8.5.4). This leads to the following
benefits:

System libraries can be shared by many processes through mapping of the shared objects into virtual
address space.

Processes can share memory by mapping readwrite pages into virtual address space

Pages can be shared during process creation with the fork(); speeding up process creation

You might also like