Math
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.
1. Will this program fit in the address space?
2. If the page size were 512 bytes, would it fit?
Give the reason for all answer.
Answer:
Q1.
Address space for each process: 65536 bytes
Page Size: 4096 bytes
Available address space =65536 / 4096=16 pages
For the text size 32768 bytes address space is =(32768/4096) = 8 pages
For the text size 16386 bytes address space is =(16386/4096) = 4.0034 = 5 pages
For the stack size 15870 bytes address space is =(15870/4096) = 3.874 = 4 pages
The available space is 16 pages but the required space is (8+5+4)=17 pages which is greater than
the available space. Hence this program does not fit in the available address space.
Q.2
If the page size were of 512 bytes then
Address space for each process: 65536 bytes
Page Size: 512 bytes
Available address space = (65536/512) = 128 pages
then,
For the text size 32768 bytes address space is =(32768/512) = 64 pages
For the text size 16386 bytes address space is =(16386/512) = 32.0039 = 33 pages
For the stack size 15870 bytes address space is =(15870/512) = 30.996 = 31 pages
The available space is 128 pages but the required space is (64+33+31)=128 pages which is equal to
the available space. Hence this program does not fit in the available address space.

Comments
Post a Comment