Josh Smallman
CS 110
Homework Assignment 5
Due Wednesday, Nov. 24th 6PM
Formatter: HTML
-
SCO, 6.4, pg 477, 4 Points
A computer has 16 pages of virtual address space but only four
real pages (page frames).
Initially, the memory is empty.
A program references the virtual pages in the order:
0, 7, 2, 7, 5, 8, 9, 2, 4
-
Which references cause a page fault with LRU?
-
Which references cause a page fault with FIFO?
LRU: 2
FIFO: 8, 9, 4
-
SCO, 6.15, pg 479, 4 Points
Supermarkets are constantly faced with a problem similar
to page reference in virtual memory systems.
They have a fixed amount of shelf space to display
an ever-increasing number of products. If an important
new product comes along, say, 100% efficient dog
food, some existing product must be dropped from
the inventory to make room for it.
The obvious replacement algorithms are
LRU and FIFO.
Which of these would you prefer?
Least Recently Used, which would translate to the least popular item being removed in order
to make room for the new product. Since we're removing the LRU product, the least amount of people (ie people who did buy that) would be affected.
-
SCO, 6.16, pg 479, 3 Points
Wy are cache blocks always much smaller than virtual
memory pages, often a hundred times smaller?
Because cache is much more expensive than memory. As the relative cost of cache decreases,
the difference in size will most likely decrease as well.
-
T, 5.3, pg 237, 3 Points
A disk is double interleaved,
i.e., sectors are in the order 0, 3, 6, 1, 4, 7, 2, 5.
It has eight sectors of 512 bytes per track,
and a rotation rate of 300 rpm.
How long does it take to read all the sectors of a track
in order, assuming the arm is already correctly
positioned,
and 1/2 rotation is needed to get sector 0 under
the head?
What is the data rate?
Now repeat the problem for a noninterleaved disk,
i.e., sectors are in the order 0, 1, 2, 3, 4, 5, 6, 7,
with the same characteristics.
How much does the data rate degrade due
to interleaving?
interleaved, not in order, so takes half rotation between sectors, plus initial half rotation,
makes 8 half rotations, or 4 total rotations, at 300rpm, makes .2 * 4 = .8 seconds.
data rate = 4096 bytes / .8 seconds = 5120 bytes/second
Noninterleaved: takes only one half rotation to get to initial sector 0,
so .5 * (1/300) = .00166 seconds
data rate = 4096 bytes / .00166 seconds = 2457600 bytes/second
rate degrades by 2452480 bytes?
-
T, 5.7, pg 237,
5 Points
In which of the four i/o software layers
(Interrupt drivers, Device drivers, Device-independent
os software, and User level software) is each of the
following done.
-
Computing the track, sector, and head for a disk read.
-
Maintaining a cache of recently used blocks.
-
Writing commands to the device registers.
-
Checking to see if the user is permitted to use
the device.
-
Converting binary integers to ASCII for printing.
Interrupt drivers: ID
Device drivers: DD
Dev.-Indy Os software: OS
User Level Software: UL
1: DD
2: OS
3: ID
4: OS
5: UL
-
T, 5.7, pg 238,
3 Points
Disk requests come to the disk driver
for cylinders 10, 22, 20, 2, 40, 6, and 38,
in that order.
A seek takes 6msec per cylinder moved.
How much seek time is needed for:
-
First come, first served
-
Closet cylinder next.
-
SCAN
In all cases the arm is initially at 20 and moving towards track 0.
FCFS: 20 to 10 = 20, 10 to 22 = 12, 22 to 20 = 10, 20 to 2 = 18, 2 to 40 = 38
40 to 6 = 34, 6 to 38 = 32
20 + 12 + 10 + 18 + 38 + 34 + 32 = 164*6msec = 984ms
CCN = 20 to 20 to 22 to 10 to 6 to 2 to 38 to 40
2 + 12 + 4 + 4 + 36 + 2 = 60*6msec = 360msec
SCAN: 20 to 10 to 6 to 2 to 20 to 22 to 38 to 40
10 + 4 + 4 + 18 + 2 + 16 + 2 = 46*6msec = 276msec
-
T, 5.12, pg 238,
3 Points
The clock interrupt handler on a certain computer requires
2 msec (including process switching overhead)
per clock tick.
The clock runs at 60Hz.
What fraction of the CPU is devoted to the clock?
60*2msec = 120msec/1 sec = 12% cpu devoted to clock
-
T, 5.14, pg 238,
3 Points
Consider how a terminal works.
The driver outputs one character and then blocks.
When the character has been printed, an interrupt
occurs and a message is sent to the blocked drive,
which outputs the next character and then blocks again.
If the time to pass a message, output a character,
and block is 4msec,
does this method work well on 110 baud lines?
How about 4800 baud lines?
4 msec per character. 110 baud lines have throughput of
110 bits/sec / 8 bits/byte = 13.75 bytes/sec
Works ok for 110 baud lines, since its so slow!
Won't work on 4800, since throughput is high so too much
time is wasted with the interrupt!