Difference between virtual page and page frame?

26,146

Solution 1

Page frame is a physical property of the main memory. Whereas, virtual page is... virtual.

frame 0  frame 1  frame 2  frame 3  frame 4
----------------------------------------------
|        |        |        |        |        |
|        |        |        |        |        |
---------------------------------------------- Main Memory

Solution 2

Physical memory is organized into PAGE FRAMES. The size of a page frame is a power of 2 in bytes and varies among systems.

Logical memory is organized into PAGES. The size of page matches a page frame.

A logical address is divided into a page selector and an offset into the page.

Logical pages are mapped to page frames using page tables. The structure of a page table varies among systems. The pages selector of a logical address serves as an index into a page table.

In most systems, the page tables can specify valid logical addresses that have no associated page frame. This is a virtual memory system. If an application attempt to access such a page, it triggers a page fault exception. The operating system page fault handler must allocate a physical page frame, load the page frame using data from secondary storage, update the page table to map the logical page to the newly allocated physical page frame, and finally restart the instruction that caused the fault.

The operating system manages the page tables. The CPU (transparently to the application) translates logical page frames into physical page frames using the page table.

Solution 3

A page (or memory page, or virtual page, or logical page) is a fixed-length contiguous block of virtual memory.

A frame (or memory frame, or physical page, or page frame) is a fixed-length block of RAM (ie. physical memory, it exists - as in "physical". Virtual memory is invented for our mathematics to work properly and efficiently in order to securely manage memory).

Notice that the frame may not be contiguous, but the page will be. We want the process, the OS to deal with consecutive addresses as it makes everything easier. Let a dedicated hardware chip (the MMU) correspond the virtual address to the proper physical address & vice versa.

Virtual addresses are used by the process, while physical addresses are used by the hardware, ie. the CPU (placing address in its address bus to request a memory access) and the RAM subsystem (MMU, page tables etc). When a program is compiled, the compiler converts a program code into machine understandable code and in between this process, addresses spaces are set in the form of virtual addresses. When processed by the processor, they're again mapped into the physical locations available in memory whether it'd be RAM or HDD, with the help of the MMU.

PS. I don't condone the use of the term page frame. You likely realize that it is the source of confusions. Stick to 'page' and 'frame', two very simple words with clear meaning.

Solution 4

According to SILBERSCHATZ et, al. "The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called frames and breaking logical memory into blocks of the same size called pages." [OS concepts 9th ed]

Solution 5

Firstly, paging is a memory management scheme. Physical memory can be divided into frames and logical memory into pages. Pages are also called virtual pages and frames are referred to as page frames. All memory chunks in physical address space are identified with frame numbers and logical address with page numbers.

The page table consists of page number with its corresponding offset.

Physical address = (page size * frame number) + page offset
The frame number was derived from the page table and the pages are added into the empty frames.

Share:
26,146
Callat
Author by

Callat

I'm your avg nerd and new programmer I'm out to learn new software so that when the machines take over the world, I can take over the machine. "Knowledge is not enough, one must apply" Bruce Lee

Updated on January 20, 2021

Comments

  • Callat
    Callat over 3 years

    From what I understand pages come from overlays which are clusters of memory spaces generated by Virtual Memory. But I don't understand what frames are or how they relate.

    Can anyone explain what page and frame is and how it works?

  • Vijay Chavda
    Vijay Chavda over 4 years
    perfect explanation