Contiguous allocation is seldom used except in the swap area for filesystems

Contiguous allocation is seldom used except in the

This preview shows page 70 - 72 out of 102 pages.

Contiguous allocation is seldom used (except in the swap area) for filesystems because of the fragmentation problem. Instead files are divided up into blocks and each file consists of a list of blocks which may be scattered anywhere on the disk. Our problem is then to identify files amongst all of the blocks. There are three ways of doing this: 1. Linked lists. Each block of data includes a pointer to the next block of data in a linked list. The difficulty with this method is that each block must be read in the correct order and the blocks might be spread randomly over the disk. Thus the retrieval of a file could require a lot of disk head movement which is slow. 2. Linked table. A linked list of blocks for each file is stored in a file allocation table . All of the pointers for every file are collected together in one place. This table could also be cached in RAM for faster access. This method is used by MS- DOS and a number of other microcomputer operating systems. 3. Indexing. Each file has an index containing a list of blocks which contain the file itself. This index might be stored anywhere in principle. Space for it is normally allocated on the disk itself, inside reserved disk blocks, and partly inside an index table which is built when the filesystem is created. The index blocks are grouped in one place for convenient access. This system is used in UNIX. Since the index
Image of page 70
table must contain pointers to disk blocks, a way of storing the pointers must be found. If the list is small and is held in a filesystem block, then most of the block will be wasted. This is a drawback of the index method, but the main advantage of this method is that it has few limitations. 5.4.6 The UNIX ufs filesystem A file system under UNIX is created using the newfs command. A separate filesystem must be created on each separate partition of the disk. To define a filesysytem we have to define the blocksize and numerous other parameters. Each system has its own defaults which inexperienced users - and most often experienced users are wise to use. Two structures are created when a file system is created: inodes and superblocks . These are the most important objects in the filesystem. Both of these objects are information structures, in the sense of the C language and they are defined under the /usr/include/ufs directory in files fs.h and inode.h . It is instructive to look at these files. This is where the default blocksize etc will be defined on your system! The blocksize is variable, but a minimum block size of bytes i.e. 4kB is stipulated so that the system can address bytes of memory without using three level indirection (see below). Also, the last block of a file can be allocated as a fragment of a block whose size is recorded in the inode. (It might be a half, a quarter or an eighth of a block.) A superblock contains the information on the boundaries of the partition (cylinder groups) and information about where the inode table is and where datablocks start. If the superblock is lost or damaged, the whole filesystem would be unreadable. It is so important that, when a file
Image of page 71
Image of page 72

You've reached the end of your free preview.

Want to read all 102 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors