Hardware Reference
In-Depth Information
dress 13 is used to point to a triple indirect block containing the addresses of 256
double indirect blocks. Using the direct, single, double, and triple indirect ad-
dresses, up to 16,843,018 blocks can be addressed, giving a theoretical maximum
file size of 17,247,250,432 bytes. If disk addresses are 64 bits instead of 32, and
disk blocks are 4 KB, then files can be really, really, really big. Free disk blocks
are kept on a linked list. When a new block is needed, the next block is plucked
from the list. As a result, the blocks of each file are scattered around the disk.
In order to make disk I/O more efficient, when a file is opened, its i-node is
copied to a table in main memory and is kept there for handy reference as long as
the file remains open. In addition, a pool of recently referenced disk blocks is
maintained in memory. Because most files are read sequentially, it often happens
that a file reference requires the same disk block as the previous reference. To
strengthen this effect, the system also tries to read the next block in a file, before it
is referenced, in order to speed up processing. All this optimization is hidden from
the user; when a user issues a read call, the program is suspended until the re-
quested data are available in the buffer.
With this background information, we can now take a look to see how file I/O
works. Open causes the system to search the directories for the specified path. If
the search is successful, the i-node is read into an internal table. Read s and write s
require the system to compute the block number from the current file position.
The disk addresses of the first 10 blocks are always in main memory (in the i-
node); higher-numbered blocks require one or more indirect blocks to be read first.
Lseek just changes the current position pointer without doing any I/O.
Link and unlink are also simple to understand now. Link looks up its first argu-
ment to find the i-node number. Then it creates a directory entry for the second
argument, putting the i-node number of the first file in that entry. Finally, it in-
creases the link count in the i-node by one. Unlink removes a directory entry and
decrements the link count in the i-node. If it is zero, the file is removed and all the
blocks are put back on the free list.
Windows 7 I/O
Windows 7 supports several file systems, the most important of which are
NTFS ( NT File System ) and the FAT ( File Allocation Table ) file system. The
former is a new file system developed specifically for NT; the latter is the old MS-
DOS file system, which was also used on Windows 95/98 (albeit with support for
longer file names). Since the FAT file system is basically obsolete except for USB
sticks and memory cards for cameras, we will study NTFS below.
File names in NTFS can be up to 255 characters long. File names are in Uni-
code, allowing people in countries not using the Latin alphabet (e.g., Japan, India,
and Israel) to write file names in their native language. (In fact, Windows 7 uses
Unicode throughout internally; versions starting with Windows 2000 have a single
binary that can be used in any country and still use the local language because all
 
Search WWH ::




Custom Search