Paging, Virtual Address Space and Physical Memory and Page Frames

In summary, page tables in a computer operating system contain a list of virtual addresses corresponding to physical addresses. The page table is loaded into physical memory when the program is started, and the operating system uses this table to map pages of virtual memory into physical memory. When a process requests a page from virtual memory, the operating system looks up the page in the page table and sends the request to the processor.
  • #1
zak100
462
11
TL;DR Summary
I am trying to understand the concept of paging. How Virtual address Space is divided into pages and how Physical memory is divided into page frames. I found an example. I have solved but I am not sure what is the correct answer for it.
Hi,
The following is not a homework question.

My question is:
A computer has 32-bit virtual addresses and 128-KB pages.
• How many entries are needed in the page table if traditional (one-level)
paging is used?
• If the physical memory is half size of virtual memory, many page frames are
there in the physical memory?

My answer is:

Total pages required = 2^32/2^7 = 2^25 pages
Thus page table has 2^25 entries

PM = 2^16
Total page frames in PM = 2^16/2^ 7= 9 page frames

Somebody please guide me what is the correct solution for the above.

Zulfi.
 
Technology news on Phys.org
  • #2
The pages are 128K, not 128. So recalculate your traditional page table size.

Physical memory is half the size of your addressing space.
Your addressing space is 32-bits, hence 4G (presumably 4GBytes).
So how much physical memory do you have? It is not the 2^16 (65536 bytes) that you suggest.
 
  • #3
A computer is supposed to be able to address words in memory, not necessarily bytes.
Let's nevertheless assume bytes are to be addressed idividually. How many bits are needed to address one byte on a 128 kB page ?
 
  • #4
BvU said:
A computer is supposed to be able to address words in memory, not necessarily bytes.
Let's nevertheless assume bytes are to be addressed individually. How many bits are needed to address one byte on a 128 kB page ?
Although modern computers commonly retrieve memory into the CPU in 32-bit, 64-bit, or much larger chunks, addressing space is still normally in bytes. Most modern computers address at the byte level - even though the physical buses are commonly 256-bits wide or greater.
 
  • Like
Likes sysprog
  • #5
Here's a video that describes the concepts of physical memory, virtual memory, paging and caching:



The keypoint is virtual memory is organized into blocks called pages that can be mapped into physical memory. The virtual memory can then be stored on disk and retrieved when the program is about to be run. The virtual memory is mapped to someplace on the disk when stored or mapped to someplace in physical memory when ready to be used by the CPU.
 
  • Like
Likes zak100, sysprog and Klystron
  • #7
Does anyone remember the company Apollo Computers Inc. from the 1980s? They did something very innovative.

They created a large virtual address space. Every computer in the network, and every disk drive on every computer and every screen were memory mapped into the single flat virtual address space. Every file on every disk mapped into a block of virtual address space. This greatly simplified the OS. The file system, privileges, security, transfers, and page fault handling could all share a common mechanism ... memory mapping and virtual memory access.

Of course in those days, the size of affordable RAM and disk storage were very small by today's standard, so that "huge" virtual address space covering the whole network was only 256 MB. It was also a time where one could have a proprietary LAN and no thoughts of an Internet WAN.
 
  • Like
Likes sysprog
  • #8
I remember that -- it was a good set of approaches -- rivalled Novell's netware . . .
 
  • #9
Hi,
Thanks for your help @.Scott. 128K= 2^7 * 2^10 = 2^17
Total pages in virtual address space = 2^32/2^17 = 2^15

Physical memory is half the size of the virtual address space= 2^32/2 = 2^31 = 2GB

Page frames = 2^31/ 2^15 = 2^16.

Somebody please guide me if the above is correct or not.

Zulfi.
 
  • #10
zak100 said:
Page frames = 2^31/ 2^15 = 2^16.
How much space does the page map itself need ? Can it reside on disk or does it have to be in memory ?
 
  • #11
BvU said:
How much space does the page map itself need ? Can it reside on disk or does it have to be in memory ?
The page table needs as much entries as there are pages in virtual memory, which is 2^17. ( not 2^15, there are 2x as much virtual pages as physical pages).
Each entry would need 16 bits for a physical address of a page frame, and a few more bits for the status of the virtual page (modified, present, cacheble, security info). You'd expect they would use 4 bytes, to make address calculations easy. You would need 2^19 bytes = 1/2 Mb.

All recent operating systems that use paging, will use different page tables for different processes.. If the system switches to another process, a processor register will be made to point to another page table.
This means you might need more space for all the page tables.
The old page table entries. are mostly not swapped out. If you do this you might have to change the page tables on disk when a page of an inactive process is swapped out.

A multi-level paging scheme is used for large memories. There are often many small processes that use only a small part of the virtual address space. If you use a higher level page directory that points to lower level page tables, these page tables don't have to be created before the corresponding block of virtual memory is needed.
 
  • #12
Dear @willem2, the question was directed at @zak100 . It's his (her) exercise!
Although I wonder if the exercise composer realized the complexity (and ambiguity) of the whole thing !
 
  • #13
Hi,
Thanks all for your interest in my problem.
@willem2
How much space does the page map itself need ?

There is no such term of page map in our book in this context.

@BvU

there are pages in virtual memory, which is 2^17

Can you please show me how you got 2^17.

Zulfi.
 
  • #14
zak100 said:
There is no such term of page map in our book in this context.
I think BvU meant the same as a page table.

zak100 said:
Can you please show me how you got 2^17.
I saw you had 2^16 page frames in your post #9, so Imultiplied by 2 as there are twice as much virtual pages as page frames. Unfortunately you had the right number of virtual pages, but not page frames, which should have been 2^14. This gives 2^15 virtual pages as you had.
Wich also means the space for a page table will be 4 times as small
 
  • Like
Likes zak100
  • #15
Hi,
Thanks for removing my confusion, so my answer 2^15 is correct. 2^14, you got this because physical memory is half the size of virtual memory. If this is wrong please let me know.

Thanks everybody for the video and for this useful discussion.

God bless you all.

Zulfi.
 
  • #16
Hi,
I still have confusion with this line:

A computer has 32-bit virtual addresses

and

If the physical memory (PM) is half size of virtual memory,

Can we say that PM = 2^31?

Zulfi.
 

1. What is paging?

Paging is a memory management technique used by operating systems to efficiently manage and utilize memory. It involves dividing the virtual memory space into smaller fixed-sized blocks called pages, which are then mapped onto physical memory locations called page frames.

2. What is virtual address space?

Virtual address space refers to the total amount of memory that a process can access. It is divided into pages, which are mapped onto physical memory locations. Each process has its own separate virtual address space, allowing multiple processes to run simultaneously without interfering with each other's memory.

3. What is physical memory?

Physical memory, also known as main memory or RAM, refers to the actual physical memory chips installed on a computer. It is used to store data and instructions that are currently being used by the computer. The size of physical memory determines the amount of data and programs that can be accessed and used by the computer at any given time.

4. What are page frames?

Page frames are the physical memory locations where pages are stored. Each page frame has a fixed size and can hold one page of data. When a process requests data from a page that is not currently in physical memory, the operating system will allocate a page frame for that page and bring it into memory.

5. How does paging improve memory management?

Paging allows for efficient use of memory by dividing the virtual memory space into smaller, more manageable pages. This reduces memory fragmentation and allows multiple processes to share the same physical memory without interfering with each other. Additionally, paging allows for virtual memory to be larger than physical memory, allowing more programs to be run simultaneously.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
19
Views
979
  • Programming and Computer Science
Replies
7
Views
3K
Replies
25
Views
1K
  • Beyond the Standard Models
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
19
Views
34K
Back
Top