- Course: CS110
- Name: SooYoung Jung
- Homework Assignment #5
- Due Date: 11/12/00
- Date: 11/12/00
- Formatter: HTML
- OSC, 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?
- In this case, LRU (Least Recently Used) will be appropriated. All
shelf spaces are assigned with certain products in supermarkets and
it does not mean that oldest products (First in) are not selling well.
As a result, least recently unused products are occupied space
which is wasting space. Get rid of the product that is not used
recently.
- OSC, 6.16, pg 479, 3 Points
Why are cache blocks always much smaller
than virtual memory pages, often a hundred times smaller?
- Cache memory is expensive. Also, cache directly addresses
memory but virtual memory is not. To be used more effective on
cache, it should be smaller.
- 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 disk:
0.5 rotation + 2.625 (rotation to
get all sectors from 0) = 3.125 rotation.
300round : 60second = 3.125
: x second
x = 60 * 3.125 / 300 = 0.625s,
0.625 second needed
to read all the sectors of a track in order.
4096bytes : 0.625s
= y byte : 1s
y = 4096 / 0.625 = 6553.6 bytes/second.
Noninterleaved
disk:
0.5 rotation + 0.875 (rotation to get all sectors from
0) = 1.375 rotation.
300round : 60second = 1.375 : x second
x
= 60 * 1.375 / 300 = 0.275s,
0.275 second needed to read all the
sectors of a track in order.
4096bytes : 0.275s = y byte : 1s
y
= 4096 / 0.275 = 14894.5 bytes/second.
Degraded 44% due to interleaving.
- 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.
- Device Drivers
- Device-independent os software
- Device Drivers
- Device-independent os software
- User level software
- T, 5.9, 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.
- 10 + 12 + 2 + 18 + 38 + 34 + 32 = 146 cylinders movement.
146
* 6 = 876 msec
- 0 + 2 + 12 + 4 + 4 + 36 + 2 = 60 cylinders movement.
60
* 6 = 360 msec
- 20 -> 22 -> 38 -> 40 -> 10 -> 6 -> 2
0
+ 2 + 16 + 2 + 30 + 4 + 4 = 58 cylinders movement.
58 * 6 = 348 msec
- 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?
- 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?
- 110 baud lines : 11 interrupts/second so 4 * 11 = 44msec.
- 4800 baud lines : 480 interrupts/second so 4 * 480 =
1920msec. The method will not work on 4800 baud lines because
the system can only take care of 250 interrupts/second.
- t.7.2, pg 313.
2 Points
Write a UNIX pipeline that prints the
eighth line of file Z on standard output.
- t.7.5, pg 313.
2 Points
When the UNIX shell starts up a process,
it puts copies of its environment variables, such as HOME, on the process'
stack, so the process can find out what its home directory is. If this process
should later fork, will the child automatically get these variables too?
- Yes. fork will make exact copy of the parent process. As
a result, the child will have same variables on the exact copy of the
stack.
- t.7.7, pg 313.
2 Points
To what hardware concept is a signal
closely related? Give two examples of how signals are used.
- Signal is similar to hardware interruption.
keyboard interruption
produced by the ^C character. Job control uses signals to start
and stop subprocesses on demand (exceptional events).
- t.7.13, pg 313.
3 Points
If a UNIX process runs for 1 sec without
competition from other processes, how long does it take for its CPU usage
counter to get back down to 0?
- CPU usage is divided in half every second so first second
it is 30, 2:15, 3:7.5, 4:3.5 5:1.5 6:0.75 7:0
So it is 7 seconds.
- t.7.14, pg 314. 2 Points
About how long does it take to fork off a
child process under the following conditions: text size = 100K bytes, data
size = 20K bytes, stack size = 10K bytes, process table size = 1K, user
structure = 5K. The kernel trap and return takes 1 msec, and the machine can
copy one 32-bit word every 500nsec. Text segments are shared.
- 20 + 10 + 1 + 5 = 36K needed to be copied since text segments
(100K) are shared.
Machine can copy one 32-bit word every 500 nsec
= two 32-bit words(8bytes) every 1microsec.
8 bytes : 1 microsec
= 36K = 36864bytes : x microsec
x = 36864 / 8 = 4608 microsec.
And
also, the kernel trap and return takes 1 msec which is 1000microsec.
Therefore
4608 + 1000 = 5608 microsec.
- t.7.19, pg 314. 4 Points
When the file /usr/ast/work/f is
opened, several disk accesses are needed to read i-node and directory blocks.
Calculate the number of disk accesses required under the assumption that the
i-node for the root directory is always in memory, and all directories are one
block long.
- 8 disk accesses are required under the assumption that the i-node for the root
directory is always in memory.
4 accesses are needed to read directory block (/, /usr, /usr/ast,
/usr/ast/work) and
4 accesses are needed to read i-node (/usr, /usr/ast, /usr/ast/work,
/usr/ast/work/f).
- s.21.6, pg 694 4 Points
Does 4.2BSD UNIX give scheduling priority to
I/O or CPU-bound processes? For what reason does it differentiate between
these categories, and why is one given priority over the other? How does it
know which of these categories fits a given process?
- 4.2BSD UNIX gives scheduling priority to
I/O-bound processes because I/O-bound processes have more work with users.
When system can schedule more time on I/O-bound processes, system
will respond more often to users so users will feel the system is fast.