Subscribe by Email


Showing posts with label Linked. Show all posts
Showing posts with label Linked. Show all posts

Sunday, June 2, 2013

Explain the various Disk Allocation methods? – Part 2

In this article we discuss about the non-contiguous disk allocation methods i.e., the linked allocation and the indexed allocation. 

What is a Linked Allocation?

- In linked allocation a single file might be stored all over the disk and these scattered parts are linked to each other just like a linked list. 
- Few bytes in the memory block are used for storing the address of the following linked block.
- This type of allocation has two major advantages mentioned below:
  1. Simplicity and
  2. Non – requirement of disk compaction
- Since the nature of the allocation method is non-contiguous, it does not lead to any external fragmentation of the disk space.
- And since all the memory blocks have been linked to each other, a memory block available anywhere in the memory can be used for satisfying the requests made by the processes. 
- Declaring the file size for the linked allocation is not required during its creation. 
- There are no issues even if the file continues to grow as long as free blocks are available and since the blocks can always be linked up. 
- As a consequence of all this, the need for disk compaction is eliminated. 

Disadvantages of Linked Allocation

But there are disadvantages of using linked allocation. They are:

Direct access to the disk blocks becomes slow: 
For finding a particular block of the file, the search has to begin at the starting point of the file and the successive pointers have to be followed till the destination block is reached.

Space required by the pointers: 
- Suppose out of 512 words of a memory block, 2 are required for storing the pointers, then we have 39 percent of the total disk being used by the pointers rather than for data. 
- This adds to the space requirement of the file blocks.

Reliability: 
- Because of all the blocks being linked via the pointers, even if one pointer gets damaged or wrong, the successive blocks can become inaccessible. 
- This problem is quite common and thus most of the operating systems avoid this problem by keeping redundant copies of these pointers in a special file. 
The basic idea here is to keep the list of the pointers in the physical memory of the system. 
- This also allows for the faster access to the disk blocks.

What is Indexed allocation?

- The linked allocation method does not provide support for the direct access and this problem is solved by the indexed allocation method. 
- In this method, all the pointers are placed over an index. 
- Thus, these pointers together form the index block. 
- The address of this address block is then stored in the directory. 
- The pointer at the nth number in the index block points to the nth block of the associated file. 
- The purpose of the index blocks is somewhat similar to that of the page map tables; however both of these are implemented in a different way.
- First level index is used for searching the index of second level and the second one is used for searching the third one and the process may continue till the fourth level. 
- But in most of the cases the indexes of the first two levels are sufficient. 
- With this method, second level index blocks (128 x 128) can be easily addressed and files of size of up to 8mb can be supported. 
- Assuming the same thing, files of size up to 1 gb can be addressed.

Advantages and Disadvantage of Indexed Allocation

- The major advantage of this allocation technique is that it does not give rise to external fragmentation and offers a high level of efficiency in random accessing. 
- Also, using this technique mapping can be done around the disk blocks that are known to be bad. 
-Bit mapping can be used for indexing the free space. 

The biggest disadvantage of this allocation technique is the large number disk accesses required for the retrieval of the address of the destination block in the memory. 


Saturday, June 1, 2013

Explain the various Disk Allocation methods? – Part 1

Management of space of the secondary data storage devices is one of the most necessary functions of the file system. This includes tracking which blocks of memory or disk are being allocated to the files and which blocks are free to be allocated. 
There are two main problems faced by the system during allocation of the space to different files. Firstly, the access to the files has to be fast and secondly, the disk space has to be effectively utilized. Both of these combine to form the big problem of disk management. These two problems are more common with the physical memory of the system. 

However, the secondary storage of the system also introduces 2 additional problems which are long disk access time and blocks of larger size to deal with. In spite of all these problems, there are considerations that are common for both the storage such as the non – contiguous and contiguous space allocation. 

Types of Disk Allocation Methods


The following are the 3 widely used allocation techniques:
Ø  Contiguous
Ø  Linked
Ø  Indexed
- The linked and the indexed allocation techniques fall under the category of the non-contiguous space allocation. 
- All the methods have their own pros and cons.
- It is in the term of blocks that all the input and output operations are carried out on the disk. 
- Software is responsible for converting from the logical record to physical storage blocks.

Contiguous Allocation: 
- This allocation technique assigns only the contiguous memory blocks to the files. 
- The size of the memory required is mentioned by the user in advance for the holding the file. 
- The file is then created only if that much amount of memory is available otherwise not. 
- It is the advantage of the contiguous memory allocation technique that all the successive file records are saved adjacent to each other physically. 
- This causes an increase on the disk access time of the files. 
- This can be concluded from the fact that if the files are scattered all about the disk, then it takes a lot more time to access them. 
- Accessing files when they have been organized in a proper order is quite easy.
- To access the files sequentially, the system uses the address of the last memory block and if required moves to the next one. 
- Both direct and sequential accesses are supported by the contiguous memory allocation technique. 
- The problem with this allocation method is that every time a new contiguous space cannot be found for the new files if a majority of the memory is already in use and if the file size is larger than the available memory.  


Non–Contiguous Memory Allocation: 
- It happens a lot of time that the files grow or shrink in size with usage and time. 
- Therefore, it becomes difficult to determine the exact space required for the files since the users do not have any advance knowledge about the growing size of their files. 
- This is why the systems using the contiguous memory allocation techniques are being replaced by the ones with the non-contiguous storage allocation which is more practical and dynamic in nature. 
- The linked allocation technique mentioned above in the article, is a disk – based implementation of the linked list. 
- Each file is considered to be a list of the disk blocks linked to each other. 
- It does not matter whether the blocks are scattered about the disk. 
- In each block, few bytes are reserved for storing the address of the next block in chain.
- The pointer to the first and the last block of the file is stored in the directory. 


Facebook activity