OS-Unit-6-Part-1-I Scheme
OS-Unit-6-Part-1-I Scheme
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 : -
Disadvantages: -
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