Virtual memory sizing: A program uses 16-bit virtual addresses. If the page size is 0.5 KB (that is, 512 bytes), how many pages exist in the virtual address space?

Difficulty: Medium

Correct Answer: 128

Explanation:


Introduction / Context:
Paging divides an address space into fixed-size pages. The number of virtual pages depends on total virtual address space size and the page size. This question tests the ability to convert address bits and page size to the number of pages.



Given Data / Assumptions:

  • Virtual address width = 16 bits.
  • Page size = 0.5 KB = 512 bytes.
  • 1 KB = 1024 bytes.


Concept / Approach:

Total virtual address space equals 2^address_bits bytes. The number of pages equals total virtual bytes divided by bytes per page. With a power-of-two page size, the result is also a power of two. Use exponents to simplify division.



Step-by-Step Solution:

Compute total virtual space: 2^16 bytes = 65536 bytes.Compute page size in bytes: 0.5 KB = 512 bytes = 2^9 bytes.Number of pages = total bytes / page size = 2^16 / 2^9 = 2^(16 - 9).2^(16 - 9) = 2^7 = 128 pages.


Verification / Alternative check:

Alternative: Determine page offset bits equal to log2(512) = 9 bits. The remaining 16 - 9 = 7 bits form the virtual page number. 7 bits index 2^7 = 128 pages. Both methods agree.



Why Other Options Are Wrong:

  • 16, 32, 64: These correspond to 2^4, 2^5, 2^6 and would imply different address widths or page sizes; they do not match 16-bit with 512-byte pages.
  • None of the above: Incorrect because 128 is valid.


Common Pitfalls:

Confusing KB with 1000 bytes; forgetting that 0.5 KB equals 512 bytes; mixing up page offset bits with page number bits.



Final Answer:

128

More Questions from Operating Systems Concepts

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion