0% found this document useful (0 votes)
13 views13 pages

OS-Unit-6-Part-1-I Scheme

Os 6unit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views13 pages

OS-Unit-6-Part-1-I Scheme

Os 6unit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Unit-6.

Part -1.

FILE MANAGEMENT

By A.S.AHMAD,Government Polyte 1
Access Methods
• Sequential Access : -
- The simplest access method is sequential access.
- Information in the file is read and written in sequential order, one record after the other.
- This model is used in magnetic tape storage devices.
- for example, A read operation—read next—reads the next portion of the file and automatically advances a file
pointer, Similarly, the write operation—write next—appends to the end of the file and advances to the end of
the newly written material.
- in this if the n record is to be accessed then it has to scan (n-1) i.e. all previous records till the nth record.
Access Methods
• Sequential Access : -
• Advantages:
- Easy to access the next record.
- Easy to understand and implement.
- Suitable for small file size.
• Disadvantages:
- Suitable only for magnetic tape drive.
- This process is very time consuming.
- The speed is also very slow.
- It is suitable for files having very few records.
Access Methods
• Direct Access : -
• The Direct-access method uses a Random Access Devices like floppy disk, hard disk, CD ROM etc, because disks
allow random access to ANY FILE BLOCK.
• For direct access, the file is viewed as a numbered sequence of blocks or records.
• Thus, we may read block 14, then read block 53, and then write block 7. There are no restrictions on the Order
of reading or writing for a direct-access file.
• Direct-access gives immediate access to large amounts of information.
Swapping: - [Process of swap in and swap out of process]
- A process must be in main memory [RAMI to be executed.
- But a process, can be swapped temporarily out of main memory to a disk called BACKING STORE and then
brought back into main memory for its remaining execution.

- For example, assume a multiprogramming environment with a round-robin CPU-scheduling algorithm. When a
quantum expires, the memory manager will start to swap out the process that just finished and to swap in another
process into main memory at the place which has just freed by previous process.
- thus the finishes, suspended, or preempted process can be swapped out from main memory and after some time
the suspended preempted process are again swapped in for further processing, which is nothing but the swapping
process. Also called roll out, roll in.
When and why to use swapping? : -

- If the memory is divided into partition, then the swapping scheme can be used.
- Swapping reacquires a backing store i.e. disk. The backing store is commonly a fast disk.
- The system maintains a ready queue consisting of all processes whose memory images are on the backing store
or in memory and are ready to run.
- Whenever the CPU scheduler decides to execute a process, it calls the dispatcher. The dispatcher checks to see
whether the next process in the queue is in memory.
- If it is not, and if there is no free memory region, the dispatcher swaps out a process currently in memory and
swaps in the desired process.
- It then reloads registers and transfers control to the selected process.
- This provides a very fast and quick context-switch time in amongst the processes.
- Thus the blocked, or suspended, or the waiting process can be swapped out to make the room for the process
ready to execute in the ready queue.
- Thus Swapping is used for the intelligent and efficient memory and CPU utilization.
Free space / Memory Allocation Method : -
• Contiguous Allocation
Advantages : -

(1) Accessing a file that has been allocated contiguously is easy. It provides very good performance.
(2) Both sequential and direct access can be supported by contiguous allocation.
(3) quick and easy calculation of block that stores data.
(4) To access ith block in a file of length 'n', can be accessed using n+i.

Disadvantages : -

(1) Difficult to find space efficiently for a new file.


(2) before allocation we have to predict the size of a file.
(3) it suffer from external fragmentation.
Linked Allocation: -
Advantages: -
(1) There is no external fragmentation with linked allocation.
(2) Any free block on the free-space list can be linked to the chain of the file to satisfy a request for new
block.
(3) The size of a file need not be declared when that file is created.
(4) It is best suited for sequential files which are to be processed sequentially.

Disadvantages: -

(1) It does not support direct access.


(2) Another disadvantage is the space required for the pointers. In every block it reserve two bytes to store
the link information to the next block.
- (3) another problem is the Reliability –
 What happens when the link or pointer to the next block is lost or damaged.
 Also any bug or error in the operating system or disk hardware failure might result in picking
up a wrong pointer.
Indexed Allocation
- Linked allocation solves the external-fragmentation and size-declaration problems of contiguous allocation.
- Indexed allocation also solves the problem of direct access to block by bringing all the pointers together into
one location, the index block.
- Each file has its own index block, which is an array of disk-block addresses.
- The ith entry in the index block points to the i block of file
- Thus to access the particular block within a particular file, the entry in its index block is searched and the
particular block of file can be directly accessed.
Advantages: -

(1) No external fragmentation.


(2) No need to declare the file size as the block are assigned dynamically.
(3) It support direct as well as sequential access.

Disadvantages: -

(1) If the file is small required only one or two blocks then one block of the space is wasted for index block to
store the address for these one or two blocks.
(2) The pointer overhead of the indexed allocation is generally more than the pointer overhead of the linked
allocation.
(3) Deciding indexed block size for each file is complicated process especially where the process grows
while executing.
• T
ob
e co
ntin
Thanks…..
ued
…..

By A.S.AHMAD,Government Polyte 13

You might also like