Operating Systems Quiz 3
Operating Systems Quiz 3
Daniel Guzman
CSCI 4730
12/8/14
Problems
1. a) Virtual address is 16 bits, physical is 13.
b) See Section below.
2. Data block ranges: 1-12 (direct), 13-1036 (L1 indirect), 1037-1049612 (L2 indirect), 10496131074791436 (L3 indirect).
1: 1 accesses (1 to direct block)
10: 1 accesses (1 to direct block)
200: 2 accesses (1 to L1 indirect block, 1 to direct block)
500: 2 accesses (1 to L1 indirect block, 1 to direct block)
1,000: 2 accesses (1 to L1 indirect block, 1 to direct block)
2,200: 3 accesses (1 to L2 indirect block, one to L1 indirect block, 1 to direct block)
10,000: 3 accesses (1 to L2 indirect block, one to L1 indirect block, 1 to direct block)
100,000: 3 accesses (1 to L2 indirect block, one to L1 indirect block, 1 to direct block)
1,000,000: 3 accesses (1 to L2 indirect block, one to L1 indirect block, 1 to direct block)
1,400,000: 4 accesses (1 to L3 indirect block, 1 to L2 indirect block, one to L1 indirect block, 1 to direct
block)
5,000,000: 4 accesses (1 to L3 indirect block, 1 to L2 indirect block, one to L1 indirect block, 1 to direct
block)
Problem 1b
To begin, each virtual address is split into 5 bits for virtual page and 11 bits for offset.
ppppp ooooooooooo
\---/ \---------/
page
offset
So, to begin with our translations, the initial table state is as follows:
Virtual Page
Physical Frame
Valid
Dirty
Read Only
Use
Physical Frame
Valid
Dirty
Read Only
Use
Next:
READ 00011 11111100101
00011 is 3, so this read is from page #3. 3 is not valid, so this means it has to be put into memory. Were
using a sequential page replacement algorithm, so well start from frame 0. Frame 0 is currently occupied
by page 0, and its state is dirty, which means that the kernel will save the contents of page 0 to
disk/whatever backs the page table. After saving, the contents of page #3 will be read into frame 0, and the
page table will set page #0s valid bit to 0, page #3s frame to 0, and page #3s valid bit to 1. The read is
Physical Frame
Valid
Dirty
Read Only
Use
Next instruction:
READ 00110 11000001001
00110 is 6, so this read is for page #6. Page 6 is not valid, so again, well be forced to go to disk. This time,
well be loading into frame 1, so we have to check the current page there. Page #4 currently occupies
frame 1, and its dirty, so again, well have to go ahead and write it out to disk/backing store to preserve its
contents. The shift then happens, loading page #6 into frame #1 and updating the table accordingly. The
read then occurs as normal, reading from physical address 0111000001001. Afterward, this is the result:
Virtual Page
Physical Frame
Valid
Dirty
Read Only
Use
Lastly:
WRITE 00010 11111111111
00010 is page #2, which is both valid and in memory! The translation will take it from page #2 to frame 3,
so the end address is 1111111111111. However, this page is read only, so the attempt to write is ultimately
doomed to fail.