Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
466
Chapter 10 o Input/Output and Stable Storage
Summary
In this chapter, we covered the following topics:
1. mechanisms for communication between the processor and 1/0 devices, including
programmed 1/0 and DMA;
2. device controllers and device drivers;
3. buses in general, and the evolution of 1/0 buses in particular, found in modern
computer systems; and
4. disk storage and disk-scheduling algorithms.
In the next chapter, we will study the file system, which is the software subsystem
built on top of stable storage in general, hard disk in particular.
Exercises
l. Compare and contrast program-controlled 1/0 with direct memory access (DMA).
2. Assume a disk drive with the following characteristics:
o
Number of surfaces = 200.
o
Number of tracks per surface = 100.
• Number of sectors per track = 50.
o
Bytes per sector = 256.
• Speed = 2400 RPM.
What is the total disk capacity?
What is the average rotational latency?
3. A disk has 20 surfaces (i.e., 10 double-sided platters). Each surface has 1000
tracks. Each track has 128 sectors. Each sector can hold 64 bytes. The disk space
allocation policy allocates an integral number of contiguous cylinders to each file.
How many bytes are contained in one cylinder?
How many cylinders are needed to accommodate a 5-MB file on the disk?
How much space is wasted in allocating this 5-MB file?
4. A disk has the following configuration:
The disk has 310MB.
Track size: 4096 bytes
Sector Size: 64 bytes
A programmer has 96 objects, each being 50 bytes in size. He decides to save each
object as an individual file. How many bytes (in total) are actually written to disk?
5. Describe in detail the sequence of operations involved in a DMA data transfer.
6. What are the mechanical operations that must take place before a disk drive can
read data?
Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
Exercises
7. A disk drive has 3 double-sided platters. The drive has 300 cylinders. How many
tracks are there per surface?
8. Assume the following specifications for a disk drive:
• 512 bytes per sector
• 30 tracks per surface
• 2 platters
• zoned bit recording with the following specifications:
• 3 Zones
Zone 3 (outermost): 12 tracks, 200 sectors per track
Zone 2: 12 tracks, 150 sectors per track
Zone 1: 6 tracks, 50 sectors per track
What is the total capacity of this drive with the zoned-bit recording?
9. Assume the following specifications for a disk drive:
• 256 bytes per sector
• 200 sectors per track
• 1000 tracks per surface
• 2 platters
• Rotational speed 7500 RPM
• Normal recording
What is the transfer rate of the disk?
10. Assume the following specifications for a disk drive:
• 256 bytes per sector
• 100 sectors per track
• 1000 tracks per surface
• 3 platters
• Average seek time of 8 ms
• Rotational speed 15000 RPM
• Normal recording
a. What would be the time to read 10 contiguous sectors from the same track?
b. What would be the time to read 10 sectors at random?
11. What are the objectives of a disk scheduling algorithm?
12. Using the number of tracks traversed as a measure of the time, compare all the
disk scheduling algorithms for the specifics of the disk and the request pattern
given in Example 10.4, with respect to the different performance metrics
summarized in Table 10.3.
467
Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
2470715 2014/11/17 158.12.88.6
Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
518
Chapter ll • File System
Microsoft, or anything else), the implementation of the file system continually evolves.
Some of the changes are due to the evolution in disk technology, and some are due to the
changes in the types of files used in applications. For example, modern workloads
generate multimedia files (audio, graphics, photos, video, etc.), and the file system
implementation has to adapt in order to efficiently support such diverse file types.
In this chapter, we have only scratched the surface of the intricacies involved in
implementing a file system. We hope that we have stimulated your interest enough to
get you to take a more advanced course in operating systems.
Exercises
1. Where can the attribute data for a file be stored? Discuss the pros and cons of
each choice.
2. Examine the following directory entry in UNIX:
-rwxrwxrwx
3 rama
0 Apr 27 21:01 foo
After the following commands are executed
chmod u -w foo
chmod g-w foo
what are the access rights of the file "foo"?
3. Select all that apply:
Linked allocation results in
• good sequential access
• good random access
• ability to grow the file easily
• poor disk utilization
• good disk utilization
4. Select all that apply:
Fixed contiguous allocation of disk space results in
• good sequential access
• good random access
• ability to grow the file easily
• poor disk utilization
• good disk utilization
5. Consider the following:
Number of cylinders on the disk
=
6000
Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
2470715 2013/11/19 158.12.88.6
Number of surfaces per platter
=3
=2
Number of sectors per track
= 400
Number of bytes per sector
= 512
Disk allocation policy
=
Number of platters
contiguous cylinders
a. How many cylinders should be allocated to store a file of size 1 GB?
b. How much is the internal fragmentation caused by this allocation?
6. What are the problems with FAT allocation policy?
7. Compare linked allocation policy with FAT.
8. How does indexed allocation overcome the problem of FAT and linked
allocation?
9. Consider an indexed allocation scheme on a disk
• The disk has 3 platters (2 surfaces per platter).
• There are 4000 tracks in each surface.
• Each track has 400 sectors.
• There are 512 bytes per sector.
• Each i-node is a fixed size data structure occupying one sector.
• A data block (unit of allocation) is a contiguous set of 4 cylinders.
• A pointer to a disk data block is represented by an 8-byte data structure.
a. What is the minimum amount of space used for a file on this system?
b. What is the maximum file size with this allocation scheme?
10. Consider the following for a hybrid allocation scheme:
• size of index block = 256 bytes
• size of data block = 8 KB
• size of disk block pointer = 8 bytes (to either index or data block)
• An i-node consists of 2 direct block pointers, 1 single indirect pointer, l double
indirect pointer, and l triple indirect pointer.
a. What is the maximum size (in bytes) of a file that can be stored in this file
system?
b. How many data blocks are needed for storing a data file of 1 GB?
c. How many index blocks are needed for storing the same data file of size
1GB?
11. What is the difference between hard and soft links?
Exercises
519
Username: Reginald HobbsBook: Computer Systems: An Integrated Approach to Architecture and Operating Systems. No part of any
book may be reproduced or transmitted in any form by any means without the publisher's prior written permission. Use (other than
pursuant to the qualified fair use privilege) in violation of the law or these Terms of Service is prohibited. Violators will be prosecuted to
the full extent of the law.
520
Chapter ll • File System
12. Consider the following:
touch
ln -s
ln -s
ln fl
ln £4
fl
fl £2
I*
I*
create a file fl
sym link *I
£2 £3
£4
I*
hard link
*I
*I
£5
a. How many i-nodes will be created by the previous set of commands?
b. What is the reference count on each node thus created?
13. For ext2 file system with a disk block size of 8 KB and a pointer to disk blocks
of 4 bytes, what is the largest file that can be stored on the system? Sketch the
structure of ani-node and show the calculations to arrive at the maximum file
size (see Example 11.8).
Bibliographic Notes and Further Reading
In systems, the microarchitecture of the processor, cache memories, and file systems are
perhaps the three most well-studied topics. The fixation on these three topics is perhaps
understandable, since they have the biggest impact on application performance.
Whereas UNIX was invented in Bell labs by Ritchie and Thompson, much of the credit
for popularizing UNIX, especially in the academic world, goes to the efforts of the
researchers at UC-Berkeley; in particular Bill joy, the co-founder of Sun Microsystems.
For a seminal paper that gives an overview of the design principles underlying the
Berkeley UNIX file system, the reader is referred to [McKusick, 1984]. McKusick et aL
[McKusick, 19961 present a detailed description on the design and implementation of
the Berkeley UNIX operating system. This is an excellent resource for any student who
wishes to write an operating system. The article by Prabhakaran et aL [Prabhakaran,
2005] is an excellent resource to understand the evolution of journaling file systems
such as Linux ext3, ReiserFS, and Microsoft NTFS. Linux, being an open-source
project, evolves continually. Therefore, the best source of information to learn about
Unux is online resources. 2 The books on Unux by Love [Love, 2003] and Bovet and
Cesati [Bovet, 20051 are additional good resources for the Linux enthusiast. For details
on Microsoft file systems, the reader is referred to [Russinovich, 2005].
2. www.linux.org.
Purchase answer to see full
attachment