A computer provides each process with 65536 bytes of address space divided into pages of 4096 bytes. A particular program has a text size of 32768 bytes, a data size of 16386 bytes and a stack size of 15870 bytes. [Remember that a page may not contain parts of different segments]
Answer the following questions:
Will this program fit in the address space?
If the page size were 512 bytes, would it fit?
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
First answer (4kB page size):
Text = 32768 / 4096 = 8 pages
Data = 16386 / 4096 = 4.0005 pages, or 5 pages, since that last 0.0005 of a page must occupy its own page
Stack = 15870 / 4096 = 3.875 pages, or 4 pages, since that last 0.875 of a page must occupy its own page
8 + 5 + 4 = 17 pages, or one more than the 16 pages of space provided (16 * 4096 = 65536). So the first answer is no.
Second answer (512B page size):
Data = 32768 / 512 = 64 pages
Text = 16386 / 512 = 32.004 pages, or 33 pages, since that last 0.004 of a page must occupy its own page
Stack = 15870 / 512 = 30.996 pages, or 31 pages, since that last 0.996 of a page must occupy its own page
64 + 33 + 31 = 128 pages, which is exactly the number provided to the process (128 * 512 = 65536). So the second answer is yes.