13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

228 File Structures Chapter 6disk is restored, since they are in stable storage.7 PERSPECTIVEThe file manager must provide an acceptable level of service for a wide range of applications.Some file managers accomplish this goal by providing a very simple but efficientservice and expect that complex applications can build on it. For example, one can makea case for the idea that a flat file space of sequential, direct-access files with minimalaccess restrictions is acceptable for many applications and is an adequate base for extensionto other applications.Other file managers accomplish the goal by providing many kinds of service. Forexample, a process might have a choice of half a dozen file types and allocation strategiesat the time it creates a file. The file manager supports all these options as efficiently as itcan. Such a file manager might actually implement a simple base structure and buildalternative structures on top of that base.Database management systems are the most difficult to serve well. They structuredata and access it in regular ways, but few file managers are equipped to take advantageof those regularities. For example, we examined storing huge files in depth-3 trees andwere pleased that a direct access required no more than four disk accesses. However, ifthe huge file is storing a database, the database is likely to contain internal pointers.These pointers might be expressed in terms of bytes from the start of the file. Followingsuch a pointer requires about four read operations. If the pointers were expressed in physicalblock number, each would need only one read operation. The structure used by thefile manager effectively decreases efficiency by a factor of 4. For this reason, databaseprograms like to avoid the file abstraction and prefer to deal directly with physicaladdresses.The internal structure of the file manager can be built in the following layers.File layer: This module creates a data structure for each open file. The data structureincludes the file descriptor and the read/write mark. Procedures in this moduleopen and close files on behalf of processes that submit the Open and Close servicecalls. The directory in which a file resides must be opened for a short time in orderto find out where the file descriptor is. If the file is named by a path, each directoryin the path must be opened for a short time.Byte layer: This module provides procedures for reading or writing any number ofbytes from or to any open file. These procedures consult the open-file structure todetermine which disk block is involved in each transput. They also modify theread/write mark. These procedures are called by the Read, Write, and Position servicecalls. They are also called by procedures in the file layer that need to readdirectories.Block layer: This module provides procedures to read and write entire blocks. Acache of recently used blocks may be maintained so that successive operations tothe same block do not require disk actions. This layer is the upper layer of the diskdriver.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!