Paging, Virtual Address Space and Physical Memory and Page Frames

  • Thread starter zak100
  • Start date
  • #1
zak100
Gold Member
462
11

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.

Main Question or Discussion Point

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.
 

Answers and Replies

  • #2
.Scott
Homework Helper
2,534
912
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
BvU
Science Advisor
Homework Helper
2019 Award
13,341
3,153
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
.Scott
Homework Helper
2,534
912
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
11,794
5,402
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
anorlunda
Staff Emeritus
Insights Author
8,582
5,460
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
1,442
760
I remember that -- it was a good set of approaches -- rivalled Novell's netware . . .
 
  • #9
zak100
Gold Member
462
11
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
BvU
Science Advisor
Homework Helper
2019 Award
13,341
3,153
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
1,955
252
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
BvU
Science Advisor
Homework Helper
2019 Award
13,341
3,153
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
zak100
Gold Member
462
11
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
1,955
252
There is no such term of page map in our book in this context.
I think BvU meant the same as a page table.

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
zak100
Gold Member
462
11
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
zak100
Gold Member
462
11
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.
 

Related Threads on Paging, Virtual Address Space and Physical Memory and Page Frames

  • Last Post
Replies
14
Views
3K
  • Last Post
Replies
2
Views
1K
Replies
3
Views
1K
  • Last Post
Replies
7
Views
2K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
2K
  • Last Post
Replies
3
Views
271
Replies
2
Views
1K
Replies
15
Views
853
Top