Contiguous Allocation Method
Contiguous Allocation Method
FILE LOCKING:
The file locking mechanism provides functionality similar to reader-write locks. A reader-write lock requires specifying the mode of the lock-in their read and write access. When a process wishes to only read shared data, it requests the reader-writer lock in reading mode. Similarly, when a process wishes to modify the shared data. it must request the lock in write mode.
File locking enables processes to implement exclusive access to a file. There are three major options for the implementation of the file.
A file can be locked as a whole or only a part of the file can be locked.
A file may be locked for reading writing, modifying appending, etc. Most of the system provides both read and write locks. If a file is locked by a process for reading, then other processes can only read data from the file but the process cannot write new data into it (i,e write access by other process is defined) Similarly, if a file is locked by a process for writing, then other processes cannot read nor write the file (it means that both read and write accesses by other processes are defined.
Locking may be either mandatory or advisory. If the locking is mandatory, then the operating system does not allow any other process to access the locked file. Similarly, if the locking is advisory, it is up to software developed to ensure that locks are appropriately acquired and released. Windows operating system adopts mandatory locking, and UNIX adopts advisory locking.
FILE BLOCKING:
Fixed blocking :
Variable-Lenght Spanned Blocking:
variable-length Un-Spanned Blocking :
ALLOCATING SPACE TO FILES ON SECONDARY STORAGE:
A file is stored on the secondary storage as a collection of blocks. The file management system (a part of the operating system) is responsible for allocating blocks to files. The main issue is how to allocate space to files on secondary storage (disk) so that disk space can be efficiently and files can be accessed quickly.
Allocated Method:
- Contiguous allocated
- Linked allocated
- Indexed allocated
Contiguous Allocated:
Advantages:
The main advantages of contiguous allocation are as follows:
Contiguous allocation is best for sequential access files.
- It is very simple to implement.
- I/O performance is excellent because multiple blocks (or entire file) can be retrieved from the disk in a single operating.
- Both sequential and direct access method can easily be implemented using contiguous allocation.
- If any block of a file containing data is damaged, then other data stored in other blocks can be retrieved.
Disadvantages:
- Without this advance information, the operating system does not know how much disk space is to reserve.
- As files are created and deleted, external fragmentation may occur. So it becomes difficult to find contiguous blocks of space of sufficient length. From time to time, it will be necessary to call a compaction algorithm to make free space on the disk.
Linked List Allocated:
Advantages:
- There is no external fragmentation and any free blocks can be used for storing data of other files.
- It is very easy and suitable for sequential access files.
- There is no need to compact disk space.
Indexed Allocation:
Advantages:
- It solves all the problems faced in linked list allocation.
- Direct access can be implemented very easily.
- Indexed allocation supports both sequential and direct access.
Disadvantages:
- If the index block of life is damaged, then data of the file cannot be accessed.
- A separate index for each file is created, so extra space on the disk is used for index blocks.
Comments
Post a Comment