Docsity

Operating Systems assignment based on space allocation, Cheat Sheet of Operating Systems

Toggle sidebar
bg1
Edith Wairimu
Scm211-0693/2022
MCS 2.1 A
OPERATING SYSTEMS I
ASSIGNMENT: SPACE ALLOCATION
INTRODUCTION
Files are located disks spaces by operating system. Operating systems deploy the following three
main ways to allocate disk space to files:
Contiguous allocation
Linked allocation
Indexed allocation
Whenever a hard disk is formatted, a system has many small areas called blocks or sectors that
are used to store any kind of file. File allocation methods are different ways by which the
operating system stores information in memory blocks, thus allowing the hard drive to be
utilized effectively and the file to be accessed.
The main idea behind these methods is to provide:
Efficient disk space utilization.
Fast access to the file blocks.
METHODS
1.Contiguous Allocation
In this scheme, each file occupies a contiguous set of blocks on the disk. For example, if a file
requires n blocks and is given a block b as the starting location, then the blocks assigned to the
file will be: b, b+1, b+2,……b+n-1. This means that given the starting block address and the
length of the file (in terms of blocks required), we can determine the blocks occupied by the file.
1
pf3
pf4
pf5

Partial preview of the text

Download Operating Systems assignment based on space allocation and more Cheat Sheet Operating Systems in PDF only on Docsity!

Scm211-0693/ MCS 2.1 A OPERATING SYSTEMS I ASSIGNMENT: SPACE ALLOCATION INTRODUCTION Files are located disks spaces by operating system. Operating systems deploy the following three main ways to allocate disk space to files:  Contiguous allocation  Linked allocation  Indexed allocation Whenever a hard disk is formatted, a system has many small areas called blocks or sectors that are used to store any kind of file. File allocation methods are different ways by which the operating system stores information in memory blocks, thus allowing the hard drive to be utilized effectively and the file to be accessed. The main idea behind these methods is to provide:  Efficient disk space utilization.  Fast access to the file blocks. METHODS

  1. Contiguous Allocation In this scheme, each file occupies a contiguous set of blocks on the disk. For example, if a file requires n blocks and is given a block b as the starting location, then the blocks assigned to the file will be: b, b+1, b+2,……b+n-1. This means that given the starting block address and the length of the file (in terms of blocks required), we can determine the blocks occupied by the file.

Scm211-0693/ MCS 2.1 A OPERATING SYSTEMS I The directory entry for a file with contiguous allocation contains Address of starting block and the length of the allocated portion. Advantages:  Both the Sequential and Direct Accesses are supported by this. For direct access, the address of the kth block of the file which starts at block b can easily be obtained as (b+k).  This is extremely fast since the number of seeks are minimal because of contiguous allocation of file blocks. Disadvantages:  This method suffers from both internal and external fragmentation. This makes it inefficient in terms of memory utilization.  Increasing file size is difficult because it depends on the availability of contiguous memory at a particular instance.

2. Linked List Allocation In this scheme, each file is a linked list of disk blocks which need not be contiguous. The disk blocks can be scattered anywhere on the disk. The directory entry contains a pointer to the starting and the ending file block. Each block contains a pointer to the next block occupied by the file. Advantages:  This is very flexible in terms of file size. File size can be increased easily since the system does not have to look for a contiguous chunk of memory.

Scm211-0693/ MCS 2.1 A OPERATING SYSTEMS I memory utilization. However, in linked allocation we lose the space of only 1 pointer per block. For files that are very large, single index block may not be able to hold all the pointers. Following mechanisms can be used to resolve this:  Linked scheme: This scheme links two or more index blocks together for holding the pointers. Every index block would then contain a pointer or the address to the next index block.  Multilevel index: In this policy, a first level index block is used to point to the second level index blocks which inturn points to the disk blocks occupied by the file. This can be extended to 3 or more levels depending on the maximum file size.  Combined Scheme: In this scheme, a special block called the Inode (information Node) contains all the information about the file such as the name, size, authority, etc and the remaining space of Inode is used to store the Disk Block addresses which contain the actual file. The first few of these pointers in Inode point to the direct blocks i.e the pointers contain the addresses of the disk blocks that contain data of the file. The next few pointers point to indirect blocks. Indirect blocks may be single indirect, double indirect or triple indirect. Single Indirect block is the disk block that does not contain the file data but the disk address of the blocks that contain the file data. Similarly, double indirect blocks do not contain the file data but the disk address of the blocks that contain the address of the blocks containing the file data. There’s also another space allocation method known as the File Allocation Table (FAT).

Scm211-0693/ MCS 2.1 A OPERATING SYSTEMS I File Allocation Table (FAT) is a file system that uses a table to store information about the allocation of files on a disk or other storage media. In a FAT file system, the file allocation table is a data structure that contains a list of entries, each of which represents a block of storage space on the disk. The entries in the file allocation table indicate whether a block of storage space is free or allocated, and if it is allocated, they indicate which file or directory the block is associated with. When a file is created, the operating system searches for a series of free blocks of storage space on the disk and records the allocation of these blocks in the file allocation table. As the file is modified or expanded, the operating system updates the entries in the file allocation table to reflect the new allocation of blocks. The FAT file system has several advantages. It is a simple and efficient file system that is well-suited to small disks and low-powered devices. It is also widely supported by many operating systems and can be used on a variety of storage media, including hard disks, floppy disks, and flash drives. However, the FAT file system also has some limitations. It can be susceptible to file fragmentation, where files become fragmented across multiple non-contiguous blocks of storage space on the disk. This can slow down file access times and reduce overall system performance. Additionally, the file allocation table can become corrupted, leading to data loss or disk errors. CONCLUSION