13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

214 File Structures Chapter 6completes successfully, the results of its operations will never be lost.6 PHYSICAL REPRESENTATIONThere are many ways to organize files on disks. A few principles seem to be universal.Disk blocks have numbers, and complex structures can be placed on the disk byhaving data in one block refer to another block by number.Each file is described by a file descriptor, which tells how the file is physicallyarranged on the disk.Each physical disk is described by a disk descriptor, which tells how the disk isarranged into areas and which parts are currently unused. The disk descriptor isstored at a well known location on the disk.Information may be stored redundantly on the disk to allow programs to try to restructurethe disk if it gets confused. Confusion is the typical result of unscheduledoperating-system failures, because the structure may be undergoing modification atthe time of the failure. Even worse, the disk may be in the middle of writing ablock when failure occurs. Restructuring a garbaged disk is called salvaging.The basic unit of allocation is the single disk block, although entire tracks orcylinders may be allocated at once to keep large regions in a file contiguous on thedisk. This attempt to keep files in local regions on the disk is called clustering. Itis based on the Cache Principle, since it is faster to read or write on the disk atcylinders close to the current position, and the most likely request to come afterone file request is another request on the same file. Clustering may also beattempted to keep files that are in the same directory positioned close together onthe disk. <strong>An</strong>other form of clustering, called skewing, spaces consecutive blocks ofa file a few sectors apart. As a result, a typical process reading the entire file willfind the next file block under the disk read/write head at the time it needs it. Somedisk controllers interleave sectors to place consecutively numbered ones some distancefrom each other on the same track. In this case, the file manager should mostlikely not attempt skewing.Searching file structures and allocating free blocks would be too time consuming ifthe information is stored only on the disk. In accordance with the Cache Principle,some structure and allocation information is duplicated in main store. As is typicallythe case with caches, the cached (main-store) data and the actual (disk) datawill be out of step. <strong>Operating</strong> system failures (crashes) are therefore even moreserious than they seem because they may lose recent changes. To mitigate thedanger, all main-store caches are occasionally (perhaps every minute) archived tothe disk. Perhaps the worst time for a catastrophic failure is during archiving.The facilities provided by the file service determine the structures that must beused. For example, direct access into arbitrary positions in a file requires differentstructures from sequential access. Hierarchical directories and flat directoriesrequire different structures. Different methods of access control also need differentstructures.

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

Saved successfully!

Ooh no, something went wrong!