Assignment 6, due Feb. 23

On all assignments, your name must be legible as it appears on your University ID card! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what lawyers call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the teaching assistant's mailbox. Never push late work under someone's door!

1. Background: Consider a disk with 8 sectors per track. Without interleaving, the sequence of sector numbers going around the track would be 0-1-2-3-4-5-6-7.

In a uniform interleaving, you use every i'th sector where the interval between successive sector numbers is a constant. The interleaving 0-2-4-6-1-3-5-7 is non-uniform because, while i=2 in most cases, the jump from 6 to 1 uses i=3 and the jump from 7 back to 0 uses i=1.

The sequence given by i=1 is usually described as non-interleaved, but technically, it is the simplest uniform interleaving.

a) List all of the uniform interleavings on 8 sectors, and for each, state the value of i. (0.5 points)

b) Give a general rule. If the disk has s sectors per track, what values of i give distinct uniform interleavings. (There is a formally correct mathematical description of the required relationship between s and i.) (0.5 points)

2. Background: Back in the days of Microsoft's DOS operating system, the system itself could not use more than 640K bytes of RAM. A typical system also had two 5 1/4 inch floppy drives. If you bought more memory than this, the system could not use it. However, some I/O drivers did use the extra memory. There were several alternative ways that drivers could use the extra memory:
• RAM disk: The floppy disks originally had a capacity of 360K bytes, so if you had 1 megabyte of RAM, you could use the extra RAM to hold a "virtual floppy disk" stored entirely in RAM. This was much faster than floppy disk, but it would lose all content when the system was powered down. Typically, the start-up script for the system would copy the boot disk to the RAM disk and then make that the system disk so that all loads of system applications would be fast.

• Disk cache: The extra RAM could be used as a cache to hold copies of recently accessed sectors from the disks being used on the system. When a user requests a read, the disk driver copies data from the cache if possible (a cache hit). In the event there is not a copy in cache (a cache miss), the software copies data from disk, keeping a copy of that data in cache. The driver also keeps a copy of data written to disk in the cache. The cache management software uses some approximation of least-recently-used (LRU) replacement.

a) Which use of the extra RAM allowed both floppy disks to be used for user data once the system was up and running? (0.3 points)

b) Which use of the extra RAM accelerated access to user files as well as system programs. (0.3 points)

c) Which use of the extra RAM required extra effort when a floppy disk was ejected from its drive? Explain the problem. (0.4 points)

3. Background: Some operating systems allow you to mount a file as a device, for example, Apple allows mounting disk image files (.dmg suffix). This primarily used as a software distribution mechanism, but it has a wide variety of potential uses. For example, after an old computer fails, it is sometimes possible to copy the disk image of that system into a file in the file system on a new computer and then extract and rescue content from the old file system that might otherwise have been lost. When a disk image file is mounted under an operating system, the directory structure stored on the mounted disk image becomes available on an equal footing with the directory structures of real disks mounted on that system.

a) Where does the disk scheduler go? Specifically, is there any need for a disk scheduler for the mounted disk image? Briefly, why or why not? (0.5 points)

b) What if the natural block size (the sector size) of my real disk differs from the natural block size of my mounted disk image file. Would this be easier to deal with using the Unix read() and write() kernel calls as a disk interface, or using the linearized sector number scheme outlined in the notes for Feb. 21? Briefly explain your answer. (0.5 points)