Difference between virtual page and page frame?
Asked Answered
F

7

21

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?

Funkhouser answered 15/2, 2017 at 19:23 Comment(0)
B
21

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
Bulkhead answered 15/2, 2017 at 19:31 Comment(0)
A
18

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.

Antiscorbutic answered 16/2, 2017 at 1:19 Comment(0)
S
12

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.

Stomachic answered 24/8, 2019 at 16:9 Comment(0)
P
9

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]

Paresthesia answered 19/4, 2019 at 15:55 Comment(1)
perfect explanationSanguine
A
2

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.
Aerify answered 19/10, 2018 at 7:49 Comment(0)
P
0

Page frame is a physical property of main memory partition into different segments for virtual address storage. It come in different size 1/2kb, 2k, 1.5 etc.

Paulitapaulk answered 19/1, 2021 at 13:51 Comment(0)
D
0

Paged allocation divides the computer's primary memory into fixed-size units called page frames, and the program's logical (or virtual) address space into pages of the same size. The hardware memory management unit maps pages to frames.

Deuteranope answered 2/3, 2022 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.