1
votes

I'm reading Operating System Concepts by Avi Silberschatz, in chapter 8 Main Memroy, it goes like:

Frequently, on a 32-bit CPU, each page-table entry is 4 bytes long, but that size can vary as well. A 32-bit entry can point to one of 232 physical page frames. If frame size is 4 KB (212), then a system with 4-byte entries can address 244 bytes (or 16 TB) of physical memory. We should note here that the size of physical memory in a paged memory system is different from the maximum logical size of a process. As we further explore paging, we introduce other information that must be kept in the page-table entries. That information reduces the number of bits available to address page frames.A 32-bit CPU uses 32-bit addresses, meaning that a given process space can only be 232 bytes (4 GB). Therefore, paging lets us use physical memory that is larger than what can be addressed by the CPU’s address pointer length.

I'm really confused with some concepts now.

In the first example(4KB frame size and 232 frames), since we have 32-bit frame number and 12-bit offset, is the logical address 44-bit? So what's relationship between logical address space and the CPU's word size?

In the second example(32-bit CPU using 32-bit addresses), how should I understand the physical memory that can be addressed by the CPU's address pointer length? And is the CPU's address pointer 32-bit long since CPU uses 32-bit addresses?

1

1 Answers

1
votes

In the first example(4KB frame size and 232 frames), since we have 32-bit frame number and 12-bit offset, is the logical address 44-bit?

From a pure theoretical perspective that is possible but in practice a page table entry also contains information such as dirty bit, set bit and many other things for the purpose of virtual memory management.

Your book talks about it here

As we further explore paging, we introduce other information that must be kept in the page-table entries. That information reduces the number of bits available to address page frames.

So even if the page table entry size is 32-bit, we can’t use all the bits for frame numbers. Generally in 32-bit CPU’s every process has a logical address space equal to 4 GiB and if we have frame size equal to 4096 Bytes then effectively we need 20 bits for the page numbers. Remaining 12 bits can be used to store other associated information.

In the second example(32-bit CPU using 32-bit addresses), how should I understand the physical memory that can be addressed by the CPU's address pointer length?

This is just extension of above stated fact. For example If you decide to use 21 bits instead of 20 for your frame numbers then you have double the logical address space to 8 Gib. However you must use some mechanism to map this 8 GiB logical address space to 4 GiB (may be swap out some pages to disk) physical address space because generally (not using some fancy technics) 32-bit CPU will be limited to 4 GiB of physical memory.

Yes

summary:- physical address space is determined by CPU's program counter. a 32-bit CPU will have a 32-bit program counter. logical address space is just an abstraction added for the purpose of security and multi programming along other things. no matter what is the size of your logical address space eventually it must be mapped to the physical address space.

watch these video's for further clarification. Virtual Memory playlist