OS Assignment 9 and 10

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Assignment 9

Explain the various methods of allocating disk space:

1. Contiguous File Allocation


2. Linked List Allocation
3. Index File Allocation

The allocation methods define how the files or data are stored in the disk space/blocks.
There are three main disk space or file allocation methods.

1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation

The main purpose for this different methods is to provide Efficient disk space utilization.
Fast access to the file blocks

Contiguous File Allocation


In this methods, each file occupies a contiguous block of disk space. When a file
is created, the file system searches for contiguous set of blocks large enough to
storage the entire file.
Advantages
This is extremely fast since the number of seeks are minimal because of
contiguous allocation of file blocks.
Both Sequential and Direct Accesses are supported by this.
Disadvantages
This methods suffers a problem of increasing file size is difficult because it
depends on the availability of contiguous memory at a particular instance.
This methods also suffers from both internal and external fragmentation. This
makes it inefficient in terms of memory utilization.
Linked List Allocation
In this methods, each file is a linked list of disk blocks, where each block contains
a pointer to the next block in the file. There's no requirement for contiguous
allocation, and files can be scattered across the disk. The last block of each file
contains a special value to indicate the end of the file.
Advantage
This is vary flexible in terms of file size. File size can be increased easily
since the system does not have to look for a contiguous chuck of memory.
This method does not suffer from external fragmentation. This makes it
relatively better in terms of memory utilization.
Disadvantages
The file blocks are distributed randomly on the disk thus, a large number of
seeks are needed to access every block individually. This makes linked
allocation slower.
It does not support random or direct access. We can not directly access the
blocks of a file.
Pointer required in the linked allocation.
Indexed File Allocation
In this methods, each file has its own index block containing pointers to all
the blocks that make up the file. The index block serves as a table of
contents for the file, mapping logical file blocks to physical disk blocks.
Advantages
This supports direct access to the blocks occupied by the file and therefore
provides fast access to the file blocks.
It overcomes the problem of external fragmentation.
Disadvantages
The pointer overhead for indexed allocation is greater than linked allocation.
For very small files, say files that expand only 2-3 blocks, the indexed
allocation would keep one entire block for the pointers which is inefficient in
terms of memory utilization. However, in linked allocation we lose the space
of only 1 pointer per block

reference:
File Allocation Methods - GeeksforGeeks
File Allocation Methods in OS - Scaler Topics

Assignment 10
Explain the concept of Paging & Segmentation with various partitioning methods
?

In the non-contiguous memory allocation technique, different parts of the same process
are stored in different places of the main memory

1. Paging
2. Segmentation

Paging
Paging is a non-contiguous memory allocation technique in which secondary
memory and the main memory is divided into equal size partitions. The
partitions of the secondary memory are called pages while the partitions of
the main memory are called Frames. They are divided into equal size
partitions to have maximum utilization of the main memory and avoid
external fragmentation.
Various partitioning methods associated with paging include:
1. Fixed Partitioning:
In fixed partitioning, physical memory is divided into fixed size
partitions, and each partition can hold one process.
Each process occupies an entire partition, and processes cannot
exceed the size of the partition.
2. Dynamic Partitioning:
In dynamic partitioning, memory is divided into variable sized partitions
to accommodate processes of varying sizes.
Paging can be combined with dynamic partitioning by dividing each
partition into fixed size frames and allocating pages to these frames
dynamically.
Segmentation
In paging, we were blindly diving the process into pages of fixed sizes but in
segmentation, we divide the process into modules for better visualization of
the process. Here each segment or module consists of the same type of
functions. For example. the main function is included in one segment, library
function is kept in other segments, and so on.
Various partitioning methods associated with segmentation include:
1. Pure Segmentation:
In pure segmentation, the logical address space is divided into
segments of variable sizes.
Each segment represents a different part of the program, such as code,
data, or stack.
Segments are mapped to physical memory using segment tables,
which contain the base address and size of each segment.
2. Segmentation with paging:
This method combines segmentation with paging to take advantage of
the benefits of both techniques.
Each segment is further divided into pages of fixed size, allowing for
more efficient use of memory.
Segment tables map segment numbers to page tables, which in turn
map page numbers to physical frames.
reference:
What are Paging and Segmentation? (afteracademy.com)
Difference Between Paging and Segmentation - GeeksforGeeks
Difference between Paging and Segmentation - javatpoint

You might also like