CSCI-UA.0202 Spring 2015 Homework 7
Handed out Saturday, March 28, 2015
Due 10:00 AM, Tuesday, April 7, 2015
Homework 7
These problems should be done on your own. As usual, we're not going
to grade these strictly (we'll mainly look at whether you attempted
them).
This homework is intended to reinforce knowledge and skills that the
second midterm will cover.
Page table size
Consider a processor architecture with 32-bit virtual addresses. In this architecture,
the memory management unit (MMU) expects a two-level page table structure.
On this architecture, the upper 6 bits of an address determine the page directory index, the next 10
bits determine the index in the second-level page table, and the bottom 16 bits determine the offset.
-
How many entries are in a page directory? Explain briefly.
-
How many entries are in a second-level page table? Explain briefly.
-
What is the page size on this machine? Explain briefly.
-
What is the maximum number of virtual pages per process? Explain briefly.
Page replacement policy
Suppose FIFO page replacement is used with four page frames and eight pages
and the program accesses the virtual pages in this order:
0172327103.
How many page faults will occur
if the four frames are initially empty? Now repeat this problem for LRU.
Event-driven programming
Choose True or False for the following assertions, and justify:
- T/F One benefit of event-driven programming is that the programmers don't have to worry
about concurrency issues at all.
- T/F Event-driven programming benefits CPU-bound programs more than
IO-bound programs.
- T/F By not using blocking/synchronous I/O, multiple I/O operations overlap, although a single thread is used. This enables I/O parallelism without requiring CPU parallelism at the same time.
Disk performance
Consider a disk with the following characteristics:
- The disk rotates at 12,000 RPM (rotations per minute)
- The disk has 10 platters (and 10 corresponding heads); the cost to
change which head is active is zero
- Each sector is 512 bytes
- There are 1024 sectors per track (we are ignoring the fact that the
number of sectors per track varies on a real disk)
- There are 4096 tracks per platter
- The track-to-track seek time is 0 milliseconds
- If the disk head has to seek more than a single track, the
seek time is given by 1 + t(.003) milliseconds, where t is the number of
tracks that the disk is seeking over.
- Ignore the time to transfer the bits from the disk to memory;
that is, once the disk head is positioned over the sector, the
transfer happens instantaneously.
- What is the storage capacity of the disk in bytes or
gigabytes? (Explain briefly.)
- What is the sequential transfer bandwidth, expressed in
bytes/second or megabytes/second? (Explain briefly.)
- Now assume that the disk with the above characteristics is
given a never-ending stream of requests to
read one sector at a time, with each request chosen randomly from all possible
sectors on the disk. Assume that these read requests are
scheduled in FIFO order. State the effective long-term
transfer rate that the disk can sustain, expressed in bytes/second
or kilobytes/second, and explain briefly.
In doing the third question, the following may be useful:
- You can (and probably should) make several percentage point
approximations, for example 4096 can be represented as 4000, and
13 x 7.5 is approximately 100.
- If we pick a track uniformly at random and then pick another
track uniformly at random, the expected (or average) number of
tracks between them is one-third (not one-half) the total
number of tracks on a platter (this can be derived using probability
theory; OSTEP also gives a derivation.
- The term "long-term transfer rate" refers to R/X, where R is the
number of bytes to transfer in each read, and X is the average length of
time that a read takes.
Disk scheduling
Disk requests come into the disk driver for tracks 10, 22, 20, 2, 40, 6,
and 38, in that order. A seek takes 6 msec per track moved (note that, among
other simplifications, we are not taking into account the length of the
seek). How much seek time is needed for the following scheduling algorithms?
(a) SSTF
(b) LOOK (SCAN, but doesn't move to the end)
In all cases, the arm is initially at track 20. (Note that SCAN is a synonym for the elevator algorithm.)
Adapted from Tanenbaum Chapter 5 Number 24.
File systems
Consider a file system that has the following description:
- The disk is divided into 1024-byte blocks.
- The beginning of the disk contains an array of 2^{16} inodes,
each of which can represent a file or be unallocated.
- A file has an indexed structure:
an inode contains (a) 8 data block pointers, each of which is 4 bytes and
each of which points to a disk block and (b)
a pointer to ONE indirect block, which is a disk block that itself contains data block
pointers.
- The inode also contains a userid (2 bytes), three time stamps (4 bytes each),
protection bits (2 bytes), a reference count (3 bytes), and the size (4
bytes).
- A directory contains a list of
(file_name,
inode_number)
pairs, where the file_name
portion is always
exactly 14
bytes, including the null terminator (if the file_name
would
otherwise be fewer than 14 bytes, it is padded to 14 bytes).
-
State the maximum file size, and explain briefly,
for example by showing your work. You may express your answer as a sum
of powers-of-two.
-
State the maximum number of files in a directory, and
explain briefly, for example by showing your work. Again, you may
express your answer as a sum of powers-of-two.
Last updated: Mon May 04 11:24:46 -0400 2015
[validate xhtml]